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

Commit 05f861b8 authored by Ray Essick's avatar Ray Essick Committed by Automerger Merge Worker
Browse files

Merge "Use monotonic system time instead of gettimeofday" into tm-dev am: 196cbfb4

parents 1f71d977 196cbfb4
Loading
Loading
Loading
Loading
+6 −9
Original line number Diff line number Diff line
@@ -261,8 +261,7 @@ C2SoftAomDec::C2SoftAomDec(const char* name, c2_node_id_t id,
    CREATE_DUMP_FILE(mInFile);
    CREATE_DUMP_FILE(mOutFile);

    gettimeofday(&mTimeStart, nullptr);
    gettimeofday(&mTimeEnd, nullptr);
    mTimeStart = mTimeEnd = systemTime();
}

C2SoftAomDec::~C2SoftAomDec() {
@@ -463,19 +462,17 @@ void C2SoftAomDec::process(const std::unique_ptr<C2Work>& work,
    int64_t frameIndex = work->input.ordinal.frameIndex.peekll();
    if (inSize) {
        uint8_t* bitstream = const_cast<uint8_t*>(rView.data() + inOffset);
        int32_t decodeTime = 0;
        int32_t delay = 0;

        DUMP_TO_FILE(mOutFile, bitstream, inSize);
        GETTIME(&mTimeStart, nullptr);
        TIME_DIFF(mTimeEnd, mTimeStart, delay);
        mTimeStart = systemTime();
        nsecs_t delay = mTimeStart - mTimeEnd;

        aom_codec_err_t err =
            aom_codec_decode(mCodecCtx, bitstream, inSize, &frameIndex);

        GETTIME(&mTimeEnd, nullptr);
        TIME_DIFF(mTimeStart, mTimeEnd, decodeTime);
        ALOGV("decodeTime=%4d delay=%4d\n", decodeTime, delay);
        mTimeEnd = systemTime();
        nsecs_t decodeTime = mTimeEnd - mTimeStart;
        ALOGV("decodeTime=%4" PRId64 " delay=%4" PRId64 "\n", decodeTime, delay);

        if (err != AOM_CODEC_OK) {
            ALOGE("av1 decoder failed to decode frame err: %d", err);
+9 −13
Original line number Diff line number Diff line
@@ -17,15 +17,12 @@
#ifndef ANDROID_C2_SOFT_AV1_DEC_H_
#define ANDROID_C2_SOFT_AV1_DEC_H_

#include <inttypes.h>

#include <SimpleC2Component.h>
#include "aom/aom_decoder.h"
#include "aom/aomdx.h"

#define GETTIME(a, b) gettimeofday(a, b);
#define TIME_DIFF(start, end, diff)     \
    diff = (((end).tv_sec - (start).tv_sec) * 1000000) + \
            ((end).tv_usec - (start).tv_usec);

namespace android {

struct C2SoftAomDec : public SimpleC2Component {
@@ -60,8 +57,8 @@ struct C2SoftAomDec : public SimpleC2Component {
    char mOutFile[200];
    #endif /* FILE_DUMP_ENABLE */

    struct timeval mTimeStart;   // Time at the start of decode()
    struct timeval mTimeEnd;     // Time at the end of decode()
    nsecs_t mTimeStart = 0;   // Time at the start of decode()
    nsecs_t mTimeEnd = 0;     // Time at the end of decode()

    status_t initDecoder();
    status_t destroyDecoder();
@@ -85,14 +82,13 @@ struct C2SoftAomDec : public SimpleC2Component {
#define OUTPUT_DUMP_EXT "av1"
#define GENERATE_FILE_NAMES()                                                 \
    {                                                                         \
        GETTIME(&mTimeStart, NULL);                                           \
        strcpy(mInFile, "");                                                  \
        nsecs_t now = systemTime();                                           \
        ALOGD("GENERATE_FILE_NAMES");                                         \
        sprintf(mInFile, "%s_%ld.%ld.%s", INPUT_DUMP_PATH, mTimeStart.tv_sec, \
                mTimeStart.tv_usec, INPUT_DUMP_EXT);                          \
        sprintf(mInFile, "%s_%" PRId64 ".%s", INPUT_DUMP_PATH,                \
                now, INPUT_DUMP_EXT);                                         \
        strcpy(mOutFile, "");                                                 \
        sprintf(mOutFile, "%s_%ld.%ld.%s", OUTPUT_DUMP_PATH,                  \
                mTimeStart.tv_sec, mTimeStart.tv_usec, OUTPUT_DUMP_EXT);      \
        sprintf(mOutFile, "%s_%" PRId64 ".%s", OUTPUT_DUMP_PATH,              \
                now, OUTPUT_DUMP_EXT);                                        \
    }

#define CREATE_DUMP_FILE(m_filename)                     \
+7 −9
Original line number Diff line number Diff line
@@ -670,8 +670,7 @@ status_t C2SoftAvcDec::resetDecoder() {

void C2SoftAvcDec::resetPlugin() {
    mSignalledOutputEos = false;
    gettimeofday(&mTimeStart, nullptr);
    gettimeofday(&mTimeEnd, nullptr);
    mTimeStart = mTimeEnd = systemTime();
}

status_t C2SoftAvcDec::deleteDecoder() {
@@ -866,14 +865,13 @@ void C2SoftAvcDec::process(
                setParams(mStride, IVD_DECODE_HEADER);
            }

            WORD32 delay;
            GETTIME(&mTimeStart, nullptr);
            TIME_DIFF(mTimeEnd, mTimeStart, delay);
            mTimeStart = systemTime();
            nsecs_t delay = mTimeStart - mTimeEnd;
            (void) ivdec_api_function(mDecHandle, &s_h264d_decode_ip, &s_h264d_decode_op);
            WORD32 decodeTime;
            GETTIME(&mTimeEnd, nullptr);
            TIME_DIFF(mTimeStart, mTimeEnd, decodeTime);
            ALOGV("decodeTime=%6d delay=%6d numBytes=%6d", decodeTime, delay,

            mTimeEnd = systemTime();
            nsecs_t decodeTime = mTimeEnd - mTimeStart;
            ALOGV("decodeTime=%" PRId64 " delay=%" PRId64 " numBytes=%6d", decodeTime, delay,
                  ps_decode_op->u4_num_bytes_consumed);
        }
        if (IVD_MEM_ALLOC_FAILED == (ps_decode_op->u4_error_code & IVD_ERROR_MASK)) {
+6 −9
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#define ANDROID_C2_SOFT_AVC_DEC_H_

#include <sys/time.h>
#include <inttypes.h>

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

@@ -43,19 +44,15 @@ namespace android {
#define IVDEXT_CMD_CTL_SET_NUM_CORES    \
        (IVD_CONTROL_API_COMMAND_TYPE_T)IH264D_CMD_CTL_SET_NUM_CORES
#define MIN(a, b)                       (((a) < (b)) ? (a) : (b))
#define GETTIME(a, b)                   gettimeofday(a, b);
#define TIME_DIFF(start, end, diff)     \
    diff = (((end).tv_sec - (start).tv_sec) * 1000000) + \
            ((end).tv_usec - (start).tv_usec);

#ifdef FILE_DUMP_ENABLE
    #define INPUT_DUMP_PATH     "/sdcard/clips/avcd_input"
    #define INPUT_DUMP_EXT      "h264"
    #define GENERATE_FILE_NAMES() {                         \
        GETTIME(&mTimeStart, NULL);                         \
        nsecs_t now = systemTime();                         \
        strcpy(mInFile, "");                                \
        sprintf(mInFile, "%s_%ld.%ld.%s", INPUT_DUMP_PATH,  \
                mTimeStart.tv_sec, mTimeStart.tv_usec,      \
        sprintf(mInFile, "%s_%" PRId64 "d.%s",              \
                INPUT_DUMP_PATH, now,                       \
                INPUT_DUMP_EXT);                            \
    }
    #define CREATE_DUMP_FILE(m_filename) {                  \
@@ -183,8 +180,8 @@ private:
    } mBitstreamColorAspects;

    // profile
    struct timeval mTimeStart;
    struct timeval mTimeEnd;
    nsecs_t mTimeStart = 0;
    nsecs_t mTimeEnd = 0;
#ifdef FILE_DUMP_ENABLE
    char mInFile[200];
#endif /* FILE_DUMP_ENABLE */
+7 −9
Original line number Diff line number Diff line
@@ -656,8 +656,7 @@ void C2SoftAvcEnc::initEncParams() {
    mEntropyMode = DEFAULT_ENTROPY_MODE;
    mBframes = DEFAULT_B_FRAMES;

    gettimeofday(&mTimeStart, nullptr);
    gettimeofday(&mTimeEnd, nullptr);
    mTimeStart = mTimeEnd = systemTime();
}

c2_status_t C2SoftAvcEnc::setDimensions() {
@@ -1650,8 +1649,7 @@ void C2SoftAvcEnc::process(
    work->worklets.front()->output.flags = work->input.flags;

    IV_STATUS_T status;
    WORD32 timeDelay = 0;
    WORD32 timeTaken = 0;
    nsecs_t timeDelay = 0;
    uint64_t workIndex = work->input.ordinal.frameIndex.peekull();

    // Initialize encoder if not already initialized
@@ -1817,10 +1815,10 @@ void C2SoftAvcEnc::process(
        //         mInFile, s_encode_ip.s_inp_buf.apv_bufs[0],
        //         (mHeight * mStride * 3 / 2));

        GETTIME(&mTimeStart, nullptr);
        /* Compute time elapsed between end of previous decode()
         * to start of current decode() */
        TIME_DIFF(mTimeEnd, mTimeStart, timeDelay);
        mTimeStart = systemTime();
        timeDelay = mTimeStart - mTimeEnd;
        status = ive_api_function(mCodecCtx, &s_video_encode_ip, &s_video_encode_op);

        if (IV_SUCCESS != status) {
@@ -1844,11 +1842,11 @@ void C2SoftAvcEnc::process(
        mBuffers[ps_encode_ip->s_inp_buf.apv_bufs[0]] = inputBuffer;
    }

    GETTIME(&mTimeEnd, nullptr);
    /* Compute time taken for decode() */
    TIME_DIFF(mTimeStart, mTimeEnd, timeTaken);
    mTimeEnd = systemTime();
    nsecs_t timeTaken = mTimeEnd - mTimeStart;

    ALOGV("timeTaken=%6d delay=%6d numBytes=%6d", timeTaken, timeDelay,
    ALOGV("timeTaken=%" PRId64 "d delay=%" PRId64 " numBytes=%6d", timeTaken, timeDelay,
            ps_encode_op->s_out_buf.u4_bytes);

    void *freed = ps_encode_op->s_inp_buf.apv_bufs[0];
Loading