Loading media/libstagefright/codec2/1.0/InputSurfaceConnection.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ #include <C2BlockInternal.h> #include <C2PlatformSupport.h> #include <gui/Surface.h> #include <media/stagefright/codec2/1.0/InputSurfaceConnection.h> #include <system/window.h> Loading media/libstagefright/codec2/C2.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ #include <C2ParamDef.h> #include <C2Work.h> namespace android { /** * There is nothing here yet. This library is built to see what symbols and methods get * defined as part of the API include files. Loading @@ -30,4 +32,5 @@ * Codec2 clients. */ } // namespace android media/libstagefright/codec2/include/C2.h +78 −35 Original line number Diff line number Diff line Loading @@ -17,18 +17,40 @@ #ifndef C2_H_ #define C2_H_ #include <errno.h> #include <string> #include <vector> #include <list> #ifdef __ANDROID__ #include <utils/Errors.h> // for status_t #include <utils/Timers.h> // for nsecs_t /** nanoseconds with arbitrary origin. */ typedef int64_t c2_nsecs_t; namespace android { #else #include <errno.h> typedef int64_t nsecs_t; enum { GRALLOC_USAGE_SW_READ_OFTEN, GRALLOC_USAGE_RENDERSCRIPT, GRALLOC_USAGE_HW_TEXTURE, GRALLOC_USAGE_HW_COMPOSER, GRALLOC_USAGE_HW_VIDEO_ENCODER, GRALLOC_USAGE_PROTECTED, GRALLOC_USAGE_SW_WRITE_OFTEN, GRALLOC_USAGE_HW_RENDER, }; #endif /** \mainpage Codec2 * * Codec2 is a generic frame-based data processing API. * Codec2 is a frame-based data processing API used by android. * * The media subsystem accesses components via the \ref API. * The framework accesses components via the \ref API. */ /** \ingroup API Loading Loading @@ -87,35 +109,53 @@ typedef const char *C2StringLiteral; * c2_status_t: status codes used. */ enum c2_status_t : int32_t { /* * Use POSIX errno constants. * Use android status constants if available. Otherwise, define the android status constants as * additional enum values using POSIX errno constants. */ C2_OK = 0, ///< operation completed successfully #ifndef __ANDROID__ ALREADY_EXISTS = -EEXIST, BAD_VALUE = -EINVAL, BAD_INDEX = -EOVERFLOW, FAILED_TRANSACTION = -ENOTSUP, INVALID_OPERATION = -ENOSYS, NAME_NOT_FOUND = -ENOENT, NO_MEMORY = -ENOMEM, NO_INIT = -ENODEV, OK = 0, PERMISSION_DENIED = -EPERM, TIMED_OUT = -ETIMEDOUT, UNKNOWN_ERROR = -EFAULT, UNKNOWN_TRANSACTION = -EBADMSG, WOULD_BLOCK = -EWOULDBLOCK, #endif C2_OK = OK, ///< operation completed successfully // bad input C2_BAD_VALUE = EINVAL, ///< argument has invalid value (user error) C2_BAD_INDEX = ENXIO, ///< argument uses invalid index (user error) C2_CANNOT_DO = ENOTSUP, ///< argument/index is valid but not possible C2_BAD_VALUE = BAD_VALUE, ///< argument has invalid value (user error) C2_BAD_INDEX = BAD_INDEX, ///< argument uses invalid index (user error) C2_CANNOT_DO = FAILED_TRANSACTION, ///< argument/index is valid but not possible // bad sequencing of events C2_DUPLICATE = EEXIST, ///< object already exists C2_NOT_FOUND = ENOENT, ///< object not found C2_BAD_STATE = EPERM, ///< operation is not permitted in the current state C2_BLOCKING = EWOULDBLOCK, ///< operation would block but blocking is not permitted C2_CANCELED = EINTR, ///< operation interrupted/canceled C2_DUPLICATE = ALREADY_EXISTS, ///< object already exists C2_NOT_FOUND = NAME_NOT_FOUND, ///< object not found C2_BAD_STATE = INVALID_OPERATION, ///< operation is not permitted in the current state C2_BLOCKING = WOULD_BLOCK, ///< operation would block but blocking is not permitted // bad environment C2_NO_MEMORY = ENOMEM, ///< not enough memory to complete operation C2_REFUSED = EACCES, ///< missing permission to complete operation C2_NO_MEMORY = NO_MEMORY, ///< not enough memory to complete operation C2_REFUSED = PERMISSION_DENIED, ///< missing permission to complete operation C2_TIMED_OUT = ETIMEDOUT, ///< operation did not complete within timeout C2_TIMED_OUT = TIMED_OUT, ///< operation did not complete within timeout // bad versioning C2_OMITTED = ENOSYS, ///< operation is not implemented/supported (optional only) C2_OMITTED = UNKNOWN_TRANSACTION, ///< operation is not implemented/supported (optional only) // unknown fatal C2_CORRUPTED = EFAULT, ///< some unexpected error prevented the operation C2_NO_INIT = ENODEV, ///< status has not been initialized C2_CORRUPTED = UNKNOWN_ERROR, ///< some unexpected error prevented the operation C2_NO_INIT = NO_INIT, ///< status has not been initialized }; /** Loading Loading @@ -145,12 +185,11 @@ enum c2_blocking_t : int32_t { type args& operator=(const type args&) = delete; \ type(const type args&) = delete; \ #define C2_ALLOW_OVERFLOW __attribute__((no_sanitize("integer"))) #define C2_PURE __attribute__((pure)) #define C2_CONST __attribute__((const)) #define C2_HIDE __attribute__((visibility("hidden"))) #define C2_INTERNAL __attribute__((internal_linkage)) #define C2_PACK __attribute__((packed)) #define C2_PURE __attribute__((pure)) #define C2_ALLOW_OVERFLOW __attribute__((no_sanitize("integer"))) #define DEFINE_OTHER_COMPARISON_OPERATORS(type) \ inline bool operator!=(const type &other) const { return !(*this == other); } \ Loading Loading @@ -509,28 +548,32 @@ inline constexpr typename c2_types<T, V>::wide_type c2_clamp(const T a, const U /// @} #ifdef __ANDROID__ } // namespace android #endif #include <functional> template<typename T> struct std::less<::c2_cntr_t<T>> { constexpr bool operator()(const ::c2_cntr_t<T> &lh, const ::c2_cntr_t<T> &rh) const { struct std::less<::android::c2_cntr_t<T>> { constexpr bool operator()(const ::android::c2_cntr_t<T> &lh, const ::android::c2_cntr_t<T> &rh) const { return lh.peeku() < rh.peeku(); } }; template<typename T> struct std::less_equal<::c2_cntr_t<T>> { constexpr bool operator()(const ::c2_cntr_t<T> &lh, const ::c2_cntr_t<T> &rh) const { struct std::less_equal<::android::c2_cntr_t<T>> { constexpr bool operator()(const ::android::c2_cntr_t<T> &lh, const ::android::c2_cntr_t<T> &rh) const { return lh.peeku() <= rh.peeku(); } }; template<typename T> struct std::greater<::c2_cntr_t<T>> { constexpr bool operator()(const ::c2_cntr_t<T> &lh, const ::c2_cntr_t<T> &rh) const { struct std::greater<::android::c2_cntr_t<T>> { constexpr bool operator()(const ::android::c2_cntr_t<T> &lh, const ::android::c2_cntr_t<T> &rh) const { return lh.peeku() > rh.peeku(); } }; template<typename T> struct std::greater_equal<::c2_cntr_t<T>> { constexpr bool operator()(const ::c2_cntr_t<T> &lh, const ::c2_cntr_t<T> &rh) const { struct std::greater_equal<::android::c2_cntr_t<T>> { constexpr bool operator()(const ::android::c2_cntr_t<T> &lh, const ::android::c2_cntr_t<T> &rh) const { return lh.peeku() >= rh.peeku(); } }; Loading media/libstagefright/codec2/include/C2Buffer.h +45 −10 Original line number Diff line number Diff line Loading @@ -18,20 +18,27 @@ #define C2BUFFER_H_ #include <C2.h> #include <C2BufferBase.h> #include <C2Param.h> // for C2Info #include <list> #include <memory> #include <vector> #ifdef __ANDROID__ #include <android-C2Buffer.h> // #include <system/window.h> #include <cutils/native_handle.h> #include <hardware/gralloc.h> // TODO: remove typedef native_handle_t C2Handle; #else typedef void* C2Handle; #endif namespace android { /// \defgroup buffer Buffers /// @{ Loading Loading @@ -82,7 +89,7 @@ public: * \retval C2_REFUSED no permission to wait for the fence (unexpected - system) * \retval C2_CORRUPTED some unknown error prevented waiting for the fence (unexpected) */ c2_status_t wait(c2_nsecs_t timeoutNs); c2_status_t wait(nsecs_t timeoutNs); /** * Used to check if this fence is valid (if there is a chance for it to be signaled.) Loading Loading @@ -543,9 +550,41 @@ public: ALLOCATIONS **************************************************************************************************/ /// \ingroup allocator Allocation and memory placement /// \defgroup allocator Allocation and memory placement /// @{ /** * Buffer/memory usage bits. These are used by the allocators to select optimal memory type/pool and * buffer layout. * * \note This struct has public fields without getters/setters. All methods are inline. */ struct C2MemoryUsage { // public: // TODO: match these to gralloc1.h enum Consumer : uint64_t { // \todo do we need to distinguish often from rarely? CPU_READ = GRALLOC_USAGE_SW_READ_OFTEN, RENDERSCRIPT_READ = GRALLOC_USAGE_RENDERSCRIPT, HW_TEXTURE_READ = GRALLOC_USAGE_HW_TEXTURE, HW_COMPOSER_READ = GRALLOC_USAGE_HW_COMPOSER, HW_CODEC_READ = GRALLOC_USAGE_HW_VIDEO_ENCODER, READ_PROTECTED = GRALLOC_USAGE_PROTECTED, }; enum Producer : uint64_t { CPU_WRITE = GRALLOC_USAGE_SW_WRITE_OFTEN, RENDERSCRIPT_WRITE = GRALLOC_USAGE_RENDERSCRIPT, HW_TEXTURE_WRITE = GRALLOC_USAGE_HW_RENDER, HW_COMPOSER_WRITE = GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_HW_RENDER, HW_CODEC_WRITE = GRALLOC_USAGE_HW_VIDEO_ENCODER, WRITE_PROTECTED = GRALLOC_USAGE_PROTECTED, }; uint64_t consumer; // e.g. input uint64_t producer; // e.g. output }; class C2LinearAllocation; class C2GraphicAllocation; Loading Loading @@ -2262,10 +2301,6 @@ protected: /// @} // expose some objects in android namespace namespace android { /// \deprecated typedef ::C2Fence C2Fence; } } // namespace android #endif // C2BUFFER_H_ media/libstagefright/codec2/include/C2BufferBase.hdeleted 100644 → 0 +0 −94 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef C2BUFFER_BASE_H_ #define C2BUFFER_BASE_H_ /// \defgroup allocator Allocation and memory placement /// @{ /** * Buffer/memory usage bits. These shall be used by the allocators to select optimal memory type/ * pool and buffer layout. Usage bits are conceptually separated into read and write usage, while * the buffer use life-cycle is separated into producers (writers) and consumers (readers). * These two concepts are related but not equivalent: consumers may only read buffers and only * producers may write to buffers; note, however, that buffer producers may also want or need to * read the buffers. * * Read and write buffer usage bits shall be or-ed to arrive at the full buffer usage. Admittedly, * this does not account for the amount of reading and writing (e.g. a buffer may have one or more * readers); however, the proper information necessary to properly weigh the various usages would be * the amount of data read/written for each usage type. This would result in an integer array of * size 64 (or the number of distinct usages) for memory usage, and likely such detailed information * would not always be available. * * That platform-agnostic Codec 2.0 API only defines the bare minimum usages. Platforms shall define * usage bits that are appropriate for the platform. */ struct C2MemoryUsage { // public: /** * Buffer read usage. */ enum Read : uint64_t { /** Buffer is read by the CPU. */ CPU_READ = 1 << 0, /** * Buffer shall only be read by trusted hardware. The definition of trusted hardware is * platform specific, but this flag is reserved to prevent mapping this block into CPU * readable memory resulting in bus fault. This flag can be used when buffer access must be * protected. */ READ_PROTECTED = 1 << 1, }; /** * Buffer write usage. */ enum Write : uint64_t { /** Buffer is writted to by the CPU. */ CPU_WRITE = 1 << 2, /** * Buffer shall only be written to by trusted hardware. The definition of trusted hardware * is platform specific, but this flag is reserved to prevent mapping this block into CPU * writable memory resulting in bus fault. This flag can be used when buffer integrity must * be protected. */ WRITE_PROTECTED = 1 << 3, }; enum : uint64_t { /** * Buffer usage bits reserved for the platform. We don't separately reserve read and * write usages as platforms may have asymmetric distribution between them. */ PLATFORM_MASK = ~(CPU_READ | CPU_WRITE | READ_PROTECTED | WRITE_PROTECTED), }; /** Create a usage from separate consumer and producer usage mask. \deprecated */ inline C2MemoryUsage(uint64_t consumer, uint64_t producer) : expected(consumer | producer) { } inline explicit C2MemoryUsage(uint64_t expected_) : expected(expected_) { } uint64_t expected; // expected buffer usage }; /// @} #endif // C2BUFFER_BASE_H_ Loading
media/libstagefright/codec2/1.0/InputSurfaceConnection.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ #include <C2BlockInternal.h> #include <C2PlatformSupport.h> #include <gui/Surface.h> #include <media/stagefright/codec2/1.0/InputSurfaceConnection.h> #include <system/window.h> Loading
media/libstagefright/codec2/C2.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ #include <C2ParamDef.h> #include <C2Work.h> namespace android { /** * There is nothing here yet. This library is built to see what symbols and methods get * defined as part of the API include files. Loading @@ -30,4 +32,5 @@ * Codec2 clients. */ } // namespace android
media/libstagefright/codec2/include/C2.h +78 −35 Original line number Diff line number Diff line Loading @@ -17,18 +17,40 @@ #ifndef C2_H_ #define C2_H_ #include <errno.h> #include <string> #include <vector> #include <list> #ifdef __ANDROID__ #include <utils/Errors.h> // for status_t #include <utils/Timers.h> // for nsecs_t /** nanoseconds with arbitrary origin. */ typedef int64_t c2_nsecs_t; namespace android { #else #include <errno.h> typedef int64_t nsecs_t; enum { GRALLOC_USAGE_SW_READ_OFTEN, GRALLOC_USAGE_RENDERSCRIPT, GRALLOC_USAGE_HW_TEXTURE, GRALLOC_USAGE_HW_COMPOSER, GRALLOC_USAGE_HW_VIDEO_ENCODER, GRALLOC_USAGE_PROTECTED, GRALLOC_USAGE_SW_WRITE_OFTEN, GRALLOC_USAGE_HW_RENDER, }; #endif /** \mainpage Codec2 * * Codec2 is a generic frame-based data processing API. * Codec2 is a frame-based data processing API used by android. * * The media subsystem accesses components via the \ref API. * The framework accesses components via the \ref API. */ /** \ingroup API Loading Loading @@ -87,35 +109,53 @@ typedef const char *C2StringLiteral; * c2_status_t: status codes used. */ enum c2_status_t : int32_t { /* * Use POSIX errno constants. * Use android status constants if available. Otherwise, define the android status constants as * additional enum values using POSIX errno constants. */ C2_OK = 0, ///< operation completed successfully #ifndef __ANDROID__ ALREADY_EXISTS = -EEXIST, BAD_VALUE = -EINVAL, BAD_INDEX = -EOVERFLOW, FAILED_TRANSACTION = -ENOTSUP, INVALID_OPERATION = -ENOSYS, NAME_NOT_FOUND = -ENOENT, NO_MEMORY = -ENOMEM, NO_INIT = -ENODEV, OK = 0, PERMISSION_DENIED = -EPERM, TIMED_OUT = -ETIMEDOUT, UNKNOWN_ERROR = -EFAULT, UNKNOWN_TRANSACTION = -EBADMSG, WOULD_BLOCK = -EWOULDBLOCK, #endif C2_OK = OK, ///< operation completed successfully // bad input C2_BAD_VALUE = EINVAL, ///< argument has invalid value (user error) C2_BAD_INDEX = ENXIO, ///< argument uses invalid index (user error) C2_CANNOT_DO = ENOTSUP, ///< argument/index is valid but not possible C2_BAD_VALUE = BAD_VALUE, ///< argument has invalid value (user error) C2_BAD_INDEX = BAD_INDEX, ///< argument uses invalid index (user error) C2_CANNOT_DO = FAILED_TRANSACTION, ///< argument/index is valid but not possible // bad sequencing of events C2_DUPLICATE = EEXIST, ///< object already exists C2_NOT_FOUND = ENOENT, ///< object not found C2_BAD_STATE = EPERM, ///< operation is not permitted in the current state C2_BLOCKING = EWOULDBLOCK, ///< operation would block but blocking is not permitted C2_CANCELED = EINTR, ///< operation interrupted/canceled C2_DUPLICATE = ALREADY_EXISTS, ///< object already exists C2_NOT_FOUND = NAME_NOT_FOUND, ///< object not found C2_BAD_STATE = INVALID_OPERATION, ///< operation is not permitted in the current state C2_BLOCKING = WOULD_BLOCK, ///< operation would block but blocking is not permitted // bad environment C2_NO_MEMORY = ENOMEM, ///< not enough memory to complete operation C2_REFUSED = EACCES, ///< missing permission to complete operation C2_NO_MEMORY = NO_MEMORY, ///< not enough memory to complete operation C2_REFUSED = PERMISSION_DENIED, ///< missing permission to complete operation C2_TIMED_OUT = ETIMEDOUT, ///< operation did not complete within timeout C2_TIMED_OUT = TIMED_OUT, ///< operation did not complete within timeout // bad versioning C2_OMITTED = ENOSYS, ///< operation is not implemented/supported (optional only) C2_OMITTED = UNKNOWN_TRANSACTION, ///< operation is not implemented/supported (optional only) // unknown fatal C2_CORRUPTED = EFAULT, ///< some unexpected error prevented the operation C2_NO_INIT = ENODEV, ///< status has not been initialized C2_CORRUPTED = UNKNOWN_ERROR, ///< some unexpected error prevented the operation C2_NO_INIT = NO_INIT, ///< status has not been initialized }; /** Loading Loading @@ -145,12 +185,11 @@ enum c2_blocking_t : int32_t { type args& operator=(const type args&) = delete; \ type(const type args&) = delete; \ #define C2_ALLOW_OVERFLOW __attribute__((no_sanitize("integer"))) #define C2_PURE __attribute__((pure)) #define C2_CONST __attribute__((const)) #define C2_HIDE __attribute__((visibility("hidden"))) #define C2_INTERNAL __attribute__((internal_linkage)) #define C2_PACK __attribute__((packed)) #define C2_PURE __attribute__((pure)) #define C2_ALLOW_OVERFLOW __attribute__((no_sanitize("integer"))) #define DEFINE_OTHER_COMPARISON_OPERATORS(type) \ inline bool operator!=(const type &other) const { return !(*this == other); } \ Loading Loading @@ -509,28 +548,32 @@ inline constexpr typename c2_types<T, V>::wide_type c2_clamp(const T a, const U /// @} #ifdef __ANDROID__ } // namespace android #endif #include <functional> template<typename T> struct std::less<::c2_cntr_t<T>> { constexpr bool operator()(const ::c2_cntr_t<T> &lh, const ::c2_cntr_t<T> &rh) const { struct std::less<::android::c2_cntr_t<T>> { constexpr bool operator()(const ::android::c2_cntr_t<T> &lh, const ::android::c2_cntr_t<T> &rh) const { return lh.peeku() < rh.peeku(); } }; template<typename T> struct std::less_equal<::c2_cntr_t<T>> { constexpr bool operator()(const ::c2_cntr_t<T> &lh, const ::c2_cntr_t<T> &rh) const { struct std::less_equal<::android::c2_cntr_t<T>> { constexpr bool operator()(const ::android::c2_cntr_t<T> &lh, const ::android::c2_cntr_t<T> &rh) const { return lh.peeku() <= rh.peeku(); } }; template<typename T> struct std::greater<::c2_cntr_t<T>> { constexpr bool operator()(const ::c2_cntr_t<T> &lh, const ::c2_cntr_t<T> &rh) const { struct std::greater<::android::c2_cntr_t<T>> { constexpr bool operator()(const ::android::c2_cntr_t<T> &lh, const ::android::c2_cntr_t<T> &rh) const { return lh.peeku() > rh.peeku(); } }; template<typename T> struct std::greater_equal<::c2_cntr_t<T>> { constexpr bool operator()(const ::c2_cntr_t<T> &lh, const ::c2_cntr_t<T> &rh) const { struct std::greater_equal<::android::c2_cntr_t<T>> { constexpr bool operator()(const ::android::c2_cntr_t<T> &lh, const ::android::c2_cntr_t<T> &rh) const { return lh.peeku() >= rh.peeku(); } }; Loading
media/libstagefright/codec2/include/C2Buffer.h +45 −10 Original line number Diff line number Diff line Loading @@ -18,20 +18,27 @@ #define C2BUFFER_H_ #include <C2.h> #include <C2BufferBase.h> #include <C2Param.h> // for C2Info #include <list> #include <memory> #include <vector> #ifdef __ANDROID__ #include <android-C2Buffer.h> // #include <system/window.h> #include <cutils/native_handle.h> #include <hardware/gralloc.h> // TODO: remove typedef native_handle_t C2Handle; #else typedef void* C2Handle; #endif namespace android { /// \defgroup buffer Buffers /// @{ Loading Loading @@ -82,7 +89,7 @@ public: * \retval C2_REFUSED no permission to wait for the fence (unexpected - system) * \retval C2_CORRUPTED some unknown error prevented waiting for the fence (unexpected) */ c2_status_t wait(c2_nsecs_t timeoutNs); c2_status_t wait(nsecs_t timeoutNs); /** * Used to check if this fence is valid (if there is a chance for it to be signaled.) Loading Loading @@ -543,9 +550,41 @@ public: ALLOCATIONS **************************************************************************************************/ /// \ingroup allocator Allocation and memory placement /// \defgroup allocator Allocation and memory placement /// @{ /** * Buffer/memory usage bits. These are used by the allocators to select optimal memory type/pool and * buffer layout. * * \note This struct has public fields without getters/setters. All methods are inline. */ struct C2MemoryUsage { // public: // TODO: match these to gralloc1.h enum Consumer : uint64_t { // \todo do we need to distinguish often from rarely? CPU_READ = GRALLOC_USAGE_SW_READ_OFTEN, RENDERSCRIPT_READ = GRALLOC_USAGE_RENDERSCRIPT, HW_TEXTURE_READ = GRALLOC_USAGE_HW_TEXTURE, HW_COMPOSER_READ = GRALLOC_USAGE_HW_COMPOSER, HW_CODEC_READ = GRALLOC_USAGE_HW_VIDEO_ENCODER, READ_PROTECTED = GRALLOC_USAGE_PROTECTED, }; enum Producer : uint64_t { CPU_WRITE = GRALLOC_USAGE_SW_WRITE_OFTEN, RENDERSCRIPT_WRITE = GRALLOC_USAGE_RENDERSCRIPT, HW_TEXTURE_WRITE = GRALLOC_USAGE_HW_RENDER, HW_COMPOSER_WRITE = GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_HW_RENDER, HW_CODEC_WRITE = GRALLOC_USAGE_HW_VIDEO_ENCODER, WRITE_PROTECTED = GRALLOC_USAGE_PROTECTED, }; uint64_t consumer; // e.g. input uint64_t producer; // e.g. output }; class C2LinearAllocation; class C2GraphicAllocation; Loading Loading @@ -2262,10 +2301,6 @@ protected: /// @} // expose some objects in android namespace namespace android { /// \deprecated typedef ::C2Fence C2Fence; } } // namespace android #endif // C2BUFFER_H_
media/libstagefright/codec2/include/C2BufferBase.hdeleted 100644 → 0 +0 −94 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef C2BUFFER_BASE_H_ #define C2BUFFER_BASE_H_ /// \defgroup allocator Allocation and memory placement /// @{ /** * Buffer/memory usage bits. These shall be used by the allocators to select optimal memory type/ * pool and buffer layout. Usage bits are conceptually separated into read and write usage, while * the buffer use life-cycle is separated into producers (writers) and consumers (readers). * These two concepts are related but not equivalent: consumers may only read buffers and only * producers may write to buffers; note, however, that buffer producers may also want or need to * read the buffers. * * Read and write buffer usage bits shall be or-ed to arrive at the full buffer usage. Admittedly, * this does not account for the amount of reading and writing (e.g. a buffer may have one or more * readers); however, the proper information necessary to properly weigh the various usages would be * the amount of data read/written for each usage type. This would result in an integer array of * size 64 (or the number of distinct usages) for memory usage, and likely such detailed information * would not always be available. * * That platform-agnostic Codec 2.0 API only defines the bare minimum usages. Platforms shall define * usage bits that are appropriate for the platform. */ struct C2MemoryUsage { // public: /** * Buffer read usage. */ enum Read : uint64_t { /** Buffer is read by the CPU. */ CPU_READ = 1 << 0, /** * Buffer shall only be read by trusted hardware. The definition of trusted hardware is * platform specific, but this flag is reserved to prevent mapping this block into CPU * readable memory resulting in bus fault. This flag can be used when buffer access must be * protected. */ READ_PROTECTED = 1 << 1, }; /** * Buffer write usage. */ enum Write : uint64_t { /** Buffer is writted to by the CPU. */ CPU_WRITE = 1 << 2, /** * Buffer shall only be written to by trusted hardware. The definition of trusted hardware * is platform specific, but this flag is reserved to prevent mapping this block into CPU * writable memory resulting in bus fault. This flag can be used when buffer integrity must * be protected. */ WRITE_PROTECTED = 1 << 3, }; enum : uint64_t { /** * Buffer usage bits reserved for the platform. We don't separately reserve read and * write usages as platforms may have asymmetric distribution between them. */ PLATFORM_MASK = ~(CPU_READ | CPU_WRITE | READ_PROTECTED | WRITE_PROTECTED), }; /** Create a usage from separate consumer and producer usage mask. \deprecated */ inline C2MemoryUsage(uint64_t consumer, uint64_t producer) : expected(consumer | producer) { } inline explicit C2MemoryUsage(uint64_t expected_) : expected(expected_) { } uint64_t expected; // expected buffer usage }; /// @} #endif // C2BUFFER_BASE_H_