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

Commit 233a22e1 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "aosp-ittiam" into sc-dev

* changes:
  C2 VTS: Update SetUp() to reduce code duplications
  C2SoftOpusEnc: Add support for a constant bitrate
  C2SoftAacDec: Fix reset while codec's stop()
  C2SoftAmrWbDec: Fix reset while codec's stop().
parents 3b979b5d 97e8181c
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -289,13 +289,14 @@ c2_status_t C2SoftAacDec::onStop() {
    mOutputDelayRingBufferFilled = 0;
    mBuffersInfo.clear();

    // To make the codec behave the same before and after a reset, we need to invalidate the
    // streaminfo struct. This does that:
    mStreamInfo->sampleRate = 0; // TODO: mStreamInfo is read only

    status_t status = UNKNOWN_ERROR;
    if (mAACDecoder) {
        aacDecoder_Close(mAACDecoder);
        status = initDecoder();
    }
    mSignalledError = false;

    return C2_OK;
    return status == OK ? C2_OK : C2_CORRUPTED;
}

void C2SoftAacDec::onReset() {
+1 −1
Original line number Diff line number Diff line
@@ -143,7 +143,7 @@ c2_status_t C2SoftAmrDec::onStop() {
    if (!mIsWide) {
        Speech_Decode_Frame_reset(mAmrHandle);
    } else {
        pvDecoder_AmrWb_Reset(mAmrHandle, 0 /* reset_all */);
        pvDecoder_AmrWb_Reset(mAmrHandle, 1 /* reset_all */);
    }
    mSignalledError = false;
    mSignalledOutputEos = false;
+34 −8
Original line number Diff line number Diff line
@@ -77,6 +77,19 @@ public:
                .withSetter((Setter<decltype(*mChannelCount)>::StrictValueWithNoDeps))
                .build());

        addParameter(
            DefineParam(mBitrateMode, C2_PARAMKEY_BITRATE_MODE)
                .withDefault(new C2StreamBitrateModeTuning::output(
                        0u, C2Config::BITRATE_VARIABLE))
                .withFields({
                    C2F(mBitrateMode, value).oneOf({
                        C2Config::BITRATE_CONST,
                        C2Config::BITRATE_VARIABLE})
                })
                .withSetter(
                    Setter<decltype(*mBitrateMode)>::StrictValueWithNoDeps)
                .build());

        addParameter(
                DefineParam(mBitrate, C2_PARAMKEY_BITRATE)
                .withDefault(new C2StreamBitrateInfo::output(0u, 128000))
@@ -100,12 +113,14 @@ public:
    uint32_t getSampleRate() const { return mSampleRate->value; }
    uint32_t getChannelCount() const { return mChannelCount->value; }
    uint32_t getBitrate() const { return mBitrate->value; }
    uint32_t getBitrateMode() const { return mBitrateMode->value; }
    uint32_t getComplexity() const { return mComplexity->value; }

private:
    std::shared_ptr<C2StreamSampleRateInfo::input> mSampleRate;
    std::shared_ptr<C2StreamChannelCountInfo::input> mChannelCount;
    std::shared_ptr<C2StreamBitrateInfo::output> mBitrate;
    std::shared_ptr<C2StreamBitrateModeTuning::output> mBitrateMode;
    std::shared_ptr<C2StreamComplexityTuning::output> mComplexity;
    std::shared_ptr<C2StreamMaxBufferSizeInfo::input> mInputMaxBufSize;
};
@@ -135,6 +150,7 @@ c2_status_t C2SoftOpusEnc::configureEncoder() {
    mSampleRate = mIntf->getSampleRate();
    mChannelCount = mIntf->getChannelCount();
    uint32_t bitrate = mIntf->getBitrate();
    uint32_t bitrateMode = mIntf->getBitrateMode();
    int complexity = mIntf->getComplexity();
    mNumSamplesPerFrame = mSampleRate / (1000 / mFrameDurationMs);
    mNumPcmBytesPerInputFrame =
@@ -189,6 +205,7 @@ c2_status_t C2SoftOpusEnc::configureEncoder() {
        return C2_BAD_VALUE;
    }

    if (bitrateMode == C2Config::BITRATE_VARIABLE) {
        // Constrained VBR
        if (opus_multistream_encoder_ctl(mEncoder, OPUS_SET_VBR(1) != OPUS_OK)) {
            ALOGE("failed to set vbr type");
@@ -199,6 +216,15 @@ c2_status_t C2SoftOpusEnc::configureEncoder() {
            ALOGE("failed to set vbr constraint");
            return C2_BAD_VALUE;
        }
    } else if (bitrateMode == C2Config::BITRATE_CONST) {
        if (opus_multistream_encoder_ctl(mEncoder, OPUS_SET_VBR(0) != OPUS_OK)) {
            ALOGE("failed to set cbr type");
            return C2_BAD_VALUE;
        }
    } else {
        ALOGE("unknown bitrate mode");
        return C2_BAD_VALUE;
    }

    // Bitrate
    if (opus_multistream_encoder_ctl(mEncoder, OPUS_SET_BITRATE(bitrate)) !=
+43 −64
Original line number Diff line number Diff line
@@ -36,13 +36,13 @@ static std::vector<DecodeTestParameters> gDecodeTestParameters;
using CsdFlushTestParameters = std::tuple<std::string, std::string, bool>;
static std::vector<CsdFlushTestParameters> gCsdFlushTestParameters;

struct CompToURL {
struct CompToFiles {
    std::string mime;
    std::string mURL;
    std::string info;
    std::string inputFile;
    std::string infoFile;
};

std::vector<CompToURL> gCompToURL = {
std::vector<CompToFiles> gCompToFiles = {
        {"mp4a-latm", "bbb_aac_stereo_128kbps_48000hz.aac", "bbb_aac_stereo_128kbps_48000hz.info"},
        {"mp4a-latm", "bbb_aac_stereo_128kbps_48000hz.aac",
         "bbb_aac_stereo_128kbps_48000hz_multi_frame.info"},
@@ -110,6 +110,15 @@ class Codec2AudioDecHidlTestBase : public ::testing::Test {
        mTimestampUs = 0u;
        mWorkResult = C2_OK;
        mTimestampDevTest = false;

        bool valid = getFileNames(mStreamIndex);
        if (!valid) {
            GTEST_SKIP() << "No test file for  mime " << mMime << " index: " << mStreamIndex;
        }
        ALOGV("mStreamIndex : %zu", mStreamIndex);
        ALOGV("mInputFile : %s", mInputFile.c_str());
        ALOGV("mInfoFile : %s", mInfoFile.c_str());

        if (mDisableTest) std::cout << "[   WARN   ] Test Disabled \n";
    }

@@ -126,7 +135,7 @@ class Codec2AudioDecHidlTestBase : public ::testing::Test {

    virtual void validateTimestampList(int32_t* bitStreamInfo);

    void GetURLForComponent(char* mURL, char* info, size_t streamIndex = 0);
    bool getFileNames(size_t streamIndex = 0);

    struct outputMetaData {
        uint64_t timestampUs;
@@ -193,6 +202,10 @@ class Codec2AudioDecHidlTestBase : public ::testing::Test {
    std::shared_ptr<android::Codec2Client::Listener> mListener;
    std::shared_ptr<android::Codec2Client::Component> mComponent;

    std::string mInputFile;
    std::string mInfoFile;
    size_t mStreamIndex = 0;

  protected:
    static void description(const std::string& description) {
        RecordProperty("description", description);
@@ -204,6 +217,7 @@ class Codec2AudioDecHidlTest : public Codec2AudioDecHidlTestBase,
    void getParams() {
        mInstanceName = std::get<0>(GetParam());
        mComponentName = std::get<1>(GetParam());
        mStreamIndex = 0;
    }
};

@@ -285,18 +299,20 @@ void getInputChannelInfo(const std::shared_ptr<android::Codec2Client::Component>
}

// LookUpTable of clips and metadata for component testing
void Codec2AudioDecHidlTestBase::GetURLForComponent(char* mURL, char* info, size_t streamIndex) {
bool Codec2AudioDecHidlTestBase::getFileNames(size_t streamIndex) {
    int streamCount = 0;
    for (size_t i = 0; i < gCompToURL.size(); ++i) {
        if (mMime.find(gCompToURL[i].mime) != std::string::npos) {

    for (size_t i = 0; i < gCompToFiles.size(); ++i) {
        if (mMime.find(gCompToFiles[i].mime) != std::string::npos) {
            if (streamCount == streamIndex) {
                strcat(mURL, gCompToURL[i].mURL.c_str());
                strcat(info, gCompToURL[i].info.c_str());
                return;
                mInputFile = sResourceDir + gCompToFiles[i].inputFile;
                mInfoFile = sResourceDir + gCompToFiles[i].infoFile;
                return true;
            }
            streamCount++;
        }
    }
    return false;
}

void decodeNFrames(const std::shared_ptr<android::Codec2Client::Component>& component,
@@ -429,6 +445,7 @@ class Codec2AudioDecDecodeTest : public Codec2AudioDecHidlTestBase,
    void getParams() {
        mInstanceName = std::get<0>(GetParam());
        mComponentName = std::get<1>(GetParam());
        mStreamIndex = std::get<2>(GetParam());
    }
};

@@ -436,22 +453,12 @@ TEST_P(Codec2AudioDecDecodeTest, DecodeTest) {
    description("Decodes input file");
    if (mDisableTest) GTEST_SKIP() << "Test is disabled";

    uint32_t streamIndex = std::get<2>(GetParam());
    bool signalEOS = std::get<3>(GetParam());
    mTimestampDevTest = true;
    char mURL[512], info[512];
    android::Vector<FrameInfo> Info;

    strcpy(mURL, sResourceDir.c_str());
    strcpy(info, sResourceDir.c_str());
    GetURLForComponent(mURL, info, streamIndex);
    if (!strcmp(mURL, sResourceDir.c_str())) {
        ALOGV("EMPTY INPUT sResourceDir.c_str() %s mURL  %s ", sResourceDir.c_str(), mURL);
        return;
    }

    int32_t numCsds = populateInfoVector(info, &Info, mTimestampDevTest, &mTimestampUslist);
    ASSERT_GE(numCsds, 0) << "Error in parsing input info file: " << info;
    int32_t numCsds = populateInfoVector(mInfoFile, &Info, mTimestampDevTest, &mTimestampUslist);
    ASSERT_GE(numCsds, 0) << "Error in parsing input info file: " << mInfoFile;

    // Reset total no of frames received
    mFramesReceived = 0;
@@ -468,9 +475,8 @@ TEST_P(Codec2AudioDecDecodeTest, DecodeTest) {
        return;
    }
    ASSERT_EQ(mComponent->start(), C2_OK);
    ALOGV("mURL : %s", mURL);
    std::ifstream eleStream;
    eleStream.open(mURL, std::ifstream::binary);
    eleStream.open(mInputFile, std::ifstream::binary);
    ASSERT_EQ(eleStream.is_open(), true);
    ASSERT_NO_FATAL_FAILURE(decodeNFrames(mComponent, mQueueLock, mQueueCondition, mWorkQueue,
                                          mFlushedIndices, mLinearPool, eleStream, &Info, 0,
@@ -507,15 +513,10 @@ TEST_P(Codec2AudioDecHidlTest, ThumbnailTest) {
    description("Test Request for thumbnail");
    if (mDisableTest) GTEST_SKIP() << "Test is disabled";

    char mURL[512], info[512];
    android::Vector<FrameInfo> Info;

    strcpy(mURL, sResourceDir.c_str());
    strcpy(info, sResourceDir.c_str());
    GetURLForComponent(mURL, info);

    int32_t numCsds = populateInfoVector(info, &Info, mTimestampDevTest, &mTimestampUslist);
    ASSERT_GE(numCsds, 0) << "Error in parsing input info file: " << info;
    int32_t numCsds = populateInfoVector(mInfoFile, &Info, mTimestampDevTest, &mTimestampUslist);
    ASSERT_GE(numCsds, 0) << "Error in parsing input info file: " << mInfoFile;

    int32_t bitStreamInfo[2] = {0};
    if (mMime.find("raw") != std::string::npos) {
@@ -529,7 +530,6 @@ TEST_P(Codec2AudioDecHidlTest, ThumbnailTest) {
        return;
    }
    ASSERT_EQ(mComponent->start(), C2_OK);
    ALOGV("mURL : %s", mURL);

    // request EOS for thumbnail
    // signal EOS flag with last frame
@@ -542,7 +542,7 @@ TEST_P(Codec2AudioDecHidlTest, ThumbnailTest) {

    } while (!(flags & SYNC_FRAME));
    std::ifstream eleStream;
    eleStream.open(mURL, std::ifstream::binary);
    eleStream.open(mInputFile, std::ifstream::binary);
    ASSERT_EQ(eleStream.is_open(), true);
    ASSERT_NO_FATAL_FAILURE(decodeNFrames(mComponent, mQueueLock, mQueueCondition, mWorkQueue,
                                          mFlushedIndices, mLinearPool, eleStream, &Info, 0,
@@ -599,15 +599,10 @@ TEST_P(Codec2AudioDecHidlTest, EOSTest) {
TEST_P(Codec2AudioDecHidlTest, FlushTest) {
    description("Tests Flush calls");
    if (mDisableTest) GTEST_SKIP() << "Test is disabled";
    char mURL[512], info[512];
    android::Vector<FrameInfo> Info;

    strcpy(mURL, sResourceDir.c_str());
    strcpy(info, sResourceDir.c_str());
    GetURLForComponent(mURL, info);

    int32_t numCsds = populateInfoVector(info, &Info, mTimestampDevTest, &mTimestampUslist);
    ASSERT_GE(numCsds, 0) << "Error in parsing input info file: " << info;
    int32_t numCsds = populateInfoVector(mInfoFile, &Info, mTimestampDevTest, &mTimestampUslist);
    ASSERT_GE(numCsds, 0) << "Error in parsing input info file: " << mInfoFile;

    int32_t bitStreamInfo[2] = {0};
    if (mMime.find("raw") != std::string::npos) {
@@ -629,9 +624,8 @@ TEST_P(Codec2AudioDecHidlTest, FlushTest) {
            verifyFlushOutput(flushedWork, mWorkQueue, mFlushedIndices, mQueueLock));
    ASSERT_EQ(mWorkQueue.size(), MAX_INPUT_BUFFERS);

    ALOGV("mURL : %s", mURL);
    std::ifstream eleStream;
    eleStream.open(mURL, std::ifstream::binary);
    eleStream.open(mInputFile, std::ifstream::binary);
    ASSERT_EQ(eleStream.is_open(), true);
    // Decode 30 frames and flush.
    uint32_t numFramesFlushed = FLUSH_INTERVAL;
@@ -684,15 +678,10 @@ TEST_P(Codec2AudioDecHidlTest, DecodeTestEmptyBuffersInserted) {
    description("Decode with multiple empty input frames");
    if (mDisableTest) GTEST_SKIP() << "Test is disabled";

    char mURL[512], info[512];
    std::ifstream eleStream, eleInfo;

    strcpy(mURL, sResourceDir.c_str());
    strcpy(info, sResourceDir.c_str());
    GetURLForComponent(mURL, info);

    eleInfo.open(info);
    ASSERT_EQ(eleInfo.is_open(), true) << mURL << " - file not found";
    eleInfo.open(mInfoFile);
    ASSERT_EQ(eleInfo.is_open(), true) << mInputFile << " - file not found";
    android::Vector<FrameInfo> Info;
    int bytesCount = 0;
    uint32_t frameId = 0;
@@ -730,8 +719,7 @@ TEST_P(Codec2AudioDecHidlTest, DecodeTestEmptyBuffersInserted) {
        return;
    }
    ASSERT_EQ(mComponent->start(), C2_OK);
    ALOGV("mURL : %s", mURL);
    eleStream.open(mURL, std::ifstream::binary);
    eleStream.open(mInputFile, std::ifstream::binary);
    ASSERT_EQ(eleStream.is_open(), true);
    ASSERT_NO_FATAL_FAILURE(decodeNFrames(mComponent, mQueueLock, mQueueCondition, mWorkQueue,
                                          mFlushedIndices, mLinearPool, eleStream, &Info, 0,
@@ -759,6 +747,7 @@ class Codec2AudioDecCsdInputTests : public Codec2AudioDecHidlTestBase,
    void getParams() {
        mInstanceName = std::get<0>(GetParam());
        mComponentName = std::get<1>(GetParam());
        mStreamIndex = 0;
    }
};

@@ -768,19 +757,9 @@ TEST_P(Codec2AudioDecCsdInputTests, CSDFlushTest) {
    description("Tests codecs for flush at different states");
    if (mDisableTest) GTEST_SKIP() << "Test is disabled";

    char mURL[512], info[512];
    android::Vector<FrameInfo> Info;

    strcpy(mURL, sResourceDir.c_str());
    strcpy(info, sResourceDir.c_str());
    GetURLForComponent(mURL, info);
    if (!strcmp(mURL, sResourceDir.c_str())) {
        ALOGV("EMPTY INPUT sResourceDir.c_str() %s mURL  %s ", sResourceDir.c_str(), mURL);
        return;
    }
    ALOGV("mURL : %s", mURL);

    int32_t numCsds = populateInfoVector(info, &Info, mTimestampDevTest, &mTimestampUslist);
    int32_t numCsds = populateInfoVector(mInfoFile, &Info, mTimestampDevTest, &mTimestampUslist);
    ASSERT_GE(numCsds, 0) << "Error in parsing input info file";

    int32_t bitStreamInfo[2] = {0};
@@ -797,7 +776,7 @@ TEST_P(Codec2AudioDecCsdInputTests, CSDFlushTest) {

    ASSERT_EQ(mComponent->start(), C2_OK);
    std::ifstream eleStream;
    eleStream.open(mURL, std::ifstream::binary);
    eleStream.open(mInputFile, std::ifstream::binary);
    ASSERT_EQ(eleStream.is_open(), true);

    bool signalEOS = false;
+62 −115

File changed.

Preview size limit exceeded, changes collapsed.

Loading