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

Commit ead20ba1 authored by Sungtak Lee's avatar Sungtak Lee Committed by Automerger Merge Worker
Browse files

Merge "Codec2: Add C2Fence returnable fetch interfaces to C2BlockPool" am:...

Merge "Codec2: Add C2Fence returnable fetch interfaces to C2BlockPool" am: 63802239 am: 1a8fbc6e

Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/1650113

Change-Id: Ied82b06eb4e34b9d4f3afbd97070d3c47019f56b
parents bcc9fcaf 1a8fbc6e
Loading
Loading
Loading
Loading
+98 −7
Original line number Diff line number Diff line
@@ -642,7 +642,8 @@ public:
     * \retval C2_REFUSED   no permission to complete the allocation
     * \retval C2_BAD_VALUE capacity or usage are not supported (invalid) (caller error)
     * \retval C2_OMITTED   this allocator does not support 1D allocations
     * \retval C2_CORRUPTED some unknown, unrecoverable error occured during allocation (unexpected)
     * \retval C2_CORRUPTED some unknown, unrecoverable error occurred during allocation
     *                      (unexpected)
     */
    virtual c2_status_t newLinearAllocation(
            uint32_t capacity __unused, C2MemoryUsage usage __unused,
@@ -666,7 +667,8 @@ public:
     * \retval C2_REFUSED   no permission to recreate the allocation
     * \retval C2_BAD_VALUE invalid handle (caller error)
     * \retval C2_OMITTED   this allocator does not support 1D allocations
     * \retval C2_CORRUPTED some unknown, unrecoverable error occured during allocation (unexpected)
     * \retval C2_CORRUPTED some unknown, unrecoverable error occurred during allocation
     *                      (unexpected)
     */
    virtual c2_status_t priorLinearAllocation(
            const C2Handle *handle __unused,
@@ -699,7 +701,8 @@ public:
     * \retval C2_REFUSED   no permission to complete the allocation
     * \retval C2_BAD_VALUE width, height, format or usage are not supported (invalid) (caller error)
     * \retval C2_OMITTED   this allocator does not support 2D allocations
     * \retval C2_CORRUPTED some unknown, unrecoverable error occured during allocation (unexpected)
     * \retval C2_CORRUPTED some unknown, unrecoverable error occurred during allocation
     *                      (unexpected)
     */
    virtual c2_status_t newGraphicAllocation(
            uint32_t width __unused, uint32_t height __unused, uint32_t format __unused,
@@ -724,7 +727,8 @@ public:
     * \retval C2_REFUSED   no permission to recreate the allocation
     * \retval C2_BAD_VALUE invalid handle (caller error)
     * \retval C2_OMITTED   this allocator does not support 2D allocations
     * \retval C2_CORRUPTED some unknown, unrecoverable error occured during recreation (unexpected)
     * \retval C2_CORRUPTED some unknown, unrecoverable error occurred during recreation
     *                      (unexpected)
     */
    virtual c2_status_t priorGraphicAllocation(
            const C2Handle *handle __unused,
@@ -908,7 +912,8 @@ public:
     * \retval C2_REFUSED   no permission to complete any required allocation
     * \retval C2_BAD_VALUE capacity or usage are not supported (invalid) (caller error)
     * \retval C2_OMITTED   this pool does not support linear blocks
     * \retval C2_CORRUPTED some unknown, unrecoverable error occured during operation (unexpected)
     * \retval C2_CORRUPTED some unknown, unrecoverable error occurred during operation
     *                      (unexpected)
     */
    virtual c2_status_t fetchLinearBlock(
            uint32_t capacity __unused, C2MemoryUsage usage __unused,
@@ -937,7 +942,8 @@ public:
     * \retval C2_REFUSED   no permission to complete any required allocation
     * \retval C2_BAD_VALUE capacity or usage are not supported (invalid) (caller error)
     * \retval C2_OMITTED   this pool does not support circular blocks
     * \retval C2_CORRUPTED some unknown, unrecoverable error occured during operation (unexpected)
     * \retval C2_CORRUPTED some unknown, unrecoverable error occurred during operation
     *                      (unexpected)
     */
    virtual c2_status_t fetchCircularBlock(
            uint32_t capacity __unused, C2MemoryUsage usage __unused,
@@ -969,7 +975,8 @@ public:
     * \retval C2_BAD_VALUE width, height, format or usage are not supported (invalid) (caller
     *                      error)
     * \retval C2_OMITTED   this pool does not support 2D blocks
     * \retval C2_CORRUPTED some unknown, unrecoverable error occured during operation (unexpected)
     * \retval C2_CORRUPTED some unknown, unrecoverable error occurred during operation
     *                      (unexpected)
     */
    virtual c2_status_t fetchGraphicBlock(
            uint32_t width __unused, uint32_t height __unused, uint32_t format __unused,
@@ -980,6 +987,90 @@ public:
    }

    virtual ~C2BlockPool() = default;

    /**
     * Blocking fetch for linear block. Obtains a linear writable block of given |capacity|
     * and |usage|. If a block can be successfully obtained, the block is stored in |block|,
     * |fence| is set to a null-fence and C2_OK is returned.
     *
     * If a block cannot be temporarily obtained, |block| is set to nullptr, a waitable fence
     * is stored into |fence| and C2_BLOCKING is returned.
     *
     * Otherwise, |block| is set to nullptr and |fence| is set to a null-fence. The waitable
     * fence is signalled when the temporary restriction on fetch is lifted.
     * e.g. more memory is available to fetch because some meomory or prior blocks were released.
     *
     * \param capacity the size of requested block.
     * \param usage    the memory usage info for the requested block. Returned blocks will be
     *                 optimized for this usage, but may be used with any usage. One exception:
     *                 protected blocks/buffers can only be used in a protected scenario.
     * \param block    pointer to where the obtained block shall be stored on success. nullptr will
     *                 be stored here on failure
     * \param fence    pointer to where the fence shall be stored on C2_BLOCKING error.
     *
     * \retval C2_OK        the operation was successful
     * \retval C2_NO_MEMORY not enough memory to complete any required allocation
     * \retval C2_TIMED_OUT the operation timed out
     * \retval C2_BLOCKING  the operation is blocked
     * \retval C2_REFUSED   no permission to complete any required allocation
     * \retval C2_BAD_VALUE capacity or usage are not supported (invalid) (caller error)
     * \retval C2_OMITTED   this pool does not support linear blocks nor fence.
     * \retval C2_CORRUPTED some unknown, unrecoverable error occurred during operation
     *                      (unexpected)
     */
    virtual c2_status_t fetchLinearBlock(
            uint32_t capacity __unused, C2MemoryUsage usage __unused,
            std::shared_ptr<C2LinearBlock> *block /* nonnull */,
            C2Fence *fence /* nonnull */) {
        *block = nullptr;
        (void) fence;
        return C2_OMITTED;
    }

    /**
     * Blocking fetch for 2D graphic block. Obtains a 2D graphic writable block of given |capacity|
     * and |usage|. If a block can be successfully obtained, the block is stored in |block|,
     * |fence| is set to a null-fence and C2_OK is returned.
     *
     * If a block cannot be temporarily obtained, |block| is set to nullptr, a waitable fence
     * is stored into |fence| and C2_BLOCKING is returned.
     *
     * Otherwise, |block| is set to nullptr and |fence| is set to a null-fence. The waitable
     * fence is signalled when the temporary restriction on fetch is lifted.
     * e.g. more memory is available to fetch because some meomory or prior blocks were released.
     *
     * \param width  the width of requested block (the obtained block could be slightly larger, e.g.
     *               to accommodate any system-required alignment)
     * \param height the height of requested block (the obtained block could be slightly larger,
     *               e.g. to accommodate any system-required alignment)
     * \param format the pixel format of requested block. This could be a vendor specific format.
     * \param usage  the memory usage info for the requested block. Returned blocks will be
     *               optimized for this usage, but may be used with any usage. One exception:
     *               protected blocks/buffers can only be used in a protected scenario.
     * \param block  pointer to where the obtained block shall be stored on success. nullptr
     *               will be stored here on failure
     * \param fence  pointer to where the fence shall be stored on C2_BLOCKING error.
     *
     * \retval C2_OK        the operation was successful
     * \retval C2_NO_MEMORY not enough memory to complete any required allocation
     * \retval C2_TIMED_OUT the operation timed out
     * \retval C2_BLOCKING  the operation is blocked
     * \retval C2_REFUSED   no permission to complete any required allocation
     * \retval C2_BAD_VALUE width, height, format or usage are not supported (invalid) (caller
     *                      error)
     * \retval C2_OMITTED   this pool does not support 2D blocks
     * \retval C2_CORRUPTED some unknown, unrecoverable error occurred during operation
     *                      (unexpected)
     */
    virtual c2_status_t fetchGraphicBlock(
            uint32_t width __unused, uint32_t height __unused, uint32_t format __unused,
            C2MemoryUsage usage __unused,
            std::shared_ptr<C2GraphicBlock> *block /* nonnull */,
            C2Fence *fence /* nonnull */) {
        *block = nullptr;
        (void) fence;
        return C2_OMITTED;
    }
protected:
    C2BlockPool() = default;
};