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

Commit 00a570bd authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "C2SoftMpeg2Dec : Enable KEEP_THREADS_ACTIVE" into main

parents da2992fb 67e08fbb
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -12,3 +12,12 @@ flag {
  description: "Feature flag for APV Software C2 codec"
  bug: "376770121"
}

flag {
  name: "mpeg2_keep_threads_active"
  is_exported: true
  is_fixed_read_only: true
  namespace: "codec_fwk"
  description: "Enable keep_threads_active in mpeg2 decoder"
  bug: "343793479"
}
+4 −5
Original line number Diff line number Diff line
@@ -14,11 +14,10 @@ cc_library {
        "libcodec2_soft_sanitize_signed-defaults",
    ],

    cflags: [
        "-DKEEP_THREADS_ACTIVE=0",
    ],

    srcs: ["C2SoftMpeg2Dec.cpp"],

    static_libs: ["libmpeg2dec"],
    static_libs: [
        "libmpeg2dec",
        "android.media.swcodec.flags-aconfig-cc",
    ],
}
+6 −13
Original line number Diff line number Diff line
@@ -16,11 +16,10 @@

//#define LOG_NDEBUG 0
#define LOG_TAG "C2SoftMpeg2Dec"
#ifndef KEEP_THREADS_ACTIVE
#define KEEP_THREADS_ACTIVE 0
#endif
#include <log/log.h>

#include <android_media_swcodec_flags.h>

#include <media/stagefright/foundation/MediaDefs.h>

#include <C2Debug.h>
@@ -320,14 +319,7 @@ C2SoftMpeg2Dec::C2SoftMpeg2Dec(
        c2_node_id_t id,
        const std::shared_ptr<IntfImpl> &intfImpl)
    : SimpleC2Component(std::make_shared<SimpleInterface<IntfImpl>>(name, id, intfImpl)),
        mIntf(intfImpl),
        mDecHandle(nullptr),
        mMemRecords(nullptr),
        mOutBufferDrain(nullptr),
        mIvColorformat(IV_YUV_420P),
        mWidth(320),
        mHeight(240),
        mOutIndex(0u) {
        mIntf(intfImpl) {
    // If input dump is enabled, then open create an empty file
    GENERATE_FILE_NAMES();
    CREATE_DUMP_FILE(mInFile);
@@ -436,7 +428,7 @@ status_t C2SoftMpeg2Dec::fillMemRecords() {

    s_fill_mem_ip.s_ivd_fill_mem_rec_ip_t.u4_size = sizeof(ivdext_fill_mem_rec_ip_t);
    s_fill_mem_ip.u4_share_disp_buf = 0;
    s_fill_mem_ip.u4_keep_threads_active = KEEP_THREADS_ACTIVE;
    s_fill_mem_ip.u4_keep_threads_active = mKeepThreadsActive;
    s_fill_mem_ip.e_output_format = mIvColorformat;
    s_fill_mem_ip.u4_deinterlace = 1;
    s_fill_mem_ip.s_ivd_fill_mem_rec_ip_t.e_cmd = IV_CMD_FILL_NUM_MEM_REC;
@@ -478,7 +470,7 @@ status_t C2SoftMpeg2Dec::createDecoder() {
    s_init_ip.s_ivd_init_ip_t.u4_frm_max_ht = mHeight;
    s_init_ip.u4_share_disp_buf = 0;
    s_init_ip.u4_deinterlace = 1;
    s_init_ip.u4_keep_threads_active = KEEP_THREADS_ACTIVE;
    s_init_ip.u4_keep_threads_active = mKeepThreadsActive;
    s_init_ip.s_ivd_init_ip_t.u4_num_mem_rec = mNumMemRecords;
    s_init_ip.s_ivd_init_ip_t.e_output_format = mIvColorformat;
    s_init_op.s_ivd_init_op_t.u4_size = sizeof(ivdext_init_op_t);
@@ -571,6 +563,7 @@ status_t C2SoftMpeg2Dec::initDecoder() {
    status_t ret = getNumMemRecords();
    if (OK != ret) return ret;

    mKeepThreadsActive = android::media::swcodec::flags::mpeg2_keep_threads_active();
    ret = fillMemRecords();
    if (OK != ret) return ret;

+15 −14
Original line number Diff line number Diff line
@@ -144,21 +144,22 @@ struct C2SoftMpeg2Dec : public SimpleC2Component {
    };

    std::shared_ptr<IntfImpl> mIntf;
    iv_obj_t *mDecHandle;
    iv_mem_rec_t *mMemRecords;
    size_t mNumMemRecords;
    iv_obj_t *mDecHandle = nullptr;
    iv_mem_rec_t *mMemRecords = nullptr;
    size_t mNumMemRecords = 0;
    std::shared_ptr<C2GraphicBlock> mOutBlock;
    uint8_t *mOutBufferDrain;

    size_t mNumCores;
    IV_COLOR_FORMAT_T mIvColorformat;

    uint32_t mWidth;
    uint32_t mHeight;
    uint32_t mStride;
    bool mSignalledOutputEos;
    bool mSignalledError;
    std::atomic_uint64_t mOutIndex;
    uint8_t *mOutBufferDrain = nullptr;

    size_t mNumCores = 1;
    IV_COLOR_FORMAT_T mIvColorformat = IV_YUV_420P;

    uint32_t mWidth = 320;
    uint32_t mHeight = 240;
    uint32_t mStride = 0;
    bool mSignalledOutputEos = false;
    bool mSignalledError = false;
    bool mKeepThreadsActive = false;
    std::atomic_uint64_t mOutIndex = 0;

    // Color aspects. These are ISO values and are meant to detect changes in aspects to avoid
    // converting them to C2 values for each frame