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

Commit 990b562e authored by Chih-Yu Huang's avatar Chih-Yu Huang Committed by Chih-yu Huang
Browse files

ccodec: FetchLinearBlock() pass usage argument to C2BlockPool

Originally the usage argument is dropped when calling
CalculateMinMaxUsage(). This CL changes to union the usage argument
and the minimum usage, then pass it to the C2BlockPool.

Bug: 170694288
Test: android.media.cts.MediaCodecTest#testException
Change-Id: I057d6bd1c25112126492361d39192d8d6f4074e5
(cherry picked from commit 4ebf813ab08cbbb2b5edea62649cee925bb6499d)
parent f0521302
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -2168,15 +2168,17 @@ status_t CCodec::CanFetchLinearBlock(
            return OK;
        }
    }
    uint64_t minUsage = usage.expected;
    uint64_t maxUsage = ~0ull;
    std::set<C2Allocator::id_t> allocators;
    GetCommonAllocatorIds(names, C2Allocator::LINEAR, &allocators);
    if (allocators.empty()) {
        *isCompatible = false;
        return OK;
    }

    uint64_t minUsage = 0;
    uint64_t maxUsage = ~0ull;
    CalculateMinMaxUsage(names, &minUsage, &maxUsage);
    minUsage |= usage.expected;
    *isCompatible = ((maxUsage & minUsage) == minUsage);
    return OK;
}
@@ -2203,14 +2205,16 @@ static std::shared_ptr<C2BlockPool> GetPool(C2Allocator::id_t allocId) {
// static
std::shared_ptr<C2LinearBlock> CCodec::FetchLinearBlock(
        size_t capacity, const C2MemoryUsage &usage, const std::vector<std::string> &names) {
    uint64_t minUsage = usage.expected;
    uint64_t maxUsage = ~0ull;
    std::set<C2Allocator::id_t> allocators;
    GetCommonAllocatorIds(names, C2Allocator::LINEAR, &allocators);
    if (allocators.empty()) {
        allocators.insert(C2PlatformAllocatorStore::DEFAULT_LINEAR);
    }

    uint64_t minUsage = 0;
    uint64_t maxUsage = ~0ull;
    CalculateMinMaxUsage(names, &minUsage, &maxUsage);
    minUsage |= usage.expected;
    if ((maxUsage & minUsage) != minUsage) {
        allocators.clear();
        allocators.insert(C2PlatformAllocatorStore::DEFAULT_LINEAR);