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

Commit 51c2a202 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 6936c1e3 196cbfb4
Loading
Loading
Loading
Loading
+6 −9
Original line number Original line 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(mInFile);
    CREATE_DUMP_FILE(mOutFile);
    CREATE_DUMP_FILE(mOutFile);


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


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


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


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


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


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


#include <inttypes.h>

#include <SimpleC2Component.h>
#include <SimpleC2Component.h>
#include "aom/aom_decoder.h"
#include "aom/aom_decoder.h"
#include "aom/aomdx.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 {
namespace android {


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


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


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


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


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


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


            WORD32 delay;
            mTimeStart = systemTime();
            GETTIME(&mTimeStart, nullptr);
            nsecs_t delay = mTimeStart - mTimeEnd;
            TIME_DIFF(mTimeEnd, mTimeStart, delay);
            (void) ivdec_api_function(mDecHandle, &s_h264d_decode_ip, &s_h264d_decode_op);
            (void) ivdec_api_function(mDecHandle, &s_h264d_decode_ip, &s_h264d_decode_op);
            WORD32 decodeTime;

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


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


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


@@ -43,19 +44,15 @@ namespace android {
#define IVDEXT_CMD_CTL_SET_NUM_CORES    \
#define IVDEXT_CMD_CTL_SET_NUM_CORES    \
        (IVD_CONTROL_API_COMMAND_TYPE_T)IH264D_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 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
#ifdef FILE_DUMP_ENABLE
    #define INPUT_DUMP_PATH     "/sdcard/clips/avcd_input"
    #define INPUT_DUMP_PATH     "/sdcard/clips/avcd_input"
    #define INPUT_DUMP_EXT      "h264"
    #define INPUT_DUMP_EXT      "h264"
    #define GENERATE_FILE_NAMES() {                         \
    #define GENERATE_FILE_NAMES() {                         \
        GETTIME(&mTimeStart, NULL);                         \
        nsecs_t now = systemTime();                         \
        strcpy(mInFile, "");                                \
        strcpy(mInFile, "");                                \
        sprintf(mInFile, "%s_%ld.%ld.%s", INPUT_DUMP_PATH,  \
        sprintf(mInFile, "%s_%" PRId64 "d.%s",              \
                mTimeStart.tv_sec, mTimeStart.tv_usec,      \
                INPUT_DUMP_PATH, now,                       \
                INPUT_DUMP_EXT);                            \
                INPUT_DUMP_EXT);                            \
    }
    }
    #define CREATE_DUMP_FILE(m_filename) {                  \
    #define CREATE_DUMP_FILE(m_filename) {                  \
@@ -183,8 +180,8 @@ private:
    } mBitstreamColorAspects;
    } mBitstreamColorAspects;


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


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


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


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


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


        GETTIME(&mTimeStart, nullptr);
        /* Compute time elapsed between end of previous decode()
        /* Compute time elapsed between end of previous decode()
         * to start of current 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);
        status = ive_api_function(mCodecCtx, &s_video_encode_ip, &s_video_encode_op);


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


    GETTIME(&mTimeEnd, nullptr);
    /* Compute time taken for decode() */
    /* 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);
            ps_encode_op->s_out_buf.u4_bytes);


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