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

Commit e4bcb3f8 authored by Wei Jia's avatar Wei Jia Committed by Android Git Automerger
Browse files

am 238a487a: am e3cb2507: am 4b995f73: Merge "libstagefright: fix handling of...

am 238a487a: am e3cb2507: am 4b995f73: Merge "libstagefright: fix handling of mSampleTimeEntries and mNumSampleSizes in SampleTable." into lmp-dev

* commit '238a487a':
  libstagefright: fix handling of mSampleTimeEntries and mNumSampleSizes in SampleTable.
parents 3dcb448f 238a487a
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -27,6 +27,11 @@
#include <media/stagefright/DataSource.h>
#include <media/stagefright/Utils.h>

/* TODO: remove after being merged into other branches */
#ifndef UINT32_MAX
#define UINT32_MAX       (4294967295U)
#endif

namespace android {

// static
@@ -282,6 +287,9 @@ status_t SampleTable::setSampleSizeParams(

    mDefaultSampleSize = U32_AT(&header[4]);
    mNumSampleSizes = U32_AT(&header[8]);
    if (mNumSampleSizes > (UINT32_MAX - 12) / 16) {
        return ERROR_MALFORMED;
    }

    if (type == kSampleSizeType32) {
        mSampleSizeFieldSize = 32;
@@ -498,7 +506,7 @@ int SampleTable::CompareIncreasingTime(const void *_a, const void *_b) {
void SampleTable::buildSampleEntriesTable() {
    Mutex::Autolock autoLock(mLock);

    if (mSampleTimeEntries != NULL) {
    if (mSampleTimeEntries != NULL || mNumSampleSizes == 0) {
        return;
    }

@@ -541,6 +549,10 @@ status_t SampleTable::findSampleAtTime(
        uint32_t *sample_index, uint32_t flags) {
    buildSampleEntriesTable();

    if (mSampleTimeEntries == NULL) {
        return ERROR_OUT_OF_RANGE;
    }

    uint32_t left = 0;
    uint32_t right_plus_one = mNumSampleSizes;
    while (left < right_plus_one) {
+3 −2
Original line number Diff line number Diff line
@@ -142,8 +142,9 @@ private:
    // normally we don't round
    inline uint64_t getSampleTime(
            size_t sample_index, uint64_t scale_num, uint64_t scale_den) const {
        return (mSampleTimeEntries[sample_index].mCompositionTime
            * scale_num) / scale_den;
        return (sample_index < (size_t)mNumSampleSizes && mSampleTimeEntries != NULL
                && scale_den != 0)
                ? (mSampleTimeEntries[sample_index].mCompositionTime * scale_num) / scale_den : 0;
    }

    status_t getSampleSize_l(uint32_t sample_index, size_t *sample_size);