Loading media/tests/benchmark/src/native/common/BenchmarkCommon.h +1 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #ifndef __BENCHMARK_COMMON_H__ #define __BENCHMARK_COMMON_H__ #include <sys/stat.h> #include <inttypes.h> #include <mutex> #include <queue> Loading media/tests/benchmark/src/native/muxer/Muxer.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ int32_t Muxer::initMuxer(int32_t fd, MUXER_OUTPUT_T outputFormat) { int64_t sTime = mStats->getCurTime(); mMuxer = AMediaMuxer_new(fd, (OutputFormat)outputFormat); if (!mMuxer) { cout << "[ WARN ] Test Skipped. Unable to create muxer \n"; ALOGV("Unable to create muxer"); return AMEDIA_ERROR_INVALID_OBJECT; } /* Loading @@ -38,7 +38,7 @@ int32_t Muxer::initMuxer(int32_t fd, MUXER_OUTPUT_T outputFormat) { */ ssize_t index = AMediaMuxer_addTrack(mMuxer, mFormat); if (index < 0) { cout << "[ WARN ] Test Skipped. Format not supported \n"; ALOGV("Format not supported"); return index; } AMediaMuxer_start(mMuxer); Loading media/tests/benchmark/tests/C2DecoderTest.cpp +56 −84 Original line number Diff line number Diff line Loading @@ -29,82 +29,64 @@ static BenchmarkTestEnvironment *gEnv = nullptr; class C2DecoderTest : public ::testing::TestWithParam<pair<string, string>> { public: C2DecoderTest() : mDecoder(nullptr), disableTest(false) { setupC2DecoderTest(); } C2DecoderTest() : mDecoder(nullptr) {} ~C2DecoderTest() { if (!mCodecList.empty()) { mCodecList.clear(); } if (mDecoder) { delete mDecoder; mDecoder = nullptr; } } virtual void SetUp() override { setupC2DecoderTest(); } void setupC2DecoderTest(); vector<string> mCodecList; C2Decoder *mDecoder; bool disableTest; }; void C2DecoderTest::setupC2DecoderTest() { mDecoder = new C2Decoder(); if (!mDecoder) { cout << "[ WARN ] Test Skipped. C2Decoder creation failed\n"; disableTest = true; return; } ASSERT_NE(mDecoder, nullptr) << "C2Decoder creation failed"; int32_t status = mDecoder->setupCodec2(); if (status != 0) { cout << "[ WARN ] Test Skipped. Codec2 setup failed \n"; disableTest = true; return; } ASSERT_EQ(status, 0) << "Codec2 setup failed"; mCodecList = mDecoder->getSupportedComponentList(false /* isEncoder*/); if (!mCodecList.size()) { cout << "[ WARN ] Test Skipped. Codec2 client didn't recognise any component \n"; disableTest = true; return; } ASSERT_GT(mCodecList.size(), 0) << "Codec2 client didn't recognise any component"; } TEST_P(C2DecoderTest, Codec2Decode) { if (disableTest) return; ALOGV("Decode the samples given by extractor using codec2"); string inputFile = gEnv->getRes() + GetParam().first; FILE *inputFp = fopen(inputFile.c_str(), "rb"); if (!inputFp) { cout << "[ WARN ] Test Skipped. Unable to open input file" << inputFile << " for reading \n"; return; } ASSERT_NE(inputFp, nullptr) << "Unable to open " << inputFile << " file for reading"; Extractor *extractor = new Extractor(); if (!extractor) { cout << "[ WARN ] Test Skipped. Extractor creation failed \n"; return; } ASSERT_NE(extractor, nullptr) << "Extractor creation failed"; // Read file properties fseek(inputFp, 0, SEEK_END); size_t fileSize = ftell(inputFp); fseek(inputFp, 0, SEEK_SET); struct stat buf; stat(inputFile.c_str(), &buf); size_t fileSize = buf.st_size; int32_t fd = fileno(inputFp); if (fileSize > kMaxBufferSize) { cout << "[ WARN ] Test Skipped. Input file size is greater than the threshold memory " "dedicated to the test \n"; } ASSERT_LE(fileSize, kMaxBufferSize) << "Input file size is greater than the threshold memory dedicated to the test"; int32_t trackCount = extractor->initExtractor(fd, fileSize); if (trackCount <= 0) { cout << "[ WARN ] Test Skipped. initExtractor failed\n"; return; } ASSERT_GT(trackCount, 0) << "initExtractor failed"; for (int32_t curTrack = 0; curTrack < trackCount; curTrack++) { int32_t status = extractor->setupTrackFormat(curTrack); if (status != 0) { cout << "[ WARN ] Test Skipped. Track Format invalid \n"; return; } ASSERT_EQ(status, 0) << "Track Format invalid"; uint8_t *inputBuffer = (uint8_t *)malloc(fileSize); if (!inputBuffer) { cout << "[ WARN ] Test Skipped. Insufficient memory \n"; return; } ASSERT_NE(inputBuffer, nullptr) << "Insufficient memory"; vector<AMediaCodecBufferInfo> frameInfo; AMediaCodecBufferInfo info; Loading @@ -116,11 +98,8 @@ TEST_P(C2DecoderTest, Codec2Decode) { void *csdBuffer = extractor->getCSDSample(info, idx); if (!csdBuffer || !info.size) break; // copy the meta data and buffer to be passed to decoder if (inputBufferOffset + info.size > fileSize) { cout << "[ WARN ] Test Skipped. Memory allocated not sufficient\n"; free(inputBuffer); return; } ASSERT_LE(inputBufferOffset + info.size, fileSize) << "Memory allocated not sufficient"; memcpy(inputBuffer + inputBufferOffset, csdBuffer, info.size); frameInfo.push_back(info); inputBufferOffset += info.size; Loading @@ -132,11 +111,8 @@ TEST_P(C2DecoderTest, Codec2Decode) { status = extractor->getFrameSample(info); if (status || !info.size) break; // copy the meta data and buffer to be passed to decoder if (inputBufferOffset + info.size > fileSize) { cout << "[ WARN ] Test Skipped. Memory allocated not sufficient\n"; free(inputBuffer); return; } ASSERT_LE(inputBufferOffset + info.size, fileSize) << "Memory allocated not sufficient"; memcpy(inputBuffer + inputBufferOffset, extractor->getFrameBuf(), info.size); frameInfo.push_back(info); inputBufferOffset += info.size; Loading @@ -148,21 +124,18 @@ TEST_P(C2DecoderTest, Codec2Decode) { if (codecName.find(GetParam().second) != string::npos && codecName.find("secure") == string::npos) { status = mDecoder->createCodec2Component(codecName, format); if (status != 0) { cout << "[ WARN ] Test Skipped. Create component failed for " << codecName << "\n"; continue; } ASSERT_EQ(status, 0) << "Create component failed for " << codecName; // Send the inputs to C2 Decoder and wait till all buffers are returned. mDecoder->decodeFrames(inputBuffer, frameInfo); status = mDecoder->decodeFrames(inputBuffer, frameInfo); ASSERT_EQ(status, 0) << "Decoder failed for " << codecName; mDecoder->waitOnInputConsumption(); if (!mDecoder->mEos) { cout << "[ WARN ] Test Failed. Didn't receive EOS \n"; } ASSERT_TRUE(mDecoder->mEos) << "Test Failed. Didn't receive EOS \n"; mDecoder->deInitCodec(); int64_t durationUs = extractor->getClipDuration(); cout << "codec: " << codecName << endl; ALOGV("codec : %s", codecName.c_str()); mDecoder->dumpStatistics(GetParam().first, durationUs); mDecoder->resetDecoder(); } Loading @@ -172,6 +145,7 @@ TEST_P(C2DecoderTest, Codec2Decode) { extractor->deInitExtractor(); delete extractor; delete mDecoder; mDecoder = nullptr; } } Loading @@ -179,8 +153,7 @@ TEST_P(C2DecoderTest, Codec2Decode) { // Add wav files INSTANTIATE_TEST_SUITE_P( AudioDecoderTest, C2DecoderTest, ::testing::Values( make_pair("bbb_44100hz_2ch_128kbps_aac_30sec.mp4", "aac"), ::testing::Values(make_pair("bbb_44100hz_2ch_128kbps_aac_30sec.mp4", "aac"), make_pair("bbb_44100hz_2ch_128kbps_mp3_30sec.mp3", "mp3"), make_pair("bbb_8000hz_1ch_8kbps_amrnb_30sec.3gp", "amrnb"), make_pair("bbb_16000hz_1ch_9kbps_amrwb_30sec.3gp", "amrnb"), Loading @@ -190,8 +163,7 @@ INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P( VideoDecoderTest, C2DecoderTest, ::testing::Values( make_pair("crowd_1920x1080_25fps_4000kbps_vp9.webm", "vp9"), ::testing::Values(make_pair("crowd_1920x1080_25fps_4000kbps_vp9.webm", "vp9"), make_pair("crowd_1920x1080_25fps_4000kbps_vp8.webm", "vp8"), make_pair("crowd_1920x1080_25fps_4000kbps_av1.webm", "av1"), make_pair("crowd_1920x1080_25fps_7300kbps_mpeg2.mp4", "mpeg2"), Loading media/tests/benchmark/tests/C2EncoderTest.cpp +26 −16 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ //#define LOG_NDEBUG 0 #define LOG_TAG "C2EncoderTest" #include <sys/stat.h> #include <fstream> #include <iostream> #include <limits> Loading @@ -30,7 +29,19 @@ static BenchmarkTestEnvironment *gEnv = nullptr; class C2EncoderTest : public ::testing::TestWithParam<pair<string, string>> { public: C2EncoderTest() : mEncoder(nullptr) { setupC2EncoderTest(); } C2EncoderTest() : mEncoder(nullptr) {} ~C2EncoderTest() { if (!mCodecList.empty()) { mCodecList.clear(); } if (mEncoder) { delete mEncoder; mEncoder = nullptr; } } virtual void SetUp() override { setupC2EncoderTest(); } void setupC2EncoderTest(); Loading Loading @@ -128,7 +139,7 @@ TEST_P(C2EncoderTest, Codec2Encode) { mEncoder->deInitCodec(); int64_t durationUs = extractor->getClipDuration(); cout << "codec: " << codecName << endl; ALOGV("codec : %s", codecName.c_str()); mEncoder->dumpStatistics(GetParam().first, durationUs); mEncoder->resetEncoder(); } Loading @@ -143,12 +154,12 @@ TEST_P(C2EncoderTest, Codec2Encode) { extractor->deInitExtractor(); delete decoder; delete mEncoder; mEncoder = nullptr; } INSTANTIATE_TEST_SUITE_P( AudioEncoderTest, C2EncoderTest, ::testing::Values( make_pair("bbb_44100hz_2ch_128kbps_aac_30sec.mp4", "aac"), ::testing::Values(make_pair("bbb_44100hz_2ch_128kbps_aac_30sec.mp4", "aac"), make_pair("bbb_8000hz_1ch_8kbps_amrnb_30sec.3gp", "amrnb"), make_pair("bbb_16000hz_1ch_9kbps_amrwb_30sec.3gp", "amrwb"), make_pair("bbb_44100hz_2ch_600kbps_flac_30sec.mp4", "flac"), Loading @@ -156,8 +167,7 @@ INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P( VideoEncoderTest, C2EncoderTest, ::testing::Values( make_pair("crowd_1920x1080_25fps_4000kbps_vp9.webm", "vp9"), ::testing::Values(make_pair("crowd_1920x1080_25fps_4000kbps_vp9.webm", "vp9"), make_pair("crowd_1920x1080_25fps_4000kbps_vp8.webm", "vp8"), make_pair("crowd_176x144_25fps_6000kbps_mpeg4.mp4", "mpeg4"), make_pair("crowd_176x144_25fps_6000kbps_h263.3gp", "h263"), Loading media/tests/benchmark/tests/DecoderTest.cpp +19 −35 Original line number Diff line number Diff line Loading @@ -21,8 +21,8 @@ #include <iostream> #include <limits> #include "Decoder.h" #include "BenchmarkTestEnvironment.h" #include "Decoder.h" static BenchmarkTestEnvironment *gEnv = nullptr; Loading @@ -34,41 +34,30 @@ TEST_P(DecoderTest, Decode) { string inputFile = gEnv->getRes() + get<0>(params); FILE *inputFp = fopen(inputFile.c_str(), "rb"); if (!inputFp) { cout << "[ WARN ] Test Skipped. Unable to open input file for reading \n"; return; } ASSERT_NE(inputFp, nullptr) << "Unable to open " << inputFile << " file for reading"; Decoder *decoder = new Decoder(); ASSERT_NE(decoder, nullptr) << "Decoder creation failed"; Extractor *extractor = decoder->getExtractor(); if (!extractor) { cout << "[ WARN ] Test Skipped. Extractor creation failed \n"; return; } ASSERT_NE(extractor, nullptr) << "Extractor creation failed"; // Read file properties fseek(inputFp, 0, SEEK_END); size_t fileSize = ftell(inputFp); fseek(inputFp, 0, SEEK_SET); struct stat buf; stat(inputFile.c_str(), &buf); size_t fileSize = buf.st_size; int32_t fd = fileno(inputFp); int32_t trackCount = extractor->initExtractor(fd, fileSize); if (trackCount <= 0) { cout << "[ WARN ] Test Skipped. initExtractor failed\n"; return; } ASSERT_GT(trackCount, 0) << "initExtractor failed"; for (int curTrack = 0; curTrack < trackCount; curTrack++) { int32_t status = extractor->setupTrackFormat(curTrack); if (status != 0) { cout << "[ WARN ] Test Skipped. Track Format invalid \n"; return; } ASSERT_EQ(status, 0) << "Track Format invalid"; uint8_t *inputBuffer = (uint8_t *)malloc(kMaxBufferSize); if (!inputBuffer) { cout << "[ WARN ] Test Skipped. Insufficient memory \n"; return; } ASSERT_NE(inputBuffer, nullptr) << "Insufficient memory"; vector<AMediaCodecBufferInfo> frameInfo; AMediaCodecBufferInfo info; uint32_t inputBufferOffset = 0; Loading @@ -78,11 +67,9 @@ TEST_P(DecoderTest, Decode) { status = extractor->getFrameSample(info); if (status || !info.size) break; // copy the meta data and buffer to be passed to decoder if (inputBufferOffset + info.size > kMaxBufferSize) { cout << "[ WARN ] Test Skipped. Memory allocated not sufficient\n"; free(inputBuffer); return; } ASSERT_LE(inputBufferOffset + info.size, kMaxBufferSize) << "Memory allocated not sufficient"; memcpy(inputBuffer + inputBufferOffset, extractor->getFrameBuf(), info.size); frameInfo.push_back(info); inputBufferOffset += info.size; Loading @@ -92,13 +79,10 @@ TEST_P(DecoderTest, Decode) { bool asyncMode = get<2>(params); decoder->setupDecoder(); status = decoder->decode(inputBuffer, frameInfo, codecName, asyncMode); if (status != AMEDIA_OK) { cout << "[ WARN ] Test Failed. Decode returned error " << status << endl; free(inputBuffer); return; } ASSERT_EQ(status, AMEDIA_OK) << "Decoder failed for " << codecName; decoder->deInitCodec(); cout << "codec : " << codecName << endl; ALOGV("codec : %s", codecName.c_str()); string inputReference = get<0>(params); decoder->dumpStatistics(inputReference); free(inputBuffer); Loading Loading
media/tests/benchmark/src/native/common/BenchmarkCommon.h +1 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #ifndef __BENCHMARK_COMMON_H__ #define __BENCHMARK_COMMON_H__ #include <sys/stat.h> #include <inttypes.h> #include <mutex> #include <queue> Loading
media/tests/benchmark/src/native/muxer/Muxer.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ int32_t Muxer::initMuxer(int32_t fd, MUXER_OUTPUT_T outputFormat) { int64_t sTime = mStats->getCurTime(); mMuxer = AMediaMuxer_new(fd, (OutputFormat)outputFormat); if (!mMuxer) { cout << "[ WARN ] Test Skipped. Unable to create muxer \n"; ALOGV("Unable to create muxer"); return AMEDIA_ERROR_INVALID_OBJECT; } /* Loading @@ -38,7 +38,7 @@ int32_t Muxer::initMuxer(int32_t fd, MUXER_OUTPUT_T outputFormat) { */ ssize_t index = AMediaMuxer_addTrack(mMuxer, mFormat); if (index < 0) { cout << "[ WARN ] Test Skipped. Format not supported \n"; ALOGV("Format not supported"); return index; } AMediaMuxer_start(mMuxer); Loading
media/tests/benchmark/tests/C2DecoderTest.cpp +56 −84 Original line number Diff line number Diff line Loading @@ -29,82 +29,64 @@ static BenchmarkTestEnvironment *gEnv = nullptr; class C2DecoderTest : public ::testing::TestWithParam<pair<string, string>> { public: C2DecoderTest() : mDecoder(nullptr), disableTest(false) { setupC2DecoderTest(); } C2DecoderTest() : mDecoder(nullptr) {} ~C2DecoderTest() { if (!mCodecList.empty()) { mCodecList.clear(); } if (mDecoder) { delete mDecoder; mDecoder = nullptr; } } virtual void SetUp() override { setupC2DecoderTest(); } void setupC2DecoderTest(); vector<string> mCodecList; C2Decoder *mDecoder; bool disableTest; }; void C2DecoderTest::setupC2DecoderTest() { mDecoder = new C2Decoder(); if (!mDecoder) { cout << "[ WARN ] Test Skipped. C2Decoder creation failed\n"; disableTest = true; return; } ASSERT_NE(mDecoder, nullptr) << "C2Decoder creation failed"; int32_t status = mDecoder->setupCodec2(); if (status != 0) { cout << "[ WARN ] Test Skipped. Codec2 setup failed \n"; disableTest = true; return; } ASSERT_EQ(status, 0) << "Codec2 setup failed"; mCodecList = mDecoder->getSupportedComponentList(false /* isEncoder*/); if (!mCodecList.size()) { cout << "[ WARN ] Test Skipped. Codec2 client didn't recognise any component \n"; disableTest = true; return; } ASSERT_GT(mCodecList.size(), 0) << "Codec2 client didn't recognise any component"; } TEST_P(C2DecoderTest, Codec2Decode) { if (disableTest) return; ALOGV("Decode the samples given by extractor using codec2"); string inputFile = gEnv->getRes() + GetParam().first; FILE *inputFp = fopen(inputFile.c_str(), "rb"); if (!inputFp) { cout << "[ WARN ] Test Skipped. Unable to open input file" << inputFile << " for reading \n"; return; } ASSERT_NE(inputFp, nullptr) << "Unable to open " << inputFile << " file for reading"; Extractor *extractor = new Extractor(); if (!extractor) { cout << "[ WARN ] Test Skipped. Extractor creation failed \n"; return; } ASSERT_NE(extractor, nullptr) << "Extractor creation failed"; // Read file properties fseek(inputFp, 0, SEEK_END); size_t fileSize = ftell(inputFp); fseek(inputFp, 0, SEEK_SET); struct stat buf; stat(inputFile.c_str(), &buf); size_t fileSize = buf.st_size; int32_t fd = fileno(inputFp); if (fileSize > kMaxBufferSize) { cout << "[ WARN ] Test Skipped. Input file size is greater than the threshold memory " "dedicated to the test \n"; } ASSERT_LE(fileSize, kMaxBufferSize) << "Input file size is greater than the threshold memory dedicated to the test"; int32_t trackCount = extractor->initExtractor(fd, fileSize); if (trackCount <= 0) { cout << "[ WARN ] Test Skipped. initExtractor failed\n"; return; } ASSERT_GT(trackCount, 0) << "initExtractor failed"; for (int32_t curTrack = 0; curTrack < trackCount; curTrack++) { int32_t status = extractor->setupTrackFormat(curTrack); if (status != 0) { cout << "[ WARN ] Test Skipped. Track Format invalid \n"; return; } ASSERT_EQ(status, 0) << "Track Format invalid"; uint8_t *inputBuffer = (uint8_t *)malloc(fileSize); if (!inputBuffer) { cout << "[ WARN ] Test Skipped. Insufficient memory \n"; return; } ASSERT_NE(inputBuffer, nullptr) << "Insufficient memory"; vector<AMediaCodecBufferInfo> frameInfo; AMediaCodecBufferInfo info; Loading @@ -116,11 +98,8 @@ TEST_P(C2DecoderTest, Codec2Decode) { void *csdBuffer = extractor->getCSDSample(info, idx); if (!csdBuffer || !info.size) break; // copy the meta data and buffer to be passed to decoder if (inputBufferOffset + info.size > fileSize) { cout << "[ WARN ] Test Skipped. Memory allocated not sufficient\n"; free(inputBuffer); return; } ASSERT_LE(inputBufferOffset + info.size, fileSize) << "Memory allocated not sufficient"; memcpy(inputBuffer + inputBufferOffset, csdBuffer, info.size); frameInfo.push_back(info); inputBufferOffset += info.size; Loading @@ -132,11 +111,8 @@ TEST_P(C2DecoderTest, Codec2Decode) { status = extractor->getFrameSample(info); if (status || !info.size) break; // copy the meta data and buffer to be passed to decoder if (inputBufferOffset + info.size > fileSize) { cout << "[ WARN ] Test Skipped. Memory allocated not sufficient\n"; free(inputBuffer); return; } ASSERT_LE(inputBufferOffset + info.size, fileSize) << "Memory allocated not sufficient"; memcpy(inputBuffer + inputBufferOffset, extractor->getFrameBuf(), info.size); frameInfo.push_back(info); inputBufferOffset += info.size; Loading @@ -148,21 +124,18 @@ TEST_P(C2DecoderTest, Codec2Decode) { if (codecName.find(GetParam().second) != string::npos && codecName.find("secure") == string::npos) { status = mDecoder->createCodec2Component(codecName, format); if (status != 0) { cout << "[ WARN ] Test Skipped. Create component failed for " << codecName << "\n"; continue; } ASSERT_EQ(status, 0) << "Create component failed for " << codecName; // Send the inputs to C2 Decoder and wait till all buffers are returned. mDecoder->decodeFrames(inputBuffer, frameInfo); status = mDecoder->decodeFrames(inputBuffer, frameInfo); ASSERT_EQ(status, 0) << "Decoder failed for " << codecName; mDecoder->waitOnInputConsumption(); if (!mDecoder->mEos) { cout << "[ WARN ] Test Failed. Didn't receive EOS \n"; } ASSERT_TRUE(mDecoder->mEos) << "Test Failed. Didn't receive EOS \n"; mDecoder->deInitCodec(); int64_t durationUs = extractor->getClipDuration(); cout << "codec: " << codecName << endl; ALOGV("codec : %s", codecName.c_str()); mDecoder->dumpStatistics(GetParam().first, durationUs); mDecoder->resetDecoder(); } Loading @@ -172,6 +145,7 @@ TEST_P(C2DecoderTest, Codec2Decode) { extractor->deInitExtractor(); delete extractor; delete mDecoder; mDecoder = nullptr; } } Loading @@ -179,8 +153,7 @@ TEST_P(C2DecoderTest, Codec2Decode) { // Add wav files INSTANTIATE_TEST_SUITE_P( AudioDecoderTest, C2DecoderTest, ::testing::Values( make_pair("bbb_44100hz_2ch_128kbps_aac_30sec.mp4", "aac"), ::testing::Values(make_pair("bbb_44100hz_2ch_128kbps_aac_30sec.mp4", "aac"), make_pair("bbb_44100hz_2ch_128kbps_mp3_30sec.mp3", "mp3"), make_pair("bbb_8000hz_1ch_8kbps_amrnb_30sec.3gp", "amrnb"), make_pair("bbb_16000hz_1ch_9kbps_amrwb_30sec.3gp", "amrnb"), Loading @@ -190,8 +163,7 @@ INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P( VideoDecoderTest, C2DecoderTest, ::testing::Values( make_pair("crowd_1920x1080_25fps_4000kbps_vp9.webm", "vp9"), ::testing::Values(make_pair("crowd_1920x1080_25fps_4000kbps_vp9.webm", "vp9"), make_pair("crowd_1920x1080_25fps_4000kbps_vp8.webm", "vp8"), make_pair("crowd_1920x1080_25fps_4000kbps_av1.webm", "av1"), make_pair("crowd_1920x1080_25fps_7300kbps_mpeg2.mp4", "mpeg2"), Loading
media/tests/benchmark/tests/C2EncoderTest.cpp +26 −16 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ //#define LOG_NDEBUG 0 #define LOG_TAG "C2EncoderTest" #include <sys/stat.h> #include <fstream> #include <iostream> #include <limits> Loading @@ -30,7 +29,19 @@ static BenchmarkTestEnvironment *gEnv = nullptr; class C2EncoderTest : public ::testing::TestWithParam<pair<string, string>> { public: C2EncoderTest() : mEncoder(nullptr) { setupC2EncoderTest(); } C2EncoderTest() : mEncoder(nullptr) {} ~C2EncoderTest() { if (!mCodecList.empty()) { mCodecList.clear(); } if (mEncoder) { delete mEncoder; mEncoder = nullptr; } } virtual void SetUp() override { setupC2EncoderTest(); } void setupC2EncoderTest(); Loading Loading @@ -128,7 +139,7 @@ TEST_P(C2EncoderTest, Codec2Encode) { mEncoder->deInitCodec(); int64_t durationUs = extractor->getClipDuration(); cout << "codec: " << codecName << endl; ALOGV("codec : %s", codecName.c_str()); mEncoder->dumpStatistics(GetParam().first, durationUs); mEncoder->resetEncoder(); } Loading @@ -143,12 +154,12 @@ TEST_P(C2EncoderTest, Codec2Encode) { extractor->deInitExtractor(); delete decoder; delete mEncoder; mEncoder = nullptr; } INSTANTIATE_TEST_SUITE_P( AudioEncoderTest, C2EncoderTest, ::testing::Values( make_pair("bbb_44100hz_2ch_128kbps_aac_30sec.mp4", "aac"), ::testing::Values(make_pair("bbb_44100hz_2ch_128kbps_aac_30sec.mp4", "aac"), make_pair("bbb_8000hz_1ch_8kbps_amrnb_30sec.3gp", "amrnb"), make_pair("bbb_16000hz_1ch_9kbps_amrwb_30sec.3gp", "amrwb"), make_pair("bbb_44100hz_2ch_600kbps_flac_30sec.mp4", "flac"), Loading @@ -156,8 +167,7 @@ INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P( VideoEncoderTest, C2EncoderTest, ::testing::Values( make_pair("crowd_1920x1080_25fps_4000kbps_vp9.webm", "vp9"), ::testing::Values(make_pair("crowd_1920x1080_25fps_4000kbps_vp9.webm", "vp9"), make_pair("crowd_1920x1080_25fps_4000kbps_vp8.webm", "vp8"), make_pair("crowd_176x144_25fps_6000kbps_mpeg4.mp4", "mpeg4"), make_pair("crowd_176x144_25fps_6000kbps_h263.3gp", "h263"), Loading
media/tests/benchmark/tests/DecoderTest.cpp +19 −35 Original line number Diff line number Diff line Loading @@ -21,8 +21,8 @@ #include <iostream> #include <limits> #include "Decoder.h" #include "BenchmarkTestEnvironment.h" #include "Decoder.h" static BenchmarkTestEnvironment *gEnv = nullptr; Loading @@ -34,41 +34,30 @@ TEST_P(DecoderTest, Decode) { string inputFile = gEnv->getRes() + get<0>(params); FILE *inputFp = fopen(inputFile.c_str(), "rb"); if (!inputFp) { cout << "[ WARN ] Test Skipped. Unable to open input file for reading \n"; return; } ASSERT_NE(inputFp, nullptr) << "Unable to open " << inputFile << " file for reading"; Decoder *decoder = new Decoder(); ASSERT_NE(decoder, nullptr) << "Decoder creation failed"; Extractor *extractor = decoder->getExtractor(); if (!extractor) { cout << "[ WARN ] Test Skipped. Extractor creation failed \n"; return; } ASSERT_NE(extractor, nullptr) << "Extractor creation failed"; // Read file properties fseek(inputFp, 0, SEEK_END); size_t fileSize = ftell(inputFp); fseek(inputFp, 0, SEEK_SET); struct stat buf; stat(inputFile.c_str(), &buf); size_t fileSize = buf.st_size; int32_t fd = fileno(inputFp); int32_t trackCount = extractor->initExtractor(fd, fileSize); if (trackCount <= 0) { cout << "[ WARN ] Test Skipped. initExtractor failed\n"; return; } ASSERT_GT(trackCount, 0) << "initExtractor failed"; for (int curTrack = 0; curTrack < trackCount; curTrack++) { int32_t status = extractor->setupTrackFormat(curTrack); if (status != 0) { cout << "[ WARN ] Test Skipped. Track Format invalid \n"; return; } ASSERT_EQ(status, 0) << "Track Format invalid"; uint8_t *inputBuffer = (uint8_t *)malloc(kMaxBufferSize); if (!inputBuffer) { cout << "[ WARN ] Test Skipped. Insufficient memory \n"; return; } ASSERT_NE(inputBuffer, nullptr) << "Insufficient memory"; vector<AMediaCodecBufferInfo> frameInfo; AMediaCodecBufferInfo info; uint32_t inputBufferOffset = 0; Loading @@ -78,11 +67,9 @@ TEST_P(DecoderTest, Decode) { status = extractor->getFrameSample(info); if (status || !info.size) break; // copy the meta data and buffer to be passed to decoder if (inputBufferOffset + info.size > kMaxBufferSize) { cout << "[ WARN ] Test Skipped. Memory allocated not sufficient\n"; free(inputBuffer); return; } ASSERT_LE(inputBufferOffset + info.size, kMaxBufferSize) << "Memory allocated not sufficient"; memcpy(inputBuffer + inputBufferOffset, extractor->getFrameBuf(), info.size); frameInfo.push_back(info); inputBufferOffset += info.size; Loading @@ -92,13 +79,10 @@ TEST_P(DecoderTest, Decode) { bool asyncMode = get<2>(params); decoder->setupDecoder(); status = decoder->decode(inputBuffer, frameInfo, codecName, asyncMode); if (status != AMEDIA_OK) { cout << "[ WARN ] Test Failed. Decode returned error " << status << endl; free(inputBuffer); return; } ASSERT_EQ(status, AMEDIA_OK) << "Decoder failed for " << codecName; decoder->deInitCodec(); cout << "codec : " << codecName << endl; ALOGV("codec : %s", codecName.c_str()); string inputReference = get<0>(params); decoder->dumpStatistics(inputReference); free(inputBuffer); Loading