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

Commit 02d3e8b2 authored by Trevor Knight's avatar Trevor Knight Committed by Gerrit Code Review
Browse files

Merge changes Ib1755a44,Ifd73b9b8 into main

* changes:
  Create C2Config profiles for IAMF
  Create the rest of the C2 boilerplate for IAMF decoder
parents af2a231f ff39b9f6
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -4,10 +4,15 @@ package {

cc_library {
    name: "libcodec2_soft_iamfdec",

    srcs: [],
    defaults: [
        "libcodec2_soft-defaults",
        "libcodec2_soft_sanitize_all-defaults",
    ],
    srcs: [
        "C2SoftIamfDec.cpp",
    ],

    shared_libs: [
        // iamf_tools library will need to go here.
        "iamf_tools",
    ],
}
+62 −5
Original line number Diff line number Diff line
@@ -17,6 +17,10 @@
#define LOG_TAG "C2SoftIamfDec"
#include <log/log.h>

#include <C2PlatformSupport.h>
#include <SimpleC2Interface.h>
#include "C2SoftIamfDec.h"

namespace android {

namespace {
@@ -35,13 +39,12 @@ class C2SoftIamfDec::IntfImpl : public SimpleInterface<void>::BaseParams {
        // Configure (e.g. noPrivateBuffers(), etc.)
        // Add parameters.
    }
}
};

C2SoftIamfDec::C2SoftIamfDec(const char* name, c2_node_id_t id,
                             const std::shared_ptr<IntfImpl>& intfImpl)
    : SimpleC2Component(std::make_shared<SimpleInterface<IntfImpl>>(name, id, intfImpl)),
      mIntf(intfImpl) {
}
      mIntf(intfImpl) {}

C2SoftIamfDec::~C2SoftIamfDec() {
    onRelease();
@@ -69,11 +72,65 @@ c2_status_t C2SoftIamfDec::onFlush_sm() {

void C2SoftIamfDec::process(const std::unique_ptr<C2Work>& work,
                            const std::shared_ptr<C2BlockPool>& pool) {
    return;
    (void)pool;  // Temporary solution to suppress unused var.
    work->result = C2_NO_INIT;
}

c2_status_t C2SoftIamfDec::drain(uint32_t drainMode, const std::shared_ptr<C2BlockPool>& pool) {
    return C2_NO_INIT;
    (void)pool;
    if (drainMode == NO_DRAIN) {
        ALOGW("drain with NO_DRAIN: no-op");
        return C2_OK;
    }
    if (drainMode == DRAIN_CHAIN) {
        ALOGW("DRAIN_CHAIN not supported");
        return C2_OMITTED;
    }

    return C2_OK;
}

class C2SoftIamfDecFactory : public C2ComponentFactory {
  public:
    C2SoftIamfDecFactory()
        : mHelper(std::static_pointer_cast<C2ReflectorHelper>(
                  GetCodec2PlatformComponentStore()->getParamReflector())) {}

    virtual c2_status_t createComponent(c2_node_id_t id,
                                        std::shared_ptr<C2Component>* const component,
                                        std::function<void(C2Component*)> deleter) override {
        *component = std::shared_ptr<C2Component>(
                new C2SoftIamfDec(COMPONENT_NAME, id,
                                  std::make_shared<C2SoftIamfDec::IntfImpl>(mHelper)),
                deleter);
        return C2_OK;
    }

    virtual c2_status_t createInterface(
            c2_node_id_t id, std::shared_ptr<C2ComponentInterface>* const interface,
            std::function<void(C2ComponentInterface*)> deleter) override {
        *interface = std::shared_ptr<C2ComponentInterface>(
                new SimpleInterface<C2SoftIamfDec::IntfImpl>(
                        COMPONENT_NAME, id, std::make_shared<C2SoftIamfDec::IntfImpl>(mHelper)),
                deleter);
        return C2_OK;
    }

    virtual ~C2SoftIamfDecFactory() override = default;

  private:
    std::shared_ptr<C2ReflectorHelper> mHelper;
};

}  // namespace android

__attribute__((cfi_canonical_jump_table)) extern "C" ::C2ComponentFactory* CreateCodec2Factory() {
    ALOGV("in %s", __func__);
    return new ::android::C2SoftIamfDecFactory();
}

__attribute__((cfi_canonical_jump_table)) extern "C" void DestroyCodec2Factory(
        ::C2ComponentFactory* factory) {
    ALOGV("in %s", __func__);
    delete factory;
}
+4 −2
Original line number Diff line number Diff line
@@ -22,10 +22,10 @@
namespace android {

class C2SoftIamfDec : public SimpleC2Component {
  public:
    // Forward declaration of the C2 interface implementation.
    class IntfImpl;

  public:
    C2SoftIamfDec(const char* name, c2_node_id_t id, const std::shared_ptr<IntfImpl>& intfImpl);
    virtual ~C2SoftIamfDec();

@@ -41,7 +41,9 @@ class C2SoftIamfDec : public SimpleC2Component {

  private:
    std::shared_ptr<IntfImpl> mIntf;
}

    C2_DO_NOT_COPY(C2SoftIamfDec);
};

}  // namespace android

+17 −3
Original line number Diff line number Diff line
@@ -29,8 +29,8 @@
 * Enumerated boolean.
 */
C2ENUM(c2_bool_t, uint32_t,
    C2_FALSE, ///< true
    C2_TRUE,  ///< false
    C2_FALSE, ///< false
    C2_TRUE,  ///< true
)

typedef C2SimpleValueStruct<c2_bool_t> C2BoolValue;
@@ -448,7 +448,7 @@ enum : uint32_t {
    _C2_PL_MPEGH_BASE = 0xB000,     // MPEG-H 3D Audio
    _C2_PL_APV_BASE = 0xC000,     // APV
    _C2_PL_AC4_BASE  = 0xD000,

    _C2_PL_IAMF_START = 0xE000,
    C2_PROFILE_LEVEL_VENDOR_START = 0x70000000,
};

@@ -634,6 +634,20 @@ enum C2Config::profile_t : uint32_t {
    PROFILE_AC4_1_1,                            ///< AC-4 Profile 01.01
    PROFILE_AC4_2_1,                            ///< AC-4 Profile 02.01
    PROFILE_AC4_2_2,                            ///< AC-4 Profile 02.02

    // IAMF Profiles
    PROFILE_IAMF_SIMPLE_AAC = _C2_PL_IAMF_START, ///< IAMF Simple Profile with AAC
    PROFILE_IAMF_SIMPLE_FLAC,                    ///< IAMF Simple Profile with FLAC
    PROFILE_IAMF_SIMPLE_OPUS,                    ///< IAMF Simple Profile with Opus
    PROFILE_IAMF_SIMPLE_PCM,                     ///< IAMF Simple Profile with PCM
    PROFILE_IAMF_BASE_AAC,                       ///< IAMF Base Profile with AAC
    PROFILE_IAMF_BASE_FLAC,                      ///< IAMF Base Profile with FLAC
    PROFILE_IAMF_BASE_OPUS,                      ///< IAMF Base Profile with Opus
    PROFILE_IAMF_BASE_PCM,                       ///< IAMF Base Profile with PCM
    PROFILE_IAMF_BASE_ENHANCED_AAC,              ///< IAMF Base Enhanced with AAC
    PROFILE_IAMF_BASE_ENHANCED_FLAC,             ///< IAMF Base Enhanced with FLAC
    PROFILE_IAMF_BASE_ENHANCED_OPUS,             ///< IAMF Base Enhanced with Opus
    PROFILE_IAMF_BASE_ENHANCED_PCM,              ///< IAMF Base Enhanced with PCM
};

enum C2Config::level_t : uint32_t {