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

Commit 9acd73d1 authored by Manisha Jajoo's avatar Manisha Jajoo Committed by Sungtak Lee
Browse files

codec2: Derive video encoder components from SimpleInterface

Test: run cts -m CtsMediaTestCases --test android.media.cts.VideoEncoderTest

Bug: 124962433

Change-Id: I2f0a7719c6d9f311b617f8e9054a2ae7dd1f27cc
parent ed134640
Loading
Loading
Loading
Loading
+24 −31
Original line number Diff line number Diff line
@@ -37,34 +37,27 @@

namespace android {

class C2SoftAvcEnc::IntfImpl : public C2InterfaceHelper {
public:
    explicit IntfImpl(const std::shared_ptr<C2ReflectorHelper> &helper)
        : C2InterfaceHelper(helper) {

        setDerivedInstance(this);

        addParameter(
                DefineParam(mInputFormat, C2_PARAMKEY_INPUT_STREAM_BUFFER_TYPE)
                .withConstValue(new C2StreamBufferTypeSetting::input(0u, C2BufferData::GRAPHIC))
                .build());
namespace {

        addParameter(
                DefineParam(mOutputFormat, C2_PARAMKEY_OUTPUT_STREAM_BUFFER_TYPE)
                .withConstValue(new C2StreamBufferTypeSetting::output(0u, C2BufferData::LINEAR))
                .build());
constexpr char COMPONENT_NAME[] = "c2.android.avc.encoder";

        addParameter(
                DefineParam(mInputMediaType, C2_PARAMKEY_INPUT_MEDIA_TYPE)
                .withConstValue(AllocSharedString<C2PortMediaTypeSetting::input>(
                        MEDIA_MIMETYPE_VIDEO_RAW))
                .build());
}  // namespace

        addParameter(
                DefineParam(mOutputMediaType, C2_PARAMKEY_OUTPUT_MEDIA_TYPE)
                .withConstValue(AllocSharedString<C2PortMediaTypeSetting::output>(
                        MEDIA_MIMETYPE_VIDEO_AVC))
                .build());
class C2SoftAvcEnc::IntfImpl : public SimpleInterface<void>::BaseParams {
public:
    explicit IntfImpl(const std::shared_ptr<C2ReflectorHelper> &helper)
        : SimpleInterface<void>::BaseParams(
                helper,
                COMPONENT_NAME,
                C2Component::KIND_ENCODER,
                C2Component::DOMAIN_VIDEO,
                MEDIA_MIMETYPE_VIDEO_AVC) {
        noPrivateBuffers(); // TODO: account for our buffers here
        noInputReferences();
        noOutputReferences();
        noInputLatency();
        noTimeStretch();
        setDerivedInstance(this);

        addParameter(
                DefineParam(mUsage, C2_PARAMKEY_INPUT_STREAM_USAGE)
@@ -72,6 +65,12 @@ public:
                        0u, (uint64_t)C2MemoryUsage::CPU_READ))
                .build());

        addParameter(
                DefineParam(mAttrib, C2_PARAMKEY_COMPONENT_ATTRIBUTES)
                .withConstValue(new C2ComponentAttributesSetting(
                    C2Component::ATTRIB_IS_TEMPORAL))
                .build());

        addParameter(
                DefineParam(mSize, C2_PARAMKEY_PICTURE_SIZE)
                .withDefault(new C2StreamPictureSizeInfo::input(0u, 320, 240))
@@ -325,10 +324,6 @@ public:
    std::shared_ptr<C2StreamRequestSyncFrameTuning::output> getRequestSync_l() const { return mRequestSync; }

private:
    std::shared_ptr<C2StreamBufferTypeSetting::input> mInputFormat;
    std::shared_ptr<C2StreamBufferTypeSetting::output> mOutputFormat;
    std::shared_ptr<C2PortMediaTypeSetting::input> mInputMediaType;
    std::shared_ptr<C2PortMediaTypeSetting::output> mOutputMediaType;
    std::shared_ptr<C2StreamUsageTuning::input> mUsage;
    std::shared_ptr<C2StreamPictureSizeInfo::input> mSize;
    std::shared_ptr<C2StreamFrameRateInfo::output> mFrameRate;
@@ -341,8 +336,6 @@ private:

#define ive_api_function  ih264e_api_function

constexpr char COMPONENT_NAME[] = "c2.android.avc.encoder";

namespace {

// From external/libavc/encoder/ih264e_bitstream.h
+25 −32
Original line number Diff line number Diff line
@@ -38,37 +38,36 @@

namespace android {

class C2SoftHevcEnc::IntfImpl : public C2InterfaceHelper {
namespace {

constexpr char COMPONENT_NAME[] = "c2.android.hevc.encoder";

} // namepsace

class C2SoftHevcEnc::IntfImpl : public SimpleInterface<void>::BaseParams {
  public:
    explicit IntfImpl(const std::shared_ptr<C2ReflectorHelper> &helper)
        : C2InterfaceHelper(helper) {
        : SimpleInterface<void>::BaseParams(
                helper,
                COMPONENT_NAME,
                C2Component::KIND_ENCODER,
                C2Component::DOMAIN_VIDEO,
                MEDIA_MIMETYPE_VIDEO_HEVC) {
        noPrivateBuffers(); // TODO: account for our buffers here
        noInputReferences();
        noOutputReferences();
        noInputLatency();
        noTimeStretch();
        setDerivedInstance(this);

        addParameter(
            DefineParam(mInputFormat, C2_PARAMKEY_INPUT_STREAM_BUFFER_TYPE)
                .withConstValue(
                    new C2StreamBufferTypeSetting::input(0u, C2BufferData::GRAPHIC))
                .build());

        addParameter(
            DefineParam(mOutputFormat, C2_PARAMKEY_OUTPUT_STREAM_BUFFER_TYPE)
                .withConstValue(
                    new C2StreamBufferTypeSetting::output(0u, C2BufferData::LINEAR))
                DefineParam(mAttrib, C2_PARAMKEY_COMPONENT_ATTRIBUTES)
                .withConstValue(new C2ComponentAttributesSetting(
                    C2Component::ATTRIB_IS_TEMPORAL))
                .build());

        addParameter(
            DefineParam(mInputMediaType, C2_PARAMKEY_INPUT_MEDIA_TYPE)
                .withConstValue(AllocSharedString<C2PortMediaTypeSetting::input>(
                    MEDIA_MIMETYPE_VIDEO_RAW))
                .build());

        addParameter(
            DefineParam(mOutputMediaType, C2_PARAMKEY_OUTPUT_MEDIA_TYPE)
                .withConstValue(AllocSharedString<C2PortMediaTypeSetting::output>(
                    MEDIA_MIMETYPE_VIDEO_HEVC))
                .build());

        addParameter(DefineParam(mUsage, C2_PARAMKEY_INPUT_STREAM_USAGE)
                DefineParam(mUsage, C2_PARAMKEY_INPUT_STREAM_USAGE)
                .withConstValue(new C2StreamUsageTuning::input(
                        0u, (uint64_t)C2MemoryUsage::CPU_READ))
                .build());
@@ -332,10 +331,6 @@ class C2SoftHevcEnc::IntfImpl : public C2InterfaceHelper {
    }

   private:
    std::shared_ptr<C2StreamBufferTypeSetting::input> mInputFormat;
    std::shared_ptr<C2StreamBufferTypeSetting::output> mOutputFormat;
    std::shared_ptr<C2PortMediaTypeSetting::input> mInputMediaType;
    std::shared_ptr<C2PortMediaTypeSetting::output> mOutputMediaType;
    std::shared_ptr<C2StreamUsageTuning::input> mUsage;
    std::shared_ptr<C2StreamPictureSizeInfo::input> mSize;
    std::shared_ptr<C2StreamFrameRateInfo::output> mFrameRate;
@@ -348,8 +343,6 @@ class C2SoftHevcEnc::IntfImpl : public C2InterfaceHelper {
    std::shared_ptr<C2StreamSyncFrameIntervalTuning::output> mSyncFramePeriod;
};

constexpr char COMPONENT_NAME[] = "c2.android.hevc.encoder";

static size_t GetCPUCoreCount() {
    long cpuCoreCount = 0;

+25 −35
Original line number Diff line number Diff line
@@ -39,48 +39,42 @@

namespace android {

namespace {

#ifdef MPEG4
constexpr char COMPONENT_NAME[] = "c2.android.mpeg4.encoder";
const char *MEDIA_MIMETYPE_VIDEO = MEDIA_MIMETYPE_VIDEO_MPEG4;
#else
constexpr char COMPONENT_NAME[] = "c2.android.h263.encoder";
const char *MEDIA_MIMETYPE_VIDEO = MEDIA_MIMETYPE_VIDEO_H263;
#endif

class C2SoftMpeg4Enc::IntfImpl : public C2InterfaceHelper {
} // namepsace

class C2SoftMpeg4Enc::IntfImpl : public SimpleInterface<void>::BaseParams {
   public:
    explicit IntfImpl(const std::shared_ptr<C2ReflectorHelper> &helper)
        : C2InterfaceHelper(helper) {
        : SimpleInterface<void>::BaseParams(
                helper,
                COMPONENT_NAME,
                C2Component::KIND_ENCODER,
                C2Component::DOMAIN_VIDEO,
                MEDIA_MIMETYPE_VIDEO) {
        noPrivateBuffers(); // TODO: account for our buffers here
        noInputReferences();
        noOutputReferences();
        noInputLatency();
        noTimeStretch();
        setDerivedInstance(this);

        addParameter(
            DefineParam(mInputFormat, C2_PARAMKEY_INPUT_STREAM_BUFFER_TYPE)
                .withConstValue(
                    new C2StreamBufferTypeSetting::input(0u, C2BufferData::GRAPHIC))
                DefineParam(mAttrib, C2_PARAMKEY_COMPONENT_ATTRIBUTES)
                .withConstValue(new C2ComponentAttributesSetting(
                    C2Component::ATTRIB_IS_TEMPORAL))
                .build());

        addParameter(
            DefineParam(mOutputFormat, C2_PARAMKEY_OUTPUT_STREAM_BUFFER_TYPE)
                .withConstValue(
                    new C2StreamBufferTypeSetting::output(0u, C2BufferData::LINEAR))
                .build());

        addParameter(
            DefineParam(mInputMediaType, C2_PARAMKEY_INPUT_MEDIA_TYPE)
                .withConstValue(AllocSharedString<C2PortMediaTypeSetting::input>(
                    MEDIA_MIMETYPE_VIDEO_RAW))
                .build());

        addParameter(
            DefineParam(mOutputMediaType, C2_PARAMKEY_OUTPUT_MEDIA_TYPE)
                .withConstValue(AllocSharedString<C2PortMediaTypeSetting::output>(
#ifdef MPEG4
                    MEDIA_MIMETYPE_VIDEO_MPEG4
#else
                    MEDIA_MIMETYPE_VIDEO_H263
#endif
                    ))
                .build());

        addParameter(DefineParam(mUsage, C2_PARAMKEY_INPUT_STREAM_USAGE)
                DefineParam(mUsage, C2_PARAMKEY_INPUT_STREAM_USAGE)
                .withConstValue(new C2StreamUsageTuning::input(
                        0u, (uint64_t)C2MemoryUsage::CPU_READ))
                .build());
@@ -217,10 +211,6 @@ class C2SoftMpeg4Enc::IntfImpl : public C2InterfaceHelper {
    }

   private:
    std::shared_ptr<C2StreamBufferTypeSetting::input> mInputFormat;
    std::shared_ptr<C2StreamBufferTypeSetting::output> mOutputFormat;
    std::shared_ptr<C2PortMediaTypeSetting::input> mInputMediaType;
    std::shared_ptr<C2PortMediaTypeSetting::output> mOutputMediaType;
    std::shared_ptr<C2StreamUsageTuning::input> mUsage;
    std::shared_ptr<C2StreamPictureSizeInfo::input> mSize;
    std::shared_ptr<C2StreamFrameRateInfo::output> mFrameRate;
+0 −2
Original line number Diff line number Diff line
@@ -23,8 +23,6 @@

namespace android {

constexpr char COMPONENT_NAME[] = "c2.android.vp8.encoder";

C2SoftVp8Enc::C2SoftVp8Enc(const char* name, c2_node_id_t id,
                           const std::shared_ptr<IntfImpl>& intfImpl)
    : C2SoftVpxEnc(name, id, intfImpl), mDCTPartitions(0), mProfile(1) {}
+0 −2
Original line number Diff line number Diff line
@@ -23,8 +23,6 @@

namespace android {

constexpr char COMPONENT_NAME[] = "c2.android.vp9.encoder";

C2SoftVp9Enc::C2SoftVp9Enc(const char* name, c2_node_id_t id,
                           const std::shared_ptr<IntfImpl>& intfImpl)
    : C2SoftVpxEnc(name, id, intfImpl),
Loading