On Wednesday, July 14, 2021, Andrew Randrianasulu <[email protected]>
wrote:

>
>
> On Tuesday, July 13, 2021, Andrew Randrianasulu <[email protected]>
> wrote:
>
>>
>>
>> On Tuesday, July 13, 2021, Phyllis Smith <[email protected]> wrote:
>>
>>> Andrew, I really like the "color hell" moniker.
>>> Andrea, you are right, ffprobe shows it correctly.  I had always heard
>>> that mediainfo sometimes got it wrong, but this is the first time I saw
>>> that.
>>>
>>> What about old projects? will they handle this change correctly?
>>>
>>
>>
>> I tried to add my new colorspace as numbered define  _after_ all pre-used
>> defines, while renaming old bt601 to bt601 ntsc (given usual ntsc-centered
>> preference in other parts of cin)
>>
>> and of course _order_ in preferences mattered,  my patches made things
>> shift down by one (so displayed colorspace and encoded colorspace drifted
>> by one! bt2020 displayed was real bt601 pal... bt601 ntsc was bt709... as
>> you sharply noted!)
>>
>> I think we save it per-session (in Cinelerra_rc) not per-project? will
>> look more into it...
>>
>> try add two more patches I attached? one is fix another is comment.
>>
>> Also, while we are here may be rename and enlarge  bt2020  label for
>> bt2020 *nc* as code (in ffmpeg.C) seems to map it really?
>>
>
>
> according to this page (scroll down for screenshot) Premiere
> differenciates between bt2020 ncl and bt2020 cl :
>
> https://www.voukoder.org/forum/thread/487-hdr-support-
> in-x265-and-nvenc-hevc/
>
> for now I just enlarged dropdown menu a bit..
>


 added 2020 ncl/cl diff + hopefully mapping between (rare) ffmpeg's
floating-point pix formats and Cinelerra's rgb(a) float...

fixed typos in prev mail...



>
>
>>
>>
>>> On Tue, Jul 13, 2021 at 12:17 PM Andrew Randrianasulu <
>>> [email protected]> wrote:
>>>
>>>>
>>>>
>>>> On Tuesday, July 13, 2021, Phyllis Smith via Cin <
>>>> [email protected]> wrote:
>>>>
>>>>> Not so sure about that after running more tests.
>>>>> Using 601Pal, mediainfo reports BT.601.
>>>>> Using 601Ntsc, medinao reports BT.709 !!
>>>>> As always, have to make sure old projects still work.
>>>>>
>>>>
>>>>
>>>> its called color hell for this exact reason)
>>>>
>>>> may be mediainfo a bit wrong (at least ver. you used - shoukd be recent
>>>> on Fedora, but small fixes like this can go in anytime...)
>>>>
>>>> see confusing code at (should be recent enough from 2020)
>>>>
>>>> https://sourceforge.net/p/mediainfo/discussion/297610/thread
>>>> /0b6d2fd38f/?limit=25
>>>>
>>>> =====
>>>>
>>>> ha.
>>>>
>>>> //----------------------------------------------------------
>>>> -----------------
>>>> extern const char* Mpegv_colour_primaries(int8u colour_primaries)
>>>> {
>>>>     switch (colour_primaries)
>>>>     {
>>>>         case 1 : return "BT.709";
>>>>         case 4 : return "BT.470 System M";
>>>>         case 5 : return "BT.601 PAL";
>>>>         case 6 : return "BT.601 NTSC";
>>>>         case 7 : return "SMPTE 240M"; //Same as BT.601 NTSC
>>>>         case 8 : return "Generic film";
>>>>         case 9 : return "BT.2020"; //Added in HEVC
>>>>         case 10 : return "XYZ"; //Added in HEVC 2014
>>>>         case 11 : return "DCI P3"; //Added in HEVC 2016
>>>>         case 12 : return "Display P3"; //Added in HEVC 2016
>>>>         case 22 : return "EBU Tech 3213"; //Added in HEVC 2016
>>>>         default : return "";
>>>>     }
>>>> }
>>>>
>>>> //----------------------------------------------------------
>>>> -----------------
>>>> extern const char* Mpegv_transfer_characteristics(int8u
>>>> transfer_characteristics)
>>>> {
>>>>     switch (transfer_characteristics)
>>>>     {
>>>>         case 1 : return "BT.709"; //Same as BT.601
>>>>         case 4 : return "BT.470 System M";
>>>>         case 5 : return "BT.470 System B/G";
>>>>         case 6 : return "BT.601";
>>>>         case 7 : return "SMPTE 240M";
>>>>         case 8 : return "Linear";
>>>>         case 9 : return "Logarithmic (100:1)"; //Added in MPEG-4 Visual
>>>>         case 10 : return "Logarithmic (316.22777:1)"; //Added in MPEG-4
>>>> Visual
>>>>         case 11 : return "xvYCC"; //Added in AVC
>>>>         case 12 : return "BT.1361"; //Added in AVC
>>>>         case 13 : return "sRGB/sYCC"; //Added in HEVC
>>>>         case 14 : return "BT.2020 (10-bit)"; //Same a BT.601 //Added in
>>>> HEVC, 10/12-bit difference is in ISO 23001-8
>>>>         case 15 : return "BT.2020 (12-bit)"; //Same a BT.601 //Added in
>>>> HEVC, 10/12-bit difference is in ISO 23001-8
>>>>         case 16 : return "PQ"; //Added in HEVC 2015
>>>>         case 17 : return "SMPTE 428M"; //Added in HEVC 2015
>>>>         case 18 : return "HLG"; //Added in HEVC 2016
>>>>         default : return "";
>>>>     }
>>>> }
>>>>
>>>> //----------------------------------------------------------
>>>> -----------------
>>>> extern const char* Mpegv_matrix_coefficients(int8u matrix_coefficients)
>>>> {
>>>>     switch (matrix_coefficients)
>>>>     {
>>>>         case 0 : return "Identity"; //Added in AVC
>>>>         case 1 : return "BT.709";
>>>>         case 4 : return "FCC 73.682";
>>>>         case 5 : return "BT.470 System B/G";
>>>>         case 6 : return "BT.601"; //Same as BT.470 System B/G
>>>>         case 7 : return "SMPTE 240M";
>>>>         case 8 : return "YCgCo"; //Added in AVC
>>>>         case 9 : return "BT.2020 non-constant"; //Added in HEVC
>>>>         case 10 : return "BT.2020 constant"; //Added in HEVC
>>>>         case 11 : return "Y'D'zD'x"; //Added in HEVC 2016
>>>>         case 12 : return "Chromaticity-derived non-constant"; //Added
>>>> in HEVC 2016
>>>>         case 13 : return "Chromaticity-derived constant"; //Added in
>>>> HEVC 2016
>>>>         case 14 : return "ICtCp"; //Added in HEVC 2016
>>>>         default : return "";
>>>>     }
>>>> }
>>>>
>>>> =====
>>>>
>>>> note _transfer characteristics_ #1 said to be the same for bt. 709 and
>>>> #6  bt. 601! (in comment)
>>>>
>>>> can you post full mediainfo output for input video, and three other
>>>> videos: unmodded Cin, modded and  set to BT601 NTSC, set to BT601 pal?
>>>>
>>>>
>>>>>
>>>>> On Mon, Jul 12, 2021 at 2:26 PM Andrew Randrianasulu via Cin <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> According to
>>>>>>
>>>>>> https://kdenlive.org/en/project/color-hell-ffmpeg-transcodin
>>>>>> g-and-preserving-bt-601/
>>>>>>
>>>>>> bt 601 pal and bt 601 ntsc are  slightly different, I tried to update
>>>>>> CinGG's definitions so now she have two distinct 601 colorspaces, but I
>>>>>> still can be wrong (esp on kr, kb coeffecients)
>>>>>>
>>>>>> can anyone test patch 3 and see if it makes any positive difference?
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Cin mailing list
>>>>>> [email protected]
>>>>>> https://lists.cinelerra-gg.org/mailman/listinfo/cin
>>>>>>
>>>>>
From 465f530a3fb80eb42b3539dc253c029ca0f1ab02 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Wed, 14 Jul 2021 02:09:05 +0300
Subject: [PATCH 7/8] Attempt at differenciating bt2020 ncl vs bt2020 cl

---
 cinelerra-5.1/cinelerra/appearanceprefs.C |  3 ++-
 cinelerra-5.1/cinelerra/appearanceprefs.h |  2 +-
 cinelerra-5.1/cinelerra/ffmpeg.C          | 13 +++++++++----
 cinelerra-5.1/guicast/bccolors.C          |  3 ++-
 cinelerra-5.1/guicast/bccolors.inc        |  3 ++-
 5 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/cinelerra-5.1/cinelerra/appearanceprefs.C b/cinelerra-5.1/cinelerra/appearanceprefs.C
index 6289bfac..83233e2b 100644
--- a/cinelerra-5.1/cinelerra/appearanceprefs.C
+++ b/cinelerra-5.1/cinelerra/appearanceprefs.C
@@ -891,8 +891,9 @@ int HighlightInverseColor::handle_event()
 const char *YuvColorSpace::color_space[] = {
 	N_("BT601_NTSC"), // COLOR SPACE BT601_NTSC
 	N_("BT709"), // COLOR_SPACE_BT709
-	N_("BT2020"), // COLOR_SPACE_BT2020
+	N_("BT2020 NCL"), // COLOR_SPACE_BT2020_NCL
 	N_("BT601_PAL"), // COLOR_SPACE_BT601_PAL
+	N_("BT2020 CL"), // COLOR_SPACE_BT2020_CL
 };
 
 YuvColorSpace::YuvColorSpace(int x, int y, PreferencesWindow *pwindow)
diff --git a/cinelerra-5.1/cinelerra/appearanceprefs.h b/cinelerra-5.1/cinelerra/appearanceprefs.h
index ba6763e9..c479da47 100644
--- a/cinelerra-5.1/cinelerra/appearanceprefs.h
+++ b/cinelerra-5.1/cinelerra/appearanceprefs.h
@@ -377,7 +377,7 @@ public:
 class YuvColorSpace : public BC_PopupMenu
 {
 public:
-	static const char *color_space[4];
+	static const char *color_space[5];
 	YuvColorSpace(int x, int y, PreferencesWindow *pwindow);
 	~YuvColorSpace();
 
diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C
index 952c3ca4..63144ec1 100644
--- a/cinelerra-5.1/cinelerra/ffmpeg.C
+++ b/cinelerra-5.1/cinelerra/ffmpeg.C
@@ -1596,7 +1596,8 @@ int FFVideoConvert::convert_picture_vframe(VFrame *frame, AVFrame *ip, AVFrame *
 	case BC_COLORS_BT601_PAL:  color_space = SWS_CS_ITU601;  break;
 	case BC_COLORS_BT601_NTSC: color_space = SWS_CS_SMPTE170M; break;
 	case BC_COLORS_BT709:  color_space = SWS_CS_ITU709;  break;
-	case BC_COLORS_BT2020: color_space = SWS_CS_BT2020;  break;
+	case BC_COLORS_BT2020_NCL: 
+	case BC_COLORS_BT2020_CL: color_space = SWS_CS_BT2020;  break;
 	}
 	const int *color_table = sws_getCoefficients(color_space);
 
@@ -1726,7 +1727,8 @@ int FFVideoConvert::convert_vframe_picture(VFrame *frame, AVFrame *op, AVFrame *
 	case BC_COLORS_BT601_PAL:  color_space = SWS_CS_ITU601;  break;
 	case BC_COLORS_BT601_NTSC: color_space = SWS_CS_SMPTE170M; break;
 	case BC_COLORS_BT709:  color_space = SWS_CS_ITU709;  break;
-	case BC_COLORS_BT2020: color_space = SWS_CS_BT2020;  break;
+	case BC_COLORS_BT2020_NCL:
+	case BC_COLORS_BT2020_CL: color_space = SWS_CS_BT2020;  break;
 	}
 	const int *color_table = sws_getCoefficients(color_space);
 
@@ -2653,8 +2655,10 @@ int FFMPEG::open_decoder()
 				vid->color_space = BC_COLORS_BT709;
 				break;
 			case AVCOL_SPC_BT2020_NCL:
+				vid->color_space = BC_COLORS_BT2020_NCL;
+				break;
 			case AVCOL_SPC_BT2020_CL:
-				vid->color_space = BC_COLORS_BT2020;
+				vid->color_space = BC_COLORS_BT2020_CL;
 				break;
 			default:
 				vid->color_space = !file_base ? BC_COLORS_BT601_NTSC :
@@ -2911,7 +2915,8 @@ int FFMPEG::open_encoder(const char *type, const char *spec)
 			case BC_COLORS_BT601_NTSC:  ctx->colorspace = AVCOL_SPC_SMPTE170M;  break;
 			case BC_COLORS_BT601_PAL: ctx->colorspace = AVCOL_SPC_BT470BG; break;
 			case BC_COLORS_BT709:  ctx->colorspace = AVCOL_SPC_BT709;      break;
-			case BC_COLORS_BT2020: ctx->colorspace = AVCOL_SPC_BT2020_NCL; break;
+			case BC_COLORS_BT2020_NCL: ctx->colorspace = AVCOL_SPC_BT2020_NCL; break;
+			case BC_COLORS_BT2020_CL: ctx->colorspace = AVCOL_SPC_BT2020_CL; break;
 			}
 			AVPixelFormat pix_fmt = av_get_pix_fmt(asset->ff_pixel_format);
 			if( opt_hw_dev != 0 ) {
diff --git a/cinelerra-5.1/guicast/bccolors.C b/cinelerra-5.1/guicast/bccolors.C
index 94dfd20b..287cc9f8 100644
--- a/cinelerra-5.1/guicast/bccolors.C
+++ b/cinelerra-5.1/guicast/bccolors.C
@@ -146,7 +146,8 @@ void YUV::yuv_set_colors(int color_space, int color_range)
 	case BC_COLORS_BT601_NTSC:  kr = BT601_NTSC_Kr;   kb = BT601_NTSC_Kb;   break;
 	case BC_COLORS_BT601_PAL: kr = BT601_PAL_Kr; kb = BT601_PAL_Kb; break;
 	case BC_COLORS_BT709:  kr = BT709_Kr;   kb = BT709_Kb;   break;
-	case BC_COLORS_BT2020: kr = BT2020_Kr;  kb = BT2020_Kb;  break;
+	case BC_COLORS_BT2020_NCL: 
+	case BC_COLORS_BT2020_CL: kr = BT2020_Kr;  kb = BT2020_Kb;  break;
 	}
 	switch( color_range ) {
 	default:
diff --git a/cinelerra-5.1/guicast/bccolors.inc b/cinelerra-5.1/guicast/bccolors.inc
index 58afbaee..3557587b 100644
--- a/cinelerra-5.1/guicast/bccolors.inc
+++ b/cinelerra-5.1/guicast/bccolors.inc
@@ -28,7 +28,8 @@ class YUV;
 #define BC_COLORS_BT601_NTSC 0
 #define BC_COLORS_BT601_PAL 3
 #define BC_COLORS_BT709 1
-#define BC_COLORS_BT2020 2
+#define BC_COLORS_BT2020_NCL 2
+#define BC_COLORS_BT2020_CL 4
 
 #define BC_COLORS_JPEG 0
 #define BC_COLORS_MPEG 1
-- 
2.32.0

From 3c757ebe3b8667209128d580f250ea4c765ecec7 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Wed, 14 Jul 2021 03:08:35 +0300
Subject: [PATCH 8/8] Attempt at mapping our rgb(a) float to ffmpeg's
 av_pix_fmt

---
 cinelerra-5.1/cinelerra/ffmpeg.C | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C
index 63144ec1..95f6d8ab 100644
--- a/cinelerra-5.1/cinelerra/ffmpeg.C
+++ b/cinelerra-5.1/cinelerra/ffmpeg.C
@@ -1490,6 +1490,8 @@ AVPixelFormat FFVideoConvert::color_model_to_pix_fmt(int color_model)
 	case BC_RGBA16161616:   return AV_PIX_FMT_RGBA64LE;
 	case BC_AYUV16161616:	return AV_PIX_FMT_AYUV64LE;
 	case BC_GBRP:		return AV_PIX_FMT_GBRP;
+	case BC_RGBA_FLOAT:	return AV_PIX_FMT_GBRAPF32;
+	case BC_RGB_FLOAT:	return AV_PIX_FMT_GBRPF32;
 	default: break;
 	}
 
@@ -1516,6 +1518,8 @@ int FFVideoConvert::pix_fmt_to_color_model(AVPixelFormat pix_fmt)
 	case AV_PIX_FMT_RGBA64LE:	return BC_RGBA16161616;
 	case AV_PIX_FMT_AYUV64LE:	return BC_AYUV16161616;
 	case AV_PIX_FMT_GBRP:		return BC_GBRP;
+	case AV_PIX_FMT_GBRPF32:	return BC_RGB_FLOAT;
+	case AV_PIX_FMT_GBRAPF32:	return BC_RGBA_FLOAT;
 	default: break;
 	}
 
-- 
2.32.0

-- 
Cin mailing list
[email protected]
https://lists.cinelerra-gg.org/mailman/listinfo/cin

Reply via email to