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

Commit 9954b898 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 10205056 from 4c2a16c7 to udc-release

Change-Id: I151ad22f04b48e791df0498603d0972e3a157476
parents 42befdd2 4c2a16c7
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -167,6 +167,7 @@ CCodecBufferChannel::CCodecBufferChannel(
        Mutexed<Output>::Locked output(mOutput);
        output->outputDelay = 0u;
        output->numSlots = kSmoothnessFactor;
        output->bounded = false;
    }
    {
        Mutexed<BlockPools>::Locked pools(mBlockPools);
@@ -727,7 +728,7 @@ void CCodecBufferChannel::feedInputBufferIfAvailableInternal() {
        Mutexed<Output>::Locked output(mOutput);
        if (!output->buffers ||
                output->buffers->hasPending() ||
                output->buffers->numActiveSlots() >= output->numSlots) {
                (!output->bounded && output->buffers->numActiveSlots() >= output->numSlots)) {
            return;
        }
    }
@@ -1509,6 +1510,7 @@ status_t CCodecBufferChannel::start(
        Mutexed<Output>::Locked output(mOutput);
        output->outputDelay = outputDelayValue;
        output->numSlots = numOutputSlots;
        output->bounded = bool(outputSurface);
        if (graphic) {
            if (outputSurface || !buffersBoundToCodec) {
                output->buffers.reset(new GraphicOutputBuffers(mName));
+3 −0
Original line number Diff line number Diff line
@@ -321,6 +321,9 @@ private:
        std::unique_ptr<OutputBuffers> buffers;
        size_t numSlots;
        uint32_t outputDelay;
        // true iff the underlying block pool is bounded --- for example,
        // a BufferQueue-based block pool would be bounded by the BufferQueue.
        bool bounded;
    };
    Mutexed<Output> mOutput;
    Mutexed<std::list<std::unique_ptr<C2Work>>> mFlushedConfigs;
+4 −0
Original line number Diff line number Diff line
@@ -637,6 +637,10 @@ status_t Codec2InfoBuilder::buildMediaCodecList(MediaCodecListWriter* writer) {
            if (encoder) {
                attrs |= MediaCodecInfo::kFlagIsEncoder;
            }
            if (codec.quirkSet.find("attribute::enforce-xml-capabilities") !=
                codec.quirkSet.end()) {
                attrs |= MediaCodecInfo::kFlagIsEnforceXmlCapabilities;
            }
            if (trait.owner == "software") {
                attrs |= MediaCodecInfo::kFlagIsSoftwareOnly;
            } else {
+105 −0
Original line number Diff line number Diff line
@@ -102,6 +102,111 @@ status_t MediaCodecInfo::Capabilities::writeToParcel(Parcel *parcel) const {
    return OK;
}

static int32_t convertToIntNoSign(const AString &str) {
    char *end;
    unsigned long u = strtoul(str.c_str(), &end, 10);
    if (end == str.c_str() || *end != '\0') {
        // malformed integer
        return -1;
    }
    if (u > INT32_MAX) {
        // The number is too big
        return -1;
    }
    return static_cast<int32_t>(u);
}

static void parseSize(const AString &str, int32_t *width, int32_t *height) {
    ssize_t ix = str.find("x");
    if (ix == -1) {
        ix = str.find("*");
        if (ix == -1) {
            return;
        }
    }
    AString wStr(str, 0, ix);
    AString hStr(str, ix + 1, str.size() - ix - 1);
    *width = convertToIntNoSign(wStr);
    *height = convertToIntNoSign(hStr);
}

static void parseRange(const AString &str, int32_t *min, int32_t *max) {
    ssize_t ix = str.find("-");
    if (ix == -1) {
        return;
    }
    AString minStr(str, 0, ix);
    AString maxStr(str, ix + 1, str.size() - ix - 1);
    *min = convertToIntNoSign(minStr);
    *max = convertToIntNoSign(maxStr);
}

static void parseSizeRange(const AString &str, int32_t *minWidth, int32_t *minHeight,
                           int32_t *maxWidth, int32_t *maxHeight) {
    ssize_t ix = str.find("-");
    if (ix == -1) {
        return;
    }
    AString minSize(str, 0, ix);
    AString maxSize(str, ix + 1, str.size() - ix - 1);
    parseSize(minSize, minWidth, minHeight);
    parseSize(maxSize, maxWidth, maxHeight);
}


bool MediaCodecInfo::Capabilities::isResolutionSupported(int32_t width, int32_t height) {
    AString blockSizeStr;
    AString blockCountStr;
    int32_t blockWidth = -1;
    int32_t blockHeight = -1;
    int32_t maxBlocks = -1;
    int32_t minBlocks = -1;

    if (mDetails->findString("block-size", &blockSizeStr)) {
        parseSize(blockSizeStr, &blockWidth, &blockHeight);
    }
    if (mDetails->findString("block-count-range", &blockCountStr)) {
        parseRange(blockCountStr, &minBlocks, &maxBlocks);
    }
    if (maxBlocks != -1 && blockWidth != -1 && blockHeight != -1) {
        if (maxBlocks < ((width + blockWidth - 1) / blockWidth) *
                         ((height + blockHeight - 1) / blockHeight)) {
            return false;
        }
    }

    AString sizeRangeStr;
    int32_t maxWidth = -1;
    int32_t maxHeight = -1;
    int32_t minWidth = -1;
    int32_t minHeight = -1;

    if (mDetails->findString("size-range", &sizeRangeStr)) {
        parseSizeRange(sizeRangeStr, &minWidth, &minHeight, &maxWidth, &maxHeight);
    }

    if (maxWidth != -1 && maxHeight != -1) {
        // The logic is that the format is not supported if width or height is outside
        // of min-max limits, UNLESS codec allows to swap it and in this case format is
        // not supported if width is outside of min-max height or height is outside of
        // min-max width
        if (width < minWidth || height < minHeight ||
            width > maxWidth || height > maxHeight) {
            int32_t swappable = 0;
            if (!mDetails->findInt32("feature-can-swap-width-height", &swappable) ||
                swappable == 0) {
                return false;
            }
            if (width < minHeight || height < minWidth ||
                width > maxHeight || height > maxWidth) {
                return false;
            }
        }
    }
    return true;
}


void MediaCodecInfo::CapabilitiesWriter::addDetail(
        const char* key, const char* value) {
    mCap->mDetails->setString(key, value);
+3 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ struct MediaCodecInfo : public RefBase {
        kFlagIsVendor = 1 << 1,
        kFlagIsSoftwareOnly = 1 << 2,
        kFlagIsHardwareAccelerated = 1 << 3,
        kFlagIsEnforceXmlCapabilities = 1 << 4,
    };

    struct Capabilities : public RefBase {
@@ -96,6 +97,8 @@ struct MediaCodecInfo : public RefBase {
         */
        const sp<AMessage> getDetails() const;

        bool isResolutionSupported(int32_t width, int32_t height);

    protected:
        Vector<ProfileLevel> mProfileLevels;
        SortedVector<ProfileLevel> mProfileLevelsSorted;
Loading