mirror of
https://github.com/opencv/opencv.git
synced 2026-07-27 06:13:05 +04:00
65cb3fd86c
libpng upgrade to 1.6.45 and cICP metadata support for PNG imwrite #27741 ### Pull Request Readiness Checklist resolves #24185 libpng docs: https://www.w3.org/TR/png-3/#cICP-chunk similar code from ffmpeg: https://github.com/FFmpeg/FFmpeg/blob/a700f0f72d1f073e5adcfbb16f4633850b0ef51c/libavcodec/pngenc.c#L452-L456 So issue #24185 can be solved by replacing `cv.imwrite` in user's code to `cv.imwriteWithMetadata`: ```python cv.imwriteWithMetadata("frame.png", frame, [cv.IMAGE_METADATA_CICP], np.array([[9, 18, 0, 1]], np.uint8)) ``` ``` $ exiftool /home/d.kurtaev/opencv_build/frames_pr/image_38.png ExifTool Version Number : 12.76 File Name : image_38.png Directory : /home/d.kurtaev/opencv_build/frames_pr File Size : 3.8 MB File Modification Date/Time : 2025:09:02 20:48:22+03:00 File Access Date/Time : 2025:09:02 20:48:22+03:00 File Inode Change Date/Time : 2025:09:02 20:48:22+03:00 File Permissions : -rw-r--r-- File Type : PNG File Type Extension : png MIME Type : image/png Image Width : 1080 Image Height : 1920 Bit Depth : 8 Color Type : RGB Compression : Deflate/Inflate Filter : Adaptive Interlace : Noninterlaced Color Primaries : BT.2020, BT.2100 Transfer Characteristics : BT.2100 HLG, ARIB STD-B67 Matrix Coefficients : Identity matrix Video Full Range Flag : 1 Image Size : 1080x1920 Megapixels : 2.1 ``` 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. - [x] The feature is well documented and sample code can be built with the project CMake
52 lines
1.8 KiB
C
52 lines
1.8 KiB
C
/* intel_init.c - SSE2 optimized filter functions
|
|
*
|
|
* Copyright (c) 2018 Cosmin Truta
|
|
* Copyright (c) 2016-2017 Glenn Randers-Pehrson
|
|
* Written by Mike Klein and Matt Sarett, Google, Inc.
|
|
* Derived from arm/arm_init.c
|
|
*
|
|
* This code is released under the libpng license.
|
|
* For conditions of distribution and use, see the disclaimer
|
|
* and license in png.h
|
|
*/
|
|
|
|
#include "../pngpriv.h"
|
|
|
|
#ifdef PNG_READ_SUPPORTED
|
|
#if PNG_INTEL_SSE_IMPLEMENTATION > 0
|
|
|
|
void
|
|
png_init_filter_functions_sse2(png_structp pp, unsigned int bpp)
|
|
{
|
|
/* The techniques used to implement each of these filters in SSE operate on
|
|
* one pixel at a time.
|
|
* So they generally speed up 3bpp images about 3x, 4bpp images about 4x.
|
|
* They can scale up to 6 and 8 bpp images and down to 2 bpp images,
|
|
* but they'd not likely have any benefit for 1bpp images.
|
|
* Most of these can be implemented using only MMX and 64-bit registers,
|
|
* but they end up a bit slower than using the equally-ubiquitous SSE2.
|
|
*/
|
|
png_debug(1, "in png_init_filter_functions_sse2");
|
|
if (bpp == 3)
|
|
{
|
|
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_sse2;
|
|
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_sse2;
|
|
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
|
|
png_read_filter_row_paeth3_sse2;
|
|
}
|
|
else if (bpp == 4)
|
|
{
|
|
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_sse2;
|
|
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_sse2;
|
|
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
|
|
png_read_filter_row_paeth4_sse2;
|
|
}
|
|
|
|
/* No need optimize PNG_FILTER_VALUE_UP. The compiler should
|
|
* autovectorize.
|
|
*/
|
|
}
|
|
|
|
#endif /* PNG_INTEL_SSE_IMPLEMENTATION > 0 */
|
|
#endif /* PNG_READ_SUPPORTED */
|