mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
Merge pull request #26849 from sturkmen72:apng-writeanimation
APNG encoding optimization #26849 related #26840 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -101,7 +101,7 @@ PERF_TEST_P(Encode, bgr, testing::ValuesIn(exts))
|
||||
|
||||
TEST_CYCLE() imencode(GetParam(), src, buf);
|
||||
|
||||
std::cout << "Encoded buffer size: " << buf.size()
|
||||
std::cout << " Encoded buffer size: " << buf.size()
|
||||
<< " bytes, Compression ratio: " << std::fixed << std::setprecision(2)
|
||||
<< (static_cast<double>(buf.size()) / (src.total() * src.channels())) * 100.0 << "%" << std::endl;
|
||||
|
||||
@@ -120,7 +120,7 @@ PERF_TEST_P(Encode, multi, testing::ValuesIn(exts_multi))
|
||||
|
||||
TEST_CYCLE() imencode(GetParam(), vec, buf);
|
||||
|
||||
std::cout << "Encoded buffer size: " << buf.size()
|
||||
std::cout << " Encoded buffer size: " << buf.size()
|
||||
<< " bytes, Compression ratio: " << std::fixed << std::setprecision(2)
|
||||
<< (static_cast<double>(buf.size()) / (vec[0].total() * vec[0].channels())) * 100.0 << "%" << std::endl;
|
||||
|
||||
|
||||
@@ -11,7 +11,10 @@ namespace opencv_test
|
||||
|
||||
using namespace perf;
|
||||
|
||||
typedef perf::TestBaseWithParam<std::string> PNG;
|
||||
CV_ENUM(PNGStrategy, IMWRITE_PNG_STRATEGY_DEFAULT, IMWRITE_PNG_STRATEGY_FILTERED, IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY, IMWRITE_PNG_STRATEGY_RLE, IMWRITE_PNG_STRATEGY_FIXED);
|
||||
CV_ENUM(PNGFilters, IMWRITE_PNG_FILTER_NONE, IMWRITE_PNG_FILTER_SUB, IMWRITE_PNG_FILTER_UP, IMWRITE_PNG_FILTER_AVG, IMWRITE_PNG_FILTER_PAETH, IMWRITE_PNG_FAST_FILTERS, IMWRITE_PNG_ALL_FILTERS);
|
||||
|
||||
typedef perf::TestBaseWithParam<testing::tuple<PNGStrategy, PNGFilters, int>> PNG;
|
||||
|
||||
PERF_TEST(PNG, decode)
|
||||
{
|
||||
@@ -58,6 +61,30 @@ PERF_TEST(PNG, encode)
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P(PNG, params,
|
||||
testing::Combine(
|
||||
testing::Values(IMWRITE_PNG_STRATEGY_DEFAULT, IMWRITE_PNG_STRATEGY_FILTERED, IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY, IMWRITE_PNG_STRATEGY_RLE, IMWRITE_PNG_STRATEGY_FIXED),
|
||||
testing::Values(IMWRITE_PNG_FILTER_NONE, IMWRITE_PNG_FILTER_SUB, IMWRITE_PNG_FILTER_UP, IMWRITE_PNG_FILTER_AVG, IMWRITE_PNG_FILTER_PAETH, IMWRITE_PNG_FAST_FILTERS, IMWRITE_PNG_ALL_FILTERS),
|
||||
testing::Values(1, 6)))
|
||||
{
|
||||
String filename = getDataPath("perf/1920x1080.png");
|
||||
const int strategy = get<0>(GetParam());
|
||||
const int filter = get<1>(GetParam());
|
||||
const int level = get<2>(GetParam());
|
||||
|
||||
Mat src = imread(filename);
|
||||
EXPECT_FALSE(src.empty()) << "Cannot open test image perf/1920x1080.png";
|
||||
vector<uchar> buf;
|
||||
|
||||
TEST_CYCLE() imencode(".png", src, buf, { IMWRITE_PNG_COMPRESSION, level, IMWRITE_PNG_STRATEGY, strategy, IMWRITE_PNG_FILTER, filter });
|
||||
|
||||
std::cout << " Encoded buffer size: " << buf.size()
|
||||
<< " bytes, Compression ratio: " << std::fixed << std::setprecision(2)
|
||||
<< (static_cast<double>(buf.size()) / (src.total() * src.channels())) * 100.0 << "%" << std::endl;
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
#endif // HAVE_PNG
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user