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

Commit 32a0d178 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Cleanup of Vts-Flags" into main

parents 8c0967af fcb86501
Loading
Loading
Loading
Loading
+16 −21
Original line number Original line Diff line number Diff line
@@ -90,8 +90,8 @@ class Codec2AudioDecHidlTestBase : public ::testing::Test {


        std::shared_ptr<C2AllocatorStore> store = android::GetCodec2PlatformAllocatorStore();
        std::shared_ptr<C2AllocatorStore> store = android::GetCodec2PlatformAllocatorStore();
        CHECK_EQ(store->fetchAllocator(C2AllocatorStore::DEFAULT_LINEAR, &mLinearAllocator), C2_OK);
        CHECK_EQ(store->fetchAllocator(C2AllocatorStore::DEFAULT_LINEAR, &mLinearAllocator), C2_OK);
        mLinearPool = std::make_shared<C2PooledBlockPool>(
        mLinearPool = std::make_shared<C2PooledBlockPool>(mLinearAllocator, mBlockPoolId++,
                mLinearAllocator, mBlockPoolId++, getBufferPoolVer());
                                                          getBufferPoolVer());
        ASSERT_NE(mLinearPool, nullptr);
        ASSERT_NE(mLinearPool, nullptr);


        std::vector<std::unique_ptr<C2Param>> queried;
        std::vector<std::unique_ptr<C2Param>> queried;
@@ -336,7 +336,9 @@ void decodeNFrames(const std::shared_ptr<android::Codec2Client::Component>& comp
            ASSERT_TRUE(false) << "Wait for generating C2Work exceeded timeout";
            ASSERT_TRUE(false) << "Wait for generating C2Work exceeded timeout";
        }
        }
        int64_t timestamp = (*Info)[frameID].timestamp;
        int64_t timestamp = (*Info)[frameID].timestamp;
        flags = ((*Info)[frameID].flags == FLAG_CONFIG_DATA) ? C2FrameData::FLAG_CODEC_CONFIG : 0;
        flags = ((*Info)[frameID].vtsFlags & (1 << VTS_BIT_FLAG_CSD_FRAME))
                        ? C2FrameData::FLAG_CODEC_CONFIG
                        : 0;
        if (signalEOS && ((frameID == (int)Info->size() - 1) || (frameID == (offset + range - 1))))
        if (signalEOS && ((frameID == (int)Info->size() - 1) || (frameID == (offset + range - 1))))
            flags |= C2FrameData::FLAG_END_OF_STREAM;
            flags |= C2FrameData::FLAG_END_OF_STREAM;


@@ -531,14 +533,10 @@ TEST_P(Codec2AudioDecHidlTest, ThumbnailTest) {


    // request EOS for thumbnail
    // request EOS for thumbnail
    // signal EOS flag with last frame
    // signal EOS flag with last frame
    size_t i = -1;
    size_t i;
    uint32_t flags;
    for (i = 0; i < Info.size(); i++) {
    do {
        if (Info[i].vtsFlags & (1 << VTS_BIT_FLAG_SYNC_FRAME)) break;
        i++;
    }
        flags = 0;
        if (Info[i].flags) flags = 1u << (Info[i].flags - 1);

    } while (!(flags & SYNC_FRAME));
    std::ifstream eleStream;
    std::ifstream eleStream;
    eleStream.open(mInputFile, std::ifstream::binary);
    eleStream.open(mInputFile, std::ifstream::binary);
    ASSERT_EQ(eleStream.is_open(), true);
    ASSERT_EQ(eleStream.is_open(), true);
@@ -643,14 +641,11 @@ TEST_P(Codec2AudioDecHidlTest, FlushTest) {
    mFlushedIndices.clear();
    mFlushedIndices.clear();
    int index = numFramesFlushed;
    int index = numFramesFlushed;
    bool keyFrame = false;
    bool keyFrame = false;
    uint32_t flags = 0;
    while (index < (int)Info.size()) {
    while (index < (int)Info.size()) {
        if (Info[index].flags) flags = 1u << (Info[index].flags - 1);
        if (Info[index].vtsFlags & (1 << VTS_BIT_FLAG_SYNC_FRAME)) {
        if ((flags & SYNC_FRAME) == SYNC_FRAME) {
            keyFrame = true;
            keyFrame = true;
            break;
            break;
        }
        }
        flags = 0;
        eleStream.ignore(Info[index].bytesCount);
        eleStream.ignore(Info[index].bytesCount);
        index++;
        index++;
    }
    }
@@ -684,24 +679,24 @@ TEST_P(Codec2AudioDecHidlTest, DecodeTestEmptyBuffersInserted) {
    int bytesCount = 0;
    int bytesCount = 0;
    uint32_t frameId = 0;
    uint32_t frameId = 0;
    uint32_t flags = 0;
    uint32_t flags = 0;
    uint32_t vtsFlags = 0;
    uint32_t timestamp = 0;
    uint32_t timestamp = 0;
    bool codecConfig = false;
    bool codecConfig = false;
    // This test introduces empty CSD after every 20th frame
    // This test introduces empty CSD after every 20th frame
    // and empty input frames at an interval of 5 frames.
    // and empty input frames at an interval of 5 frames.
    while (1) {
    while (1) {
        if (!(frameId % 5)) {
        if (!(frameId % 5)) {
            if (!(frameId % 20))
            vtsFlags = !(frameId % 20) ? (1 << VTS_BIT_FLAG_CSD_FRAME) : 0;
                flags = 32;
            else
                flags = 0;
            bytesCount = 0;
            bytesCount = 0;
        } else {
        } else {
            if (!(eleInfo >> bytesCount)) break;
            if (!(eleInfo >> bytesCount)) break;
            eleInfo >> flags;
            eleInfo >> flags;
            vtsFlags = mapInfoFlagstoVtsFlags(flags);
            ASSERT_NE(vtsFlags, 0xFF) << "unrecognized flag entry in info file: " << mInfoFile;
            eleInfo >> timestamp;
            eleInfo >> timestamp;
            codecConfig = flags ? ((1 << (flags - 1)) & C2FrameData::FLAG_CODEC_CONFIG) != 0 : 0;
            codecConfig = (vtsFlags & (1 << VTS_BIT_FLAG_CSD_FRAME)) != 0;
        }
        }
        Info.push_back({bytesCount, flags, timestamp});
        Info.push_back({bytesCount, vtsFlags, timestamp});
        frameId++;
        frameId++;
    }
    }
    eleInfo.close();
    eleInfo.close();
+17 −3
Original line number Original line Diff line number Diff line
@@ -233,18 +233,24 @@ int32_t populateInfoVector(std::string info, android::Vector<FrameInfo>* frameIn
    int32_t numCsds = 0;
    int32_t numCsds = 0;
    int32_t bytesCount = 0;
    int32_t bytesCount = 0;
    uint32_t flags = 0;
    uint32_t flags = 0;
    uint32_t vtsFlags = 0;
    uint32_t timestamp = 0;
    uint32_t timestamp = 0;
    while (1) {
    while (1) {
        if (!(eleInfo >> bytesCount)) break;
        if (!(eleInfo >> bytesCount)) break;
        eleInfo >> flags;
        eleInfo >> flags;
        vtsFlags = mapInfoFlagstoVtsFlags(flags);
        if (vtsFlags == 0xFF) {
            ALOGE("unrecognized flag entry in info file %s", info.c_str());
            return -1;
        }
        eleInfo >> timestamp;
        eleInfo >> timestamp;
        bool codecConfig = flags ? ((1 << (flags - 1)) & C2FrameData::FLAG_CODEC_CONFIG) != 0 : 0;
        bool codecConfig = (vtsFlags & (1 << VTS_BIT_FLAG_CSD_FRAME)) != 0 ;
        if (codecConfig) numCsds++;
        if (codecConfig) numCsds++;
        bool nonDisplayFrame = ((flags & FLAG_NON_DISPLAY_FRAME) != 0);
        bool nonDisplayFrame = (vtsFlags & (1 << VTS_BIT_FLAG_NO_SHOW_FRAME)) != 0;
        if (timestampDevTest && !codecConfig && !nonDisplayFrame) {
        if (timestampDevTest && !codecConfig && !nonDisplayFrame) {
            timestampUslist->push_back(timestamp);
            timestampUslist->push_back(timestamp);
        }
        }
        frameInfo->push_back({bytesCount, flags, timestamp});
        frameInfo->push_back({bytesCount, vtsFlags, timestamp});
    }
    }
    ALOGV("numCsds : %d", numCsds);
    ALOGV("numCsds : %d", numCsds);
    eleInfo.close();
    eleInfo.close();
@@ -273,3 +279,11 @@ void verifyFlushOutput(std::list<std::unique_ptr<C2Work>>& flushedWork,
    ASSERT_EQ(flushedIndices.empty(), true);
    ASSERT_EQ(flushedIndices.empty(), true);
    flushedWork.clear();
    flushedWork.clear();
}
}

int mapInfoFlagstoVtsFlags(int infoFlags) {
    if (infoFlags == 0) return 0;
    else if (infoFlags == 0x1) return (1 << VTS_BIT_FLAG_SYNC_FRAME);
    else if (infoFlags == 0x10) return (1 << VTS_BIT_FLAG_NO_SHOW_FRAME);
    else if (infoFlags == 0x20) return (1 << VTS_BIT_FLAG_CSD_FRAME);
    return 0xFF;
}
+10 −4
Original line number Original line Diff line number Diff line
@@ -29,9 +29,6 @@
#include <chrono>
#include <chrono>
#include <fstream>
#include <fstream>


#define FLAG_NON_DISPLAY_FRAME (1 << 4)
#define FLAG_CONFIG_DATA (1 << 5)

#define MAX_RETRY 20
#define MAX_RETRY 20
#define TIME_OUT 400ms
#define TIME_OUT 400ms
#define MAX_INPUT_BUFFERS 8
#define MAX_INPUT_BUFFERS 8
@@ -53,9 +50,15 @@ extern std::string sResourceDir;
// Component name prefix
// Component name prefix
extern std::string sComponentNamePrefix;
extern std::string sComponentNamePrefix;


enum c2_vts_flags_t {
    VTS_BIT_FLAG_SYNC_FRAME = 1,
    VTS_BIT_FLAG_NO_SHOW_FRAME = 2,
    VTS_BIT_FLAG_CSD_FRAME = 3,
};

struct FrameInfo {
struct FrameInfo {
    int bytesCount;
    int bytesCount;
    uint32_t flags;
    uint32_t vtsFlags;
    int64_t timestamp;
    int64_t timestamp;
};
};


@@ -165,4 +168,7 @@ int32_t populateInfoVector(std::string info, android::Vector<FrameInfo>* frameIn
void verifyFlushOutput(std::list<std::unique_ptr<C2Work>>& flushedWork,
void verifyFlushOutput(std::list<std::unique_ptr<C2Work>>& flushedWork,
                       std::list<std::unique_ptr<C2Work>>& workQueue,
                       std::list<std::unique_ptr<C2Work>>& workQueue,
                       std::list<uint64_t>& flushedIndices, std::mutex& queueLock);
                       std::list<uint64_t>& flushedIndices, std::mutex& queueLock);

int mapInfoFlagstoVtsFlags(int infoFlags);

#endif  // MEDIA_C2_HIDL_TEST_COMMON_H
#endif  // MEDIA_C2_HIDL_TEST_COMMON_H
+22 −29
Original line number Original line Diff line number Diff line
@@ -120,8 +120,8 @@ class Codec2VideoDecHidlTestBase : public ::testing::Test {


        std::shared_ptr<C2AllocatorStore> store = android::GetCodec2PlatformAllocatorStore();
        std::shared_ptr<C2AllocatorStore> store = android::GetCodec2PlatformAllocatorStore();
        CHECK_EQ(store->fetchAllocator(C2AllocatorStore::DEFAULT_LINEAR, &mLinearAllocator), C2_OK);
        CHECK_EQ(store->fetchAllocator(C2AllocatorStore::DEFAULT_LINEAR, &mLinearAllocator), C2_OK);
        mLinearPool = std::make_shared<C2PooledBlockPool>(
        mLinearPool = std::make_shared<C2PooledBlockPool>(mLinearAllocator, mBlockPoolId++,
                mLinearAllocator, mBlockPoolId++, getBufferPoolVer());
                                                          getBufferPoolVer());
        ASSERT_NE(mLinearPool, nullptr);
        ASSERT_NE(mLinearPool, nullptr);


        std::vector<std::unique_ptr<C2Param>> queried;
        std::vector<std::unique_ptr<C2Param>> queried;
@@ -463,7 +463,9 @@ void decodeNFrames(const std::shared_ptr<android::Codec2Client::Component>& comp
        }
        }
        int64_t timestamp = (*Info)[frameID].timestamp;
        int64_t timestamp = (*Info)[frameID].timestamp;


        flags = ((*Info)[frameID].flags == FLAG_CONFIG_DATA) ? C2FrameData::FLAG_CODEC_CONFIG : 0;
        flags = ((*Info)[frameID].vtsFlags & (1 << VTS_BIT_FLAG_CSD_FRAME))
                        ? C2FrameData::FLAG_CODEC_CONFIG
                        : 0;
        if (signalEOS && ((frameID == (int)Info->size() - 1) || (frameID == (offset + range - 1))))
        if (signalEOS && ((frameID == (int)Info->size() - 1) || (frameID == (offset + range - 1))))
            flags |= C2FrameData::FLAG_END_OF_STREAM;
            flags |= C2FrameData::FLAG_END_OF_STREAM;


@@ -711,17 +713,19 @@ TEST_P(Codec2VideoDecHidlTest, AdaptiveDecodeTest) {
        ASSERT_EQ(eleInfo.is_open(), true) << mInputFile << " - file not found";
        ASSERT_EQ(eleInfo.is_open(), true) << mInputFile << " - file not found";
        int bytesCount = 0;
        int bytesCount = 0;
        uint32_t flags = 0;
        uint32_t flags = 0;
        uint32_t vtsFlags = 0;
        uint32_t timestamp = 0;
        uint32_t timestamp = 0;
        uint32_t timestampMax = 0;
        uint32_t timestampMax = 0;
        while (1) {
        while (1) {
            if (!(eleInfo >> bytesCount)) break;
            if (!(eleInfo >> bytesCount)) break;
            eleInfo >> flags;
            eleInfo >> flags;
            vtsFlags = mapInfoFlagstoVtsFlags(flags);
            ASSERT_NE(vtsFlags, 0xFF) << "unrecognized flag entry in info file: " << mInfoFile;
            eleInfo >> timestamp;
            eleInfo >> timestamp;
            timestamp += timestampOffset;
            timestamp += timestampOffset;
            Info.push_back({bytesCount, flags, timestamp});
            Info.push_back({bytesCount, vtsFlags, timestamp});
            bool codecConfig =
            bool codecConfig = (vtsFlags & (1 << VTS_BIT_FLAG_CSD_FRAME)) != 0;
                    flags ? ((1 << (flags - 1)) & C2FrameData::FLAG_CODEC_CONFIG) != 0 : 0;
            bool nonDisplayFrame = (vtsFlags & (1 << VTS_BIT_FLAG_NO_SHOW_FRAME)) != 0;
            bool nonDisplayFrame = ((flags & FLAG_NON_DISPLAY_FRAME) != 0);


            {
            {
                ULock l(mQueueLock);
                ULock l(mQueueLock);
@@ -795,20 +799,15 @@ TEST_P(Codec2VideoDecHidlTest, ThumbnailTest) {
    int32_t numCsds = populateInfoVector(mInfoFile, &Info, mTimestampDevTest, &mTimestampUslist);
    int32_t numCsds = populateInfoVector(mInfoFile, &Info, mTimestampDevTest, &mTimestampUslist);
    ASSERT_GE(numCsds, 0) << "Error in parsing input info file: " << mInfoFile;
    ASSERT_GE(numCsds, 0) << "Error in parsing input info file: " << mInfoFile;


    uint32_t flags = 0;
    for (size_t i = 0; i < MAX_ITERATIONS; i++) {
    for (size_t i = 0; i < MAX_ITERATIONS; i++) {
        ASSERT_EQ(mComponent->start(), C2_OK);
        ASSERT_EQ(mComponent->start(), C2_OK);


        // request EOS for thumbnail
        // request EOS for thumbnail
        // signal EOS flag with last frame
        // signal EOS flag with last frame
        size_t j = -1;
        size_t j = -1;
        do {
        for (j = 0; j < Info.size(); j++) {
            j++;
            if (Info[j].vtsFlags & (1 << VTS_BIT_FLAG_SYNC_FRAME)) break;
            flags = 0;
        }
            if (Info[j].flags) flags = 1u << (Info[j].flags - 1);

        } while (!(flags & SYNC_FRAME));

        std::ifstream eleStream;
        std::ifstream eleStream;
        eleStream.open(mInputFile, std::ifstream::binary);
        eleStream.open(mInputFile, std::ifstream::binary);
        ASSERT_EQ(eleStream.is_open(), true);
        ASSERT_EQ(eleStream.is_open(), true);
@@ -908,14 +907,11 @@ TEST_P(Codec2VideoDecHidlTest, FlushTest) {
    // Seek to next key frame and start decoding till the end
    // Seek to next key frame and start decoding till the end
    int index = numFramesFlushed;
    int index = numFramesFlushed;
    bool keyFrame = false;
    bool keyFrame = false;
    uint32_t flags = 0;
    while (index < (int)Info.size()) {
    while (index < (int)Info.size()) {
        if (Info[index].flags) flags = 1u << (Info[index].flags - 1);
        if (Info[index].vtsFlags & (1 << VTS_BIT_FLAG_SYNC_FRAME)) {
        if ((flags & SYNC_FRAME) == SYNC_FRAME) {
            keyFrame = true;
            keyFrame = true;
            break;
            break;
        }
        }
        flags = 0;
        eleStream.ignore(Info[index].bytesCount);
        eleStream.ignore(Info[index].bytesCount);
        index++;
        index++;
    }
    }
@@ -949,24 +945,24 @@ TEST_P(Codec2VideoDecHidlTest, DecodeTestEmptyBuffersInserted) {
    int bytesCount = 0;
    int bytesCount = 0;
    uint32_t frameId = 0;
    uint32_t frameId = 0;
    uint32_t flags = 0;
    uint32_t flags = 0;
    uint32_t vtsFlags = 0;
    uint32_t timestamp = 0;
    uint32_t timestamp = 0;
    bool codecConfig = false;
    bool codecConfig = false;
    // This test introduces empty CSD after every 20th frame
    // This test introduces empty CSD after every 20th frame
    // and empty input frames at an interval of 5 frames.
    // and empty input frames at an interval of 5 frames.
    while (1) {
    while (1) {
        if (!(frameId % 5)) {
        if (!(frameId % 5)) {
            if (!(frameId % 20))
            vtsFlags = !(frameId % 20) ? (1 << VTS_BIT_FLAG_CSD_FRAME) : 0;
                flags = 32;
            else
                flags = 0;
            bytesCount = 0;
            bytesCount = 0;
        } else {
        } else {
            if (!(eleInfo >> bytesCount)) break;
            if (!(eleInfo >> bytesCount)) break;
            eleInfo >> flags;
            eleInfo >> flags;
            vtsFlags = mapInfoFlagstoVtsFlags(flags);
            ASSERT_NE(vtsFlags, 0xFF) << "unrecognized flag entry in info file: " << mInfoFile;
            eleInfo >> timestamp;
            eleInfo >> timestamp;
            codecConfig = flags ? ((1 << (flags - 1)) & C2FrameData::FLAG_CODEC_CONFIG) != 0 : 0;
            codecConfig = (vtsFlags & (1 << VTS_BIT_FLAG_CSD_FRAME)) != 0;
        }
        }
        Info.push_back({bytesCount, flags, timestamp});
        Info.push_back({bytesCount, vtsFlags, timestamp});
        frameId++;
        frameId++;
    }
    }
    eleInfo.close();
    eleInfo.close();
@@ -1046,12 +1042,9 @@ TEST_P(Codec2VideoDecCsdInputTests, CSDFlushTest) {
    }
    }


    int offset = framesToDecode;
    int offset = framesToDecode;
    uint32_t flags = 0;
    while (1) {
    while (1) {
        while (offset < (int)Info.size()) {
        while (offset < (int)Info.size()) {
            flags = 0;
            if (Info[offset].vtsFlags & (1 << VTS_BIT_FLAG_SYNC_FRAME)) {
            if (Info[offset].flags) flags = 1u << (Info[offset].flags - 1);
            if (flags & SYNC_FRAME) {
                keyFrame = true;
                keyFrame = true;
                break;
                break;
            }
            }