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

Commit 6b0e0f02 authored by Lajos Molnar's avatar Lajos Molnar
Browse files

Codec2: pass block pools by ID

This highlighted a cfi bug so disabled cfi:

frameworks/av/media/libstagefright/codecs/avcdec/C2SoftAvcDec.cpp:1237:15: runtime error:
control flow integrity check for type 'android::C2BlockPool' failed during virtual call
(vtable address 0x0078b2f659c0)
0x0078b2f659c0: note: invalid vtable in module /system/lib64/libstagefright_soft_c2avcdec.so
 00 00 00 00  98 a8 ef b2 78 00 00 00  f0 df f3 b2 78 00 00 00  00 e0 f3 b2 78 00 00 00  00 e0 f3 b2
              ^

Bug: 64121714
Test: unittest
Change-Id: I25d9c9d603e78c5043568cfb951d26aacea798a4
parent bc928726
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -17,9 +17,9 @@ cc_library_shared {
            "unsigned-integer-overflow",
            "signed-integer-overflow",
        ],
        cfi: true,
        cfi: false, // true,
        diag: {
            cfi: true,
            cfi: false, // true,
        },
    },

+6 −2
Original line number Diff line number Diff line
@@ -61,13 +61,15 @@ enum C2ParamIndexKind : C2Param::ParamIndex {
    kParamIndexMime,
    kParamIndexStreamCount,
    kParamIndexFormat,
    kParamIndexBlockPools,

    kParamIndexMaxVideoSizeHint,
    kParamIndexVideoSizeTuning,

    // video info

    kParamIndexStructStart = 0x1,
    kParamIndexVideoSize,
    kParamIndexMaxVideoSizeHint,
    kParamIndexVideoSizeTuning,

    kParamIndexParamStart = 0x800,
};
@@ -125,6 +127,8 @@ C2ENUM(C2FormatKind, uint32_t,

typedef C2StreamParam<C2Tuning, C2Uint32Value, kParamIndexFormat> C2StreamFormatConfig;

typedef C2PortParam<C2Tuning, C2Uint64Array, kParamIndexBlockPools> C2PortBlockPoolsTuning;

/*
   Component description fields:

+32 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

#include <C2AllocatorGralloc.h>
#include <C2AllocatorIon.h>
#include <C2BufferPriv.h>
#include <C2Component.h>
#include <C2PlatformSupport.h>

@@ -109,4 +110,35 @@ std::shared_ptr<C2AllocatorStore> GetCodec2PlatformAllocatorStore() {
    return std::make_shared<C2PlatformAllocatorStore>();
}

C2Status GetCodec2BlockPool(
        C2BlockPool::local_id_t id, std::shared_ptr<const C2Component> component,
        std::shared_ptr<C2BlockPool> *pool) {
    pool->reset();
    if (!component) {
        return C2_BAD_VALUE;
    }
    // TODO support pre-registered block pools
    std::shared_ptr<C2AllocatorStore> allocatorStore = GetCodec2PlatformAllocatorStore();
    std::shared_ptr<C2Allocator> allocator;
    C2Status res = C2_NOT_FOUND;

    switch (id) {
    case C2BlockPool::BASIC_LINEAR:
        res = allocatorStore->getAllocator(C2AllocatorStore::DEFAULT_LINEAR, &allocator);
        if (res == OK) {
            *pool = std::make_shared<C2BasicLinearBlockPool>(allocator);
        }
        break;
    case C2BlockPool::BASIC_GRAPHIC:
        res = allocatorStore->getAllocator(C2AllocatorStore::DEFAULT_GRAPHIC, &allocator);
        if (res == OK) {
            *pool = std::make_shared<C2BasicGraphicBlockPool>(allocator);
        }
        break;
    default:
        break;
    }
    return res;
}

} // namespace android
 No newline at end of file
+24 −0
Original line number Diff line number Diff line
@@ -25,9 +25,33 @@ namespace android {

/**
 * Returns the platform allocator store.
 * \retval nullptr if the platform allocator store could not be obtained
 */
std::shared_ptr<C2AllocatorStore> GetCodec2PlatformAllocatorStore();

/**
 * Retrieves a block pool for a component.
 *
 * \param id        the local ID of the block pool
 * \param component the component using the block pool (must be non-null)
 * \param pool      pointer to where the obtained block pool shall be stored on success. nullptr
 *                  will be stored here on failure
 *
 * \retval C2_OK        the operation was successful
 * \retval C2_BAD_VALUE the component is null
 * \retval C2_NOT_FOUND if the block pool does not exist
 * \retval C2_NO_MEMORY not enough memory to fetch the block pool (this return value is only
 *                      possible for basic pools)
 * \retval C2_TIMED_OUT the operation timed out (this return value is only possible for basic pools)
 * \retval C2_REFUSED   no permission to complete any required allocation (this return value is only
 *                      possible for basic pools)
 * \retval C2_CORRUPTED some unknown, unrecoverable error occured during operation (unexpected,
 *                      this return value is only possible for basic pools)
 */
C2Status GetCodec2BlockPool(
        C2BlockPool::local_id_t id, std::shared_ptr<const C2Component> component,
        std::shared_ptr<C2BlockPool> *pool);

} // namespace android

#endif // STAGEFRIGHT_CODEC2_PLATFORM_SUPPORT_H_
+2 −2
Original line number Diff line number Diff line
@@ -74,9 +74,9 @@ cc_library_shared {
        misc_undefined: [
            "signed-integer-overflow",
        ],
        cfi: true,
        cfi: false, // true,
        diag: {
            cfi: true,
            cfi: false, // true,
        },
    },

Loading