mirror of
https://github.com/opencv/opencv.git
synced 2024-11-29 05:29:54 +08:00
Merge pull request #18210 from VadimLevin:dev/vlevin/openjpeg-reduce-filesize
This commit is contained in:
commit
2e6e9c14b5
@ -327,12 +327,14 @@ opj_cparameters setupEncoderParameters(const std::vector<int>& params)
|
||||
{
|
||||
opj_cparameters parameters;
|
||||
opj_set_default_encoder_parameters(¶meters);
|
||||
bool rate_is_specified = false;
|
||||
for (size_t i = 0; i < params.size(); i += 2)
|
||||
{
|
||||
switch (params[i])
|
||||
{
|
||||
case cv::IMWRITE_JPEG2000_COMPRESSION_X1000:
|
||||
parameters.tcp_rates[0] = 1000.f / std::min(std::max(params[i + 1], 1), 1000);
|
||||
rate_is_specified = true;
|
||||
break;
|
||||
default:
|
||||
CV_LOG_WARNING(NULL, "OpenJPEG2000(encoder): skip unsupported parameter: " << params[i]);
|
||||
@ -341,6 +343,10 @@ opj_cparameters setupEncoderParameters(const std::vector<int>& params)
|
||||
}
|
||||
parameters.tcp_numlayers = 1;
|
||||
parameters.cp_disto_alloc = 1;
|
||||
if (!rate_is_specified)
|
||||
{
|
||||
parameters.tcp_rates[0] = 4;
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
|
||||
|
@ -228,9 +228,12 @@ TEST_P(Imgcodecs_Image, read_write_BGR)
|
||||
double psnrThreshold = 100;
|
||||
if (ext == "jpg")
|
||||
psnrThreshold = 32;
|
||||
#ifdef HAVE_JASPER
|
||||
#if defined(HAVE_JASPER)
|
||||
if (ext == "jp2")
|
||||
psnrThreshold = 95;
|
||||
#elif defined(HAVE_OPENJPEG)
|
||||
if (ext == "jp2")
|
||||
psnrThreshold = 35;
|
||||
#endif
|
||||
|
||||
Mat image = generateTestImageBGR();
|
||||
@ -254,9 +257,12 @@ TEST_P(Imgcodecs_Image, read_write_GRAYSCALE)
|
||||
double psnrThreshold = 100;
|
||||
if (ext == "jpg")
|
||||
psnrThreshold = 40;
|
||||
#ifdef HAVE_JASPER
|
||||
#if defined(HAVE_JASPER)
|
||||
if (ext == "jp2")
|
||||
psnrThreshold = 70;
|
||||
#elif defined(HAVE_OPENJPEG)
|
||||
if (ext == "jp2")
|
||||
psnrThreshold = 35;
|
||||
#endif
|
||||
|
||||
Mat image = generateTestImageGrayscale();
|
||||
|
Loading…
Reference in New Issue
Block a user