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

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

Merge "Add adaptive playback test" into oc-mr1-dev

parents 3f55d873 05f81e4d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -133,6 +133,7 @@ struct CodecObserver : public IOmxObserver {
                if (it->type ==
                    android::hardware::media::omx::V1_0::Message::Type::EVENT) {
                    *msg = *it;
                    if (callBack) callBack(*it, nullptr);
                    it = msgQueue.erase(it);
                    // OMX_EventBufferFlag event is sent when the component has
                    // processed a buffer with its EOS flag set. This event is
+176 −22
Original line number Diff line number Diff line
@@ -219,6 +219,7 @@ class VideoDecHidlTest : public ::testing::VtsHalHidlTargetTestBase {
        timestampUs = 0;
        timestampDevTest = false;
        isSecure = false;
        portSettingsChange = false;
        size_t suffixLen = strlen(".secure");
        if (strlen(gEnv->getComponent().c_str()) >= suffixLen) {
            isSecure =
@@ -295,6 +296,13 @@ class VideoDecHidlTest : public ::testing::VtsHalHidlTargetTestBase {
                }
#endif
            }
        } else if (msg.type == Message::Type::EVENT) {
            if (msg.data.eventData.event == OMX_EventPortSettingsChanged) {
                if ((msg.data.eventData.data2 == OMX_IndexParamPortDefinition ||
                     msg.data.eventData.data2 == 0)) {
                    portSettingsChange = true;
                }
            }
        }
    }

@@ -322,6 +330,7 @@ class VideoDecHidlTest : public ::testing::VtsHalHidlTargetTestBase {
    ::android::List<uint64_t> timestampUslist;
    bool timestampDevTest;
    bool isSecure;
    bool portSettingsChange;

   protected:
    static void description(const std::string& description) {
@@ -369,41 +378,56 @@ void getInputChannelInfo(sp<IOmxNode> omxNode, OMX_U32 kPortIndexInput,
    }
}

// number of elementary streams per component
#define STREAM_COUNT 2
// LookUpTable of clips and metadata for component testing
void GetURLForComponent(VideoDecHidlTest::standardComp comp, char* mURL,
                        char* info) {
                        char* info, size_t streamIndex = 1) {
    struct CompToURL {
        VideoDecHidlTest::standardComp comp;
        const char* mURL;
        const char* info;
        const char mURL[STREAM_COUNT][512];
        const char info[STREAM_COUNT][512];
    };
    ASSERT_TRUE(streamIndex < STREAM_COUNT);

    static const CompToURL kCompToURL[] = {
        {VideoDecHidlTest::standardComp::avc,
         "bbb_avc_1920x1080_5000kbps_30fps.h264",
         "bbb_avc_1920x1080_5000kbps_30fps.info"},
         {"bbb_avc_176x144_300kbps_60fps.h264",
          "bbb_avc_1920x1080_5000kbps_30fps.h264"},
         {"bbb_avc_176x144_300kbps_60fps.info",
          "bbb_avc_1920x1080_5000kbps_30fps.info"}},
        {VideoDecHidlTest::standardComp::hevc,
         "bbb_hevc_640x360_1600kbps_30fps.hevc",
         "bbb_hevc_640x360_1600kbps_30fps.info"},
         {"bbb_hevc_176x144_176kbps_60fps.hevc",
          "bbb_hevc_640x360_1600kbps_30fps.hevc"},
         {"bbb_hevc_176x144_176kbps_60fps.info",
          "bbb_hevc_640x360_1600kbps_30fps.info"}},
        {VideoDecHidlTest::standardComp::mpeg2,
         "bbb_mpeg2_176x144_105kbps_25fps.m2v",
         "bbb_mpeg2_176x144_105kbps_25fps.info"},
         {"bbb_mpeg2_176x144_105kbps_25fps.m2v",
          "bbb_mpeg2_352x288_1mbps_60fps.m2v"},
         {"bbb_mpeg2_176x144_105kbps_25fps.info",
          "bbb_mpeg2_352x288_1mbps_60fps.info"}},
        {VideoDecHidlTest::standardComp::h263,
         "bbb_h263_352x288_300kbps_12fps.h263",
         "bbb_h263_352x288_300kbps_12fps.info"},
         {"", "bbb_h263_352x288_300kbps_12fps.h263"},
         {"", "bbb_h263_352x288_300kbps_12fps.info"}},
        {VideoDecHidlTest::standardComp::mpeg4,
         "bbb_mpeg4_1280x720_1000kbps_25fps.m4v",
         "bbb_mpeg4_1280x720_1000kbps_25fps.info"},
        {VideoDecHidlTest::standardComp::vp8, "bbb_vp8_640x360_2mbps_30fps.vp8",
         "bbb_vp8_640x360_2mbps_30fps.info"},
         {"", "bbb_mpeg4_1280x720_1000kbps_25fps.m4v"},
         {"", "bbb_mpeg4_1280x720_1000kbps_25fps.info"}},
        {VideoDecHidlTest::standardComp::vp8,
         {"bbb_vp8_176x144_240kbps_60fps.vp8",
          "bbb_vp8_640x360_2mbps_30fps.vp8"},
         {"bbb_vp8_176x144_240kbps_60fps.info",
          "bbb_vp8_640x360_2mbps_30fps.info"}},
        {VideoDecHidlTest::standardComp::vp9,
         "bbb_vp9_640x360_1600kbps_30fps.vp9",
         "bbb_vp9_640x360_1600kbps_30fps.info"},
         {"bbb_vp9_176x144_285kbps_60fps.vp9",
          "bbb_vp9_640x360_1600kbps_30fps.vp9"},
         {"bbb_vp9_176x144_285kbps_60fps.info",
          "bbb_vp9_640x360_1600kbps_30fps.info"}},
    };

    for (size_t i = 0; i < sizeof(kCompToURL) / sizeof(kCompToURL[0]); ++i) {
        if (kCompToURL[i].comp == comp) {
            strcat(mURL, kCompToURL[i].mURL);
            strcat(info, kCompToURL[i].info);
            strcat(mURL, kCompToURL[i].mURL[streamIndex]);
            strcat(info, kCompToURL[i].info[streamIndex]);
            return;
        }
    }
@@ -972,9 +996,6 @@ TEST_F(VideoDecHidlTest, DecodeTest) {
    setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused,
                        eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate);

    // disabling adaptive playback.
    omxNode->prepareForAdaptivePlayback(kPortIndexOutput, false, 1920, 1080);

    android::Vector<BufferInfo> iBuffer, oBuffer;

    // set state to idle
@@ -1015,6 +1036,139 @@ TEST_F(VideoDecHidlTest, DecodeTest) {
                            kPortIndexInput, kPortIndexOutput);
}

// Test for adaptive playback support
TEST_F(VideoDecHidlTest, AdaptivePlaybackTest) {
    description("Tests for Adaptive Playback support");
    if (disableTest) return;
    if (!(compName == avc || compName == hevc || compName == vp8 ||
          compName == vp9 || compName == mpeg2))
        return;
    android::hardware::media::omx::V1_0::Status status;
    uint32_t kPortIndexInput = 0, kPortIndexOutput = 1;
    status = setRole(omxNode, gEnv->getRole().c_str());
    ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
    OMX_PORT_PARAM_TYPE params;
    status = getParam(omxNode, OMX_IndexParamVideoInit, &params);
    if (status == ::android::hardware::media::omx::V1_0::Status::OK) {
        ASSERT_EQ(params.nPorts, 2U);
        kPortIndexInput = params.nStartPortNumber;
        kPortIndexOutput = kPortIndexInput + 1;
    }

    // set port mode
    status = omxNode->setPortMode(kPortIndexInput, portMode[0]);
    ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
    status = omxNode->setPortMode(kPortIndexOutput, portMode[1]);
    ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);

    // prepare for adaptive playback
    uint32_t adaptiveMaxWidth = 320;
    uint32_t adaptiveMaxHeight = 240;
    status = omxNode->prepareForAdaptivePlayback(
        kPortIndexOutput, true, adaptiveMaxWidth, adaptiveMaxHeight);
    if (strncmp(gEnv->getComponent().c_str(), "OMX.google.", 11) == 0) {
        // SoftOMX Decoders donot support graphic buffer modes. So for them
        // support for adaptive play back is mandatory in Byte Buffer mode
        ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
    } else {
        return;
    }

    // TODO: Handle this better !!!
    // Without the knowledge of the maximum resolution of the frame to be
    // decoded it is not possible to choose the size of the input buffer.
    // The value below is based on the info. files of clips in res folder.
    status = setPortBufferSize(omxNode, kPortIndexInput, 482304);
    ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);

    // set Port Params
    uint32_t nFrameWidth, nFrameHeight, xFramerate;
    getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, &nFrameHeight,
                        &xFramerate);
    // get default color format
    OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatUnused;
    getDefaultColorFormat(omxNode, kPortIndexOutput, portMode[1],
                          &eColorFormat);
    ASSERT_NE(eColorFormat, OMX_COLOR_FormatUnused);
    status =
        setVideoPortFormat(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused,
                           eColorFormat, xFramerate);
    EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
    setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused,
                        eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate);

    android::Vector<BufferInfo> iBuffer, oBuffer;

    // set state to idle
    changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer,
                            kPortIndexInput, kPortIndexOutput, portMode);
    // set state to executing
    changeStateIdletoExecute(omxNode, observer);

    timestampDevTest = true;
    uint32_t timestampOffset = 0;
    for (uint32_t i = 0; i < STREAM_COUNT * 2; i++) {
        std::ifstream eleStream, eleInfo;
        char mURL[512], info[512];
        android::Vector<FrameData> Info;
        strcpy(mURL, gEnv->getRes().c_str());
        strcpy(info, gEnv->getRes().c_str());
        GetURLForComponent(compName, mURL, info, i % STREAM_COUNT);
        eleInfo.open(info);
        ASSERT_EQ(eleInfo.is_open(), true);
        int bytesCount = 0;
        uint32_t flags = 0;
        uint32_t timestamp = 0;
        uint32_t timestampMax = 0;
        while (1) {
            if (!(eleInfo >> bytesCount)) break;
            eleInfo >> flags;
            eleInfo >> timestamp;
            timestamp += timestampOffset;
            Info.push_back({bytesCount, flags, timestamp});
            if (timestampDevTest && (flags != OMX_BUFFERFLAG_CODECCONFIG))
                timestampUslist.push_back(timestamp);
            if (timestampMax < timestamp) timestampMax = timestamp;
        }
        timestampOffset = timestampMax;
        eleInfo.close();

        // Port Reconfiguration
        eleStream.open(mURL, std::ifstream::binary);
        ASSERT_EQ(eleStream.is_open(), true);
        decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
                      kPortIndexOutput, eleStream, &Info, 0, (int)Info.size(),
                      portMode[1], false);
        eleStream.close();

        getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth,
                            &nFrameHeight, &xFramerate);
        if ((nFrameWidth > adaptiveMaxWidth) ||
            (nFrameHeight > adaptiveMaxHeight)) {
            if (nFrameWidth > adaptiveMaxWidth) adaptiveMaxWidth = nFrameWidth;
            if (nFrameHeight > adaptiveMaxHeight)
                adaptiveMaxHeight = nFrameHeight;
            EXPECT_TRUE(portSettingsChange);
        } else {
            // In DynamicANW Buffer mode, its ok to do a complete
            // reconfiguration even if a partial reconfiguration is sufficient.
            if (portMode[1] != PortMode::DYNAMIC_ANW_BUFFER)
                EXPECT_FALSE(portSettingsChange);
        }
        portSettingsChange = false;
    }
    waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer,
                           kPortIndexInput, kPortIndexOutput, portMode[1]);
    testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, portMode,
            portReconfiguration, kPortIndexInput, kPortIndexOutput, nullptr);
    if (timestampDevTest) EXPECT_EQ(timestampUslist.empty(), true);
    // set state to idle
    changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer);
    // set state to executing
    changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer,
                            kPortIndexInput, kPortIndexOutput);
}

// end of sequence test
TEST_F(VideoDecHidlTest, EOSTest_M) {
    description("Test End of stream monkeying");
+37 KiB

File added.

No diff preview for this file type.

+62 −0
Original line number Diff line number Diff line
28 128 0
10 128 0
4780 32 33333
960 0 100000
480 0 66666
246 0 50000
264 0 83333
1160 0 166666
404 0 133333
237 0 116666
193 0 150000
936 0 233333
384 0 200000
199 0 183333
275 0 216666
1086 0 300000
520 0 266666
301 0 250000
270 0 283333
1232 0 366666
559 0 333333
287 0 316666
274 0 350000
1084 0 433333
485 0 400000
307 0 383333
284 0 416666
1052 0 500000
504 0 466666
298 0 450000
327 0 483333
1189 0 566666
358 0 533333
172 0 516666
185 0 550000
1115 0 633333
463 0 600000
218 0 583333
255 0 616666
1155 0 700000
622 0 666666
356 0 650000
341 0 683333
1240 0 766666
610 0 733333
341 0 716666
380 0 750000
1326 0 833333
620 0 800000
396 0 783333
353 0 816666
1196 0 900000
623 0 866666
375 0 850000
362 0 883333
1192 0 966666
654 0 933333
359 0 916666
352 0 950000
828 0 1016666
436 0 983333
401 0 1000000
+20 KiB

File added.

No diff preview for this file type.

Loading