using code example from

https://git.ffmpeg.org/gitweb/ffmpeg.git/blobdiff/f7bab37c8e66f3c77a5fbb5b5b72c10b0fb4ca5a..6f79f0971e8ccf6c7a2b8eb1dbc5b64fdd77ca0f:/libavcodec/pngenc.c

and test files from

https://littlecms.com/img/blog/check_lut.jpg

https://littlecms.com/img/blog/check_full.jpg

I think I was able to make png ffmpeg encoder to add built-in profile,
based on (randomly-choose) colorimetry.

patch itself needed to be applied with usual patch from directory just
above main cinelerra-5.1 level, and not "git am"

tar.gz not included due to 7Mb size!

Fake colorimetry I used:

========

# this codec creates a set of image files in a directory
# use an image2 file name like /dir/p%05d.png
flags2=0x80000000
colorspace=smpte2085
color_primaries=bt2020
color_trc=bt2020_12bit
color_range=jpeg


====

resulted in this exiftool output:

exiftool /dev/shm/4.png
ExifTool Version Number         : 11.11
File Name                       : 4.png
Directory                       : /dev/shm
File Size                       : 29 kB
File Modification Date/Time     : 2023:11:12 19:28:40+03:00
File Access Date/Time           : 2023:11:12 19:28:40+03:00
File Inode Change Date/Time     : 2023:11:12 19:28:40+03:00
File Permissions                : rw-r--r--
File Type                       : PNG
File Type Extension             : png
MIME Type                       : image/png
Image Width                     : 400
Image Height                    : 300
Bit Depth                       : 8
Color Type                      : RGB
Compression                     : Deflate/Inflate
Filter                          : Adaptive
Interlace                       : Noninterlaced
Pixels Per Unit X               : 1
Pixels Per Unit Y               : 1
Pixel Units                     : Unknown
Profile Name                    : icc
Profile CMM Type                : Little CMS
Profile Version                 : 4.3.0
Profile Class                   : Display Device Profile
Color Space Data                : RGB
Profile Connection Space        : XYZ
Profile Date Time               : 2023:11:12 16:28:40
Profile File Signature          : acsp
Primary Platform                : Apple Computer Inc.
CMM Flags                       : Not Embedded, Independent
Device Manufacturer             :
Device Model                    :
Device Attributes               : Reflective, Glossy, Positive, Color
Rendering Intent                : Perceptual
Connection Space Illuminant     : 0.9642 1 0.82491
Profile Creator                 : Little CMS
Profile ID                      : 0
Profile Description             : RGB built-in
Profile Copyright               : No copyright, use freely
Media White Point               : 0.9642 1 0.82491
Chromatic Adaptation            : 1.04788 0.02292 -0.05022 0.02959
0.99048 -0.01707 -0.00925 0.01508 0.75168
Red Matrix Column               : 0.67348 0.27904 -0.00194
Blue Matrix Column              : 0.12505 0.04561 0.79684
Green Matrix Column             : 0.16566 0.67534 0.02998
Red Tone Reproduction Curve     : (Binary data 32 bytes, use -b option
to extract)
Green Tone Reproduction Curve   : (Binary data 32 bytes, use -b option
to extract)
Blue Tone Reproduction Curve    : (Binary data 32 bytes, use -b option
to extract)
Chromaticity Channels           : 3
Chromaticity Colorant           : Unknown (0)
Chromaticity Channel 1          : 0.70799 0.29201
Chromaticity Channel 2          : 0.17 0.797
Chromaticity Channel 3          : 0.131 0.04601
Image Size                      : 400x300
Megapixels                      : 0.120


Note, of course this is WRONG kind of wrong, randomly setting
colorimetry tags on encode, but at least it hopefully show that
ffmpeg's machinery (6.1) works at least that far.

sadly, no of those two test images show correct text, so I guess
display icc profile support quite missing step for us ...!

but one micro/nanostep at a time?
From 557cf0691c1b25b6c7da4db12c5d90f8ad2cba08 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <randrianas...@gmail.com>
Date: Sun, 12 Nov 2023 03:59:48 +0300
Subject: [PATCH] Add lcms2 2.13.1 for testing

---
 cinelerra-5.1/configure.ac        |  6 ++++++
 cinelerra-5.1/thirdparty/Makefile | 11 +++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/cinelerra-5.1/configure.ac b/cinelerra-5.1/configure.ac
index 180764bd..b3a7d415 100644
--- a/cinelerra-5.1/configure.ac
+++ b/cinelerra-5.1/configure.ac
@@ -496,6 +496,11 @@ PKG_3RD([libbthread],[auto],
   [ . ])
 fi
 
+PKG_3RD([lcms2],[auto],
+  [lcms2-2.13.1],
+  [ src/.libs/liblcms2.a ],
+  [ include ])
+
 
 AC_SUBST(STATIC_PKGS)
 
@@ -1045,6 +1050,7 @@ PKG_PROVIDE([sord], [$WANT_LV2])
 PKG_PROVIDE([suil], [$WANT_LV2])
 PKG_PROVIDE([ffnvcodec], [$WANT_NV])
 PKG_PROVIDE([libdpx])
+PKG_PROVIDE([lcms2])
 
 if test "x$WANT_LV2" = "xyes"; then
   if test "x$HAVE_lv2" = "xyes" -a "x$BUILD_lilv" = "x0"; then
diff --git a/cinelerra-5.1/thirdparty/Makefile b/cinelerra-5.1/thirdparty/Makefile
index 659ab3fe..eeb64ace 100644
--- a/cinelerra-5.1/thirdparty/Makefile
+++ b/cinelerra-5.1/thirdparty/Makefile
@@ -131,7 +131,8 @@ esound.ldflags=" -lm -lstdc++"
 fftw.cfg_params= --disable-fortran --enable-shared=no
 ffmpeg.cfg_vars?= PKG_CONFIG_PATH="$(call bld_path,libwebp)/usr/local/lib/pkgconfig"
 ffmpeg.cfg_params= \
-	--enable-pthreads --disable-avdevice --enable-gpl --disable-ffplay \
+	--enable-pthreads --disable-avdevice --enable-gpl --disable-doc --disable-ffplay \
+	$(call if_ena,lcms2,--enable-lcms2,--disable-lcms2) \
 	$(call if_want,VAAPI,--enable-vaapi,--disable-vaapi) \
 	$(call if_want,VDPAU,--enable-vdpau,--disable-vdpau) \
 	$(call if_want,NV, --enable-nvenc --enable-nvdec --enable-ffnvcodec) \
@@ -160,6 +161,7 @@ ffmpeg.cfg_params= \
 		$(call inc_path,libvorbis) \
 		$(call inc_path,libtheora) \
 		$(call inc_path,libvpx) \
+		$(call inc_path,lcms2) \
 		$(call inc_path,x264) \
 		$(call inc_path,x265)" \
 	--extra-cxxflags="-D__STDC_CONSTANT_MACROS" \
@@ -178,6 +180,7 @@ ffmpeg.cfg_params= \
 		$(call ld_path,libvpx) \
 		$(call ld_path,x264) \
 		$(call ld_path,x265) \
+		$(call ld_path,lcms2) \
 		$(shared_libs) \
 		-Wl,--end-group -lm -lstdc++ -pthread \
 		$(EXTRA_LIBS)" $(FFMPEG_EXTRA_CFG) \
@@ -269,6 +272,8 @@ x265.cfg_params?= -DENABLE_SHARED=no
 libvpx.cfg_params?= --enable-pic --disable-avx512 --enable-vp9-highbitdepth --disable-examples --disable-unit_tests
 libdpx.cfg_vars?= libtoolize; aclocal; autoconf; automake -a;
 
+lcms2.cfg_params?= --disable-shared
+
 DS:=$$$$$$$$
 pkg_cfg=$(call bld_path,$(1),usr/local/lib/pkgconfig):
 LV2_PKGCFG:=$(subst : ,:,$(foreach p,lv2 serd sord sratom lilv suil,$(call pkg_cfg,$(p))))
@@ -340,7 +345,7 @@ $(call rules,$(call std-build,djbfft))
 $(call rules,$(call std-build,audiofile))
 $(call rules,$(call std-build,encore))
 $(call rules,$(call std-build,esound,audiofile))
-$(call rules,$(call std-build,ffmpeg, twolame lame openjpeg opus \
+$(call rules,$(call std-build,ffmpeg, lcms2 twolame lame openjpeg opus \
 	libtheora x264 x265 libvpx libaom dav1d libwebp \
 	$(call if_want,NV, ffnvcodec)))
 $(call rules,$(call std-build,fftw))
@@ -382,6 +387,8 @@ $(call rules,$(call std-build,lilv, lv2 sratom serd sord))
 $(call rules,$(call std-build,suil, lv2))
 $(call rules,$(call std-build,ffnvcodec))
 $(call rules,$(call std-build,libdpx))
+$(call rules,$(call std-build,lcms2))
+
 
 # specialize festival, multiple tarballs
 festival:
-- 
2.42.0

-- 
Cin mailing list
Cin@lists.cinelerra-gg.org
https://lists.cinelerra-gg.org/mailman/listinfo/cin

Reply via email to