Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H264EncoderNvCodec Fix #288

Closed
wants to merge 7 commits into from
181 changes: 88 additions & 93 deletions base/test/h264Encodernvcodec_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

BOOST_AUTO_TEST_SUITE(h264encodernvcodec_tests)



BOOST_AUTO_TEST_CASE(yuv420_640x360,
* utf::precondition(if_h264_encoder_supported()))
{
Expand Down Expand Up @@ -55,20 +53,23 @@ BOOST_AUTO_TEST_CASE(yuv420_640x360,
auto fileWriter = boost::shared_ptr<Module>(new FileWriterModule(FileWriterModuleProps("./data/testOutput/h264images/Raw_YUV420_640x360????.h264")));
encoder->setNext(fileWriter);

BOOST_TEST(fileReader->init());
BOOST_TEST(copy->init());
BOOST_TEST(encoder->init());
BOOST_TEST(fileWriter->init());

fileReader->play(true);
boost::shared_ptr<PipeLine> p;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the test here

p = boost::shared_ptr<PipeLine>(new PipeLine("test"));
p->appendModule(fileReader);

for (auto i = 0; i < 43; i++)
if (!p->init())
{
fileReader->step();
copy->step();
encoder->step();
fileWriter->step();
}
throw AIPException(AIP_FATAL, "Engine Pipeline init failed. Check IPEngine Logs for more details.");
}

p->run_all_threaded();

Test_Utils::sleep_for_seconds(20);

p->stop();
p->term();
p->wait_for_all();
p.reset();
}

BOOST_AUTO_TEST_CASE(yuv420_640x360_resize,
Expand Down Expand Up @@ -107,26 +108,24 @@ BOOST_AUTO_TEST_CASE(yuv420_640x360_resize,
auto fileWriter = boost::shared_ptr<Module>(new FileWriterModule(FileWriterModuleProps(outFile[0],true)));
encoder->setNext(fileWriter);

BOOST_TEST(fileReader->init());
BOOST_TEST(copy->init());
BOOST_TEST(resize->init());
BOOST_TEST(sync->init());
BOOST_TEST(encoder->init());
BOOST_TEST(fileWriter->init());

fileReader->play(true);

boost::shared_ptr<PipeLine> p;
p = boost::shared_ptr<PipeLine>(new PipeLine("test"));
p->appendModule(fileReader);

for (auto i = 0; i < 42; i++)
if (!p->init())
{
fileReader->step();
copy->step();
resize->step();
sync->step();
encoder->step();
fileWriter->step();
throw AIPException(AIP_FATAL, "Engine Pipeline init failed. Check IPEngine Logs for more details.");
}

p->run_all_threaded();

Test_Utils::sleep_for_seconds(20);

p->stop();
p->term();
p->wait_for_all();
p.reset();

Test_Utils::saveOrCompare(outFile[0], 0);
}

Expand Down Expand Up @@ -164,24 +163,24 @@ BOOST_AUTO_TEST_CASE(yuv420_640x360_sync,
auto fileWriter = boost::shared_ptr<Module>(new FileWriterModule(FileWriterModuleProps(outFile[0],true)));
encoder->setNext(fileWriter);

BOOST_TEST(fileReader->init());
BOOST_TEST(copy->init());
BOOST_TEST(sync->init());
BOOST_TEST(encoder->init());
BOOST_TEST(fileWriter->init());

fileReader->play(true);
boost::shared_ptr<PipeLine> p;
p = boost::shared_ptr<PipeLine>(new PipeLine("test"));
p->appendModule(fileReader);


for (auto i = 0; i < 42; i++)
if (!p->init())
{
fileReader->step();
copy->step();
sync->step();
encoder->step();
fileWriter->step();
throw AIPException(AIP_FATAL, "Engine Pipeline init failed. Check IPEngine Logs for more details.");
}

p->run_all_threaded();

Test_Utils::sleep_for_seconds(20);

p->stop();
p->term();
p->wait_for_all();
p.reset();

Test_Utils::saveOrCompare(outFile[0], 0);

}
Expand Down Expand Up @@ -220,22 +219,24 @@ BOOST_AUTO_TEST_CASE(overlay_1920x960_BGRA,
auto fileWriter = boost::shared_ptr<Module>(new FileWriterModule(FileWriterModuleProps(outFile[0],true)));
encoder->setNext(fileWriter);

BOOST_TEST(fileReader->init());
BOOST_TEST(copy->init());
BOOST_TEST(encoder->init());
BOOST_TEST(fileWriter->init());
boost::shared_ptr<PipeLine> p;
p = boost::shared_ptr<PipeLine>(new PipeLine("test"));
p->appendModule(fileReader);

fileReader->play(true);


for (auto i = 0; i < 42; i++)
if (!p->init())
{
fileReader->step();
copy->step();
encoder->step();
fileWriter->step();
throw AIPException(AIP_FATAL, "Engine Pipeline init failed. Check IPEngine Logs for more details.");
}

p->run_all_threaded();

Test_Utils::sleep_for_seconds(20);

p->stop();
p->term();
p->wait_for_all();
p.reset();

Test_Utils::saveOrCompare(outFile[0], 0);

}
Expand Down Expand Up @@ -278,26 +279,24 @@ BOOST_AUTO_TEST_CASE(mono_1920x960,
auto fileWriter = boost::shared_ptr<Module>(new FileWriterModule(FileWriterModuleProps(outFile[0],true)));
encoder->setNext(fileWriter);

BOOST_TEST(fileReader->init());
BOOST_TEST(copy->init());
BOOST_TEST(cc->init());
BOOST_TEST(sync->init());
BOOST_TEST(encoder->init());
BOOST_TEST(fileWriter->init());

fileReader->play(true);
boost::shared_ptr<PipeLine> p;
p = boost::shared_ptr<PipeLine>(new PipeLine("test"));
p->appendModule(fileReader);


for (auto i = 0; i < 42; i++)
if (!p->init())
{
fileReader->step();
copy->step();
cc->step();
sync->step();
encoder->step();
fileWriter->step();
throw AIPException(AIP_FATAL, "Engine Pipeline init failed. Check IPEngine Logs for more details.");
}

p->run_all_threaded();

Test_Utils::sleep_for_seconds(20);

p->stop();
p->term();
p->wait_for_all();
p.reset();

Test_Utils::saveOrCompare(outFile[0], 0);
}

Expand Down Expand Up @@ -335,29 +334,24 @@ void mono_1920x960_ext_sink_()
auto sink = boost::shared_ptr<ExternalSinkModule>(new ExternalSinkModule());
encoder->setNext(sink);

BOOST_TEST(fileReader->init());
BOOST_TEST(copy->init());
BOOST_TEST(cc->init());
BOOST_TEST(sync->init());
BOOST_TEST(encoder->init());
BOOST_TEST(sink->init());

fileReader->play(true);

frame_sp frame;
boost::shared_ptr<PipeLine> p;
p = boost::shared_ptr<PipeLine>(new PipeLine("test"));
p->appendModule(fileReader);

for (auto i = 0; i < 5; i++)
if (!p->init())
{
fileReader->step();
copy->step();
cc->step();
sync->step();
encoder->step();
auto frames = sink->pop();
BOOST_TEST(frames.size() == 1);
frame = frames.cbegin()->second;
throw AIPException(AIP_FATAL, "Engine Pipeline init failed. Check IPEngine Logs for more details.");
}

p->run_all_threaded();

Test_Utils::sleep_for_seconds(20);

p->stop();
p->term();
p->wait_for_all();
p.reset();


}

Expand Down Expand Up @@ -397,7 +391,7 @@ BOOST_AUTO_TEST_CASE(yuv420_640x360_pipeline, *boost::unit_test::disabled())
Logger::setLogLevel(boost::log::trivial::severity_level::info);
p.run_all_threaded();

boost::this_thread::sleep_for(boost::chrono::seconds(10));
boost::this_thread::sleep_for(boost::chrono::seconds(20));
Logger::setLogLevel(boost::log::trivial::severity_level::error);
p.stop();
p.term();
Expand Down Expand Up @@ -445,7 +439,8 @@ BOOST_AUTO_TEST_CASE(mono_1920x960_pipeline, *boost::unit_test::disabled())
Logger::setLogLevel(boost::log::trivial::severity_level::info);
p.run_all_threaded();

boost::this_thread::sleep_for(boost::chrono::seconds(10));
boost::this_thread::sleep_for(boost::chrono::seconds(20));

Logger::setLogLevel(boost::log::trivial::severity_level::error);

p.stop();
Expand Down
49 changes: 14 additions & 35 deletions base/test/h264decoder_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,43 +181,22 @@ BOOST_AUTO_TEST_CASE(encoder_to_decoder, *utf::precondition(if_h264_encoder_supp

fileReader->play(true);

BOOST_TEST(fileReader->init());
BOOST_TEST(copy->init());
BOOST_TEST(encoder->init());
BOOST_TEST(Decoder->init());
BOOST_TEST(m2->init());

int index = 0;
for (auto i = 0; i <= 43; i++)
{
boost::shared_ptr<PipeLine> p;
p = boost::shared_ptr<PipeLine>(new PipeLine("test"));

p->appendModule(fileReader);

fileReader->step();
copy->step();
encoder->step();
Decoder->step();

if (i >= 3)
{
auto frames = m2->pop();
BOOST_TEST(frames.size() == 1);
auto outputFrame = frames.cbegin()->second;
BOOST_TEST(outputFrame->getMetadata()->getFrameType() == FrameMetadata::RAW_IMAGE_PLANAR);

std::string fileName;

if (index <= 9)
{
fileName = "/data/Raw_YUV420_640x360/Image00" + std::to_string(index) + "_YUV420.raw";
}
else
{
fileName = "/data/Raw_YUV420_640x360/Image0" + std::to_string(index) + "_YUV420.raw";
}

Test_Utils::saveOrCompare(fileName.c_str(), const_cast<const uint8_t*>(static_cast<uint8_t*>(outputFrame->data())), outputFrame->size(), 0);
index++;
}
if (!p->init())
{
throw AIPException(AIP_FATAL, "Engine Pipeline init failed. Check IPEngine Logs for more details.");
}

p->run_all_threaded();
Test_Utils::sleep_for_seconds(10);
p->stop();
p->term();
p->wait_for_all();
p.reset();
}

BOOST_AUTO_TEST_CASE(mp4reader_to_decoder_extSink, *utf::precondition(if_h264_encoder_supported()))
Expand Down
Loading