Andrew improvements to split YUV color space, + minor changes
authorGood Guy <good1.2guy@gmail.com>
Mon, 19 Jul 2021 23:48:52 +0000 (17:48 -0600)
committerGood Guy <good1.2guy@gmail.com>
Mon, 19 Jul 2021 23:48:52 +0000 (17:48 -0600)
12 files changed:
cinelerra-5.1/cinelerra/appearanceprefs.C
cinelerra-5.1/cinelerra/appearanceprefs.h
cinelerra-5.1/cinelerra/exportedl.C
cinelerra-5.1/cinelerra/ffmpeg.C
cinelerra-5.1/cinelerra/preferences.C
cinelerra-5.1/cinelerra/preferences.h
cinelerra-5.1/doc/shortcuts.html
cinelerra-5.1/ffmpeg/plugin.opts
cinelerra-5.1/guicast/bccolors.C
cinelerra-5.1/guicast/bccolors.h
cinelerra-5.1/guicast/bccolors.inc
cinelerra-5.1/plugins/colorspace/colorspace.C

index 356fe206928a1de6fb30feaea2fc207df0990706..e9b75f21e6af90110e49b3f78fd12f752585d519 100644 (file)
@@ -885,15 +885,19 @@ int HighlightInverseColor::handle_event()
        return 1;
 }
 
+// num. order of those entries must be same as in
+// guicast/bccolors.inc
 
-const char *YuvColorSpace::color_space[] = {
-       N_("BT601"), // COLOR_SPACE_BT601
+const char *YuvColorSpace::color_space[MAX_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)
- : BC_PopupMenu(x, y, xS(120),
+ : BC_PopupMenu(x, y, xS(140),
        _(color_space[pwindow->thread->preferences->yuv_color_space]), 1)
 {
        this->pwindow = pwindow;
index fc40b04b81358c49a8764f11a93295ff6155bd57..590732b5b9e4167dc27e4940107ea1ae71d6e69a 100644 (file)
@@ -242,7 +242,8 @@ public:
 
 class ViewViconColorMode : public BC_PopupMenu
 {
-       static const char *vicon_color_modes[3];
+#define MAX_VICON_COLOR_MODE 3
+       static const char *vicon_color_modes[MAX_VICON_COLOR_MODE];
 public:
        ViewViconColorMode(PreferencesWindow *pwindow, int x, int y);
        ~ViewViconColorMode();
@@ -377,7 +378,8 @@ public:
 class YuvColorSpace : public BC_PopupMenu
 {
 public:
-       static const char *color_space[3];
+#define MAX_COLOR_SPACE  5
+       static const char *color_space[MAX_COLOR_SPACE];
        YuvColorSpace(int x, int y, PreferencesWindow *pwindow);
        ~YuvColorSpace();
 
@@ -399,7 +401,8 @@ public:
 class YuvColorRange : public BC_PopupMenu
 {
 public:
-       static const char *color_range[2];
+#define MAX_COLOR_RANGE 2
+       static const char *color_range[MAX_COLOR_RANGE];
        YuvColorRange(int x, int y, PreferencesWindow *pwindow);
        ~YuvColorRange();
 
index d4d670eb624786c5280b201e1873f114187d4544..cac86bcf3ac512e2954d5dcd2778c19f367ea125 100644 (file)
@@ -401,6 +401,8 @@ ExportEDLWindow::ExportEDLWindow(MWindow *mwindow, ExportEDL *exportedl, ExportE
 {
        this->mwindow = mwindow;
        this->exportasset = exportasset;
+// *** CONTEXT_HELP ***
+       context_help_set_keyword("Export to EDL");
        for( int i=0; i<2; ++i ) {
                list_titles[i] = _(default_list_titles[i]);
                list_widths[i] = xS(default_list_widths[i]);
index 90e4a8510421a5c4bdf60d44422dc5245d0e29f9..a4a385cdf83b5fbe72ed245ac581b0685bfb673b 100644 (file)
@@ -1589,9 +1589,11 @@ int FFVideoConvert::convert_picture_vframe(VFrame *frame, AVFrame *ip, AVFrame *
        }
        int color_space = SWS_CS_ITU601;
        switch( preferences->yuv_color_space ) {
-       case BC_COLORS_BT601:  color_space = SWS_CS_ITU601;  break;
+       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);
 
@@ -1718,9 +1720,11 @@ int FFVideoConvert::convert_vframe_picture(VFrame *frame, AVFrame *op, AVFrame *
        }
        int color_space = SWS_CS_ITU601;
        switch( preferences->yuv_color_space ) {
-       case BC_COLORS_BT601:  color_space = SWS_CS_ITU601;  break;
+       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);
 
@@ -2638,18 +2642,22 @@ int FFMPEG::open_decoder()
                        }
                        switch( avpar->color_space ) {
                        case AVCOL_SPC_BT470BG:
+                               vid->color_space = BC_COLORS_BT601_PAL;
+                               break;
                        case AVCOL_SPC_SMPTE170M:
-                               vid->color_space = BC_COLORS_BT601;
+                               vid->color_space = BC_COLORS_BT601_NTSC;
                                break;
                        case AVCOL_SPC_BT709:
                                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 :
+                               vid->color_space = !file_base ? BC_COLORS_BT601_NTSC :
                                        file_base->file->preferences->yuv_color_space;
                                break;
                        }
@@ -2892,9 +2900,11 @@ int FFMPEG::open_encoder(const char *type, const char *spec)
                        if( (vid->color_space = asset->ff_color_space) < 0 )
                                vid->color_space = file_base->file->preferences->yuv_color_space;
                        switch( vid->color_space ) {
-                       case BC_COLORS_BT601:  ctx->colorspace = AVCOL_SPC_SMPTE170M;  break;
+                       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 ) {
index 6f4e57c995481e371d6203756fe96dfc78473545..f4716a723c1a774e58721615c4390257628b7f0b 100644 (file)
@@ -104,7 +104,7 @@ Preferences::Preferences()
        forward_render_displacement = 0;
        dvd_yuv420p_interlace = 0;
        highlight_inverse = 0xffffff;
-       yuv_color_space = BC_COLORS_BT601;
+       yuv_color_space = BC_COLORS_BT601_NTSC;
        yuv_color_range = BC_COLORS_JPEG;
        autocolor_assets = 0;
        ctrl_toggle = 1;
@@ -322,6 +322,8 @@ void Preferences::scan_channels(char *string, int *channel_positions, int channe
        }
 }
 
+
+// TODO validation, otherwise corrupted/edited Cinelerra_rc crash app!
 int Preferences::load_defaults(BC_Hash *defaults)
 {
        char string[BCTEXTLEN];
@@ -349,6 +351,7 @@ int Preferences::load_defaults(BC_Hash *defaults)
        layout_scale = defaults->get("LAYOUT_SCALE",layout_scale);
        vicon_size = defaults->get("VICON_SIZE",vicon_size);
        vicon_color_mode = defaults->get("VICON_COLOR_MODE",vicon_color_mode);
+       if (vicon_color_mode > ( MAX_VICON_COLOR_MODE -1 ) || vicon_color_mode <0) vicon_color_mode = 0;
        strcpy(theme, _(DEFAULT_THEME));
        strcpy(locale, DEFAULT_LOCALE);
        strcpy(plugin_icons, DEFAULT_PICON);
@@ -385,7 +388,9 @@ int Preferences::load_defaults(BC_Hash *defaults)
        dvd_yuv420p_interlace = defaults->get("DVD_YUV420P_INTERLACE", dvd_yuv420p_interlace);
        highlight_inverse = defaults->get("HIGHLIGHT_INVERSE", highlight_inverse);
        yuv_color_space = defaults->get("YUV_COLOR_SPACE", yuv_color_space);
+       if (yuv_color_space > (MAX_COLOR_SPACE - 1) || yuv_color_space < 0) yuv_color_space = 0;
        yuv_color_range = defaults->get("YUV_COLOR_RANGE", yuv_color_range);
+       if (yuv_color_range > (MAX_COLOR_RANGE - 1) || yuv_color_range < 0) yuv_color_range = 0;
        autocolor_assets = defaults->get("AUTOCOLOR_ASSETS", autocolor_assets);
        ctrl_toggle = defaults->get("CTRL_TOGGLE", ctrl_toggle);
        rectify_audio = defaults->get("RECTIFY_AUDIO", rectify_audio);
index e814f4260f8f91d5a52a64af59d3ccedc15a4e22..7dd3871c961d162c8b93215af9b80826eabdae80 100644 (file)
@@ -33,6 +33,8 @@
 #include "shbtnprefs.inc"
 #include "videoconfig.inc"
 
+// for MAX_COLOR_SPACE
+#include "appearanceprefs.h"
 
 class Preferences
 {
index 0e420e7c7f7485a2636954559e3516c6234898af..d2cab0ff84ff54334cc41f42f2ea848d71af98a3 100644 (file)
                <td align="left"><font face="Liberation Serif" size=4>'Shift-R'</font></td>
                <td align="left"><font face="Liberation Serif" size=4>Open render window</font></td>
        </tr>
+       <tr>
+               <td height="26" align="left"><font face="Liberation Serif" size=4><br></font></td>
+               <td align="left"><font face="Liberation Serif" size=4>Export EDL…</font></td>
+               <td align="left"><font face="Liberation Serif" size=4>'Shift-E'</font></td>
+               <td align="left"><font face="Liberation Serif" size=4>Export to CMX3600 format</font></td>
+       </tr>
        <tr>
                <td height="26" align="left"><font face="Liberation Serif" size=4><br></font></td>
                <td align="left"><font face="Liberation Serif" size=4>Batch Render..</font></td>
index 845a25453dd68c496cca04b2e31228efb442d941..0e52a6d7af7a7331cfe6c07e6e04a4dd3a9613dd 100644 (file)
@@ -197,8 +197,8 @@ noise
 #overlay x=main_w-overlay_w-10:y=main_h-overlay_h-10 ###Input/output error
 owdenoise
 pad
-#palettegen ###Resource temporarily unavailable
-#paletteuse ###Input/output error
+#palettegen stats_mode=single ###Resource temporarily unavailable (single ok/need output file)
+#paletteuse ###Input/output error (requires input palette.png and output.gif files)
 pan 1c|c0=0.9*c0+0.1*c1
 perms
 perspective
index e587321d5d347f597e962fe752dccac642d3330f..287cc9f86036292e9ed59e5f91a9893ff07a36b2 100644 (file)
@@ -143,9 +143,11 @@ void YUV::yuv_set_colors(int color_space, int color_range)
        int mpeg;
        switch( color_space ) {
        default:
-       case BC_COLORS_BT601:  kr = BT601_Kr;   kb = BT601_Kb;   break;
+       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:
index 94be40bcbd99d1309b1781bb0ec17bef09468f53..820b977d0235cc01cd96991dd66df90e882f1c58 100644 (file)
@@ -104,8 +104,11 @@ inverse:
 // white vector normalized, so:
 //  Kg = 1 - Kr - Kb
 
-#define BT601_Kr 0.299
-#define BT601_Kb 0.114
+#define BT601_NTSC_Kr 0.299
+#define BT601_NTSC_Kb 0.114
+
+#define BT601_PAL_Kr 0.299
+#define BT601_PAL_Kb 0.114
 
 #define BT709_Kr 0.2126
 #define BT709_Kb 0.0722
index 010faca5723d770a7d1063292c80a231a658967e..3557587bbcb68a4b6119b20bfc832b2e009792b3 100644 (file)
 
 class YUV;
 
-#define BC_COLORS_BT601 0
+#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
index 01814ec89d2822a0152f6712a6aaec4875de624c..bb1a7b380bf12120243cebc578235d8ed8ac64ba 100644 (file)
@@ -35,7 +35,7 @@ REGISTER_PLUGIN(ColorSpaceMain)
 ColorSpaceConfig::ColorSpaceConfig()
 {
        inverse = 0;
-       inp_colorspace = BC_COLORS_BT601;
+       inp_colorspace = BC_COLORS_BT601_NTSC;
        inp_colorrange = BC_COLORS_JPEG;
        out_colorspace = BC_COLORS_BT709;
        out_colorrange = BC_COLORS_JPEG;
@@ -307,20 +307,24 @@ void XTable::init(int len, int inv,
        this->inp_space = inp_space;  this->out_space = out_space;
        this->inp_range = inp_range;  this->out_range = out_range;
 
-       double iKr = BT601_Kr, iKb = BT601_Kb;
-       double oKr = BT601_Kr, oKb = BT601_Kb;
+       double iKr = BT601_NTSC_Kr, iKb = BT601_NTSC_Kb;
+       double oKr = BT601_NTSC_Kr, oKb = BT601_NTSC_Kb;
        int impg = 0, ompg = 0;
        switch( inp_space ) {
        default:
-       case BC_COLORS_BT601:  iKr = BT601_Kr;   iKb = BT601_Kb;   break;
+       case BC_COLORS_BT601_NTSC:  iKr = BT601_NTSC_Kr;   iKb = BT601_NTSC_Kb;   break;
+       case BC_COLORS_BT601_PAL:  iKr = BT601_PAL_Kr;   iKb = BT601_PAL_Kb;   break;
        case BC_COLORS_BT709:  iKr = BT709_Kr;   iKb = BT709_Kb;   break;
-       case BC_COLORS_BT2020: iKr = BT2020_Kr;  iKb = BT2020_Kb;  break;
+       case BC_COLORS_BT2020_NCL: 
+       case BC_COLORS_BT2020_CL: iKr = BT2020_Kr;  iKb = BT2020_Kb;  break;
        }
        switch( out_space ) {
        default:
-       case BC_COLORS_BT601:  oKr = BT601_Kr;   oKb = BT601_Kb;   break;
+       case BC_COLORS_BT601_NTSC:  oKr = BT601_NTSC_Kr;   oKb = BT601_NTSC_Kb;   break;
+       case BC_COLORS_BT601_PAL:  oKr = BT601_PAL_Kr;   oKb = BT601_PAL_Kb;   break;
        case BC_COLORS_BT709:  oKr = BT709_Kr;   oKb = BT709_Kb;   break;
-       case BC_COLORS_BT2020: oKr = BT2020_Kr;  oKb = BT2020_Kb;  break;
+       case BC_COLORS_BT2020_NCL: 
+       case BC_COLORS_BT2020_CL: oKr = BT2020_Kr;  oKb = BT2020_Kb;  break;
        }
 
        int iyuv = BC_CModels::is_yuv(inp_model);