From: Good Guy Date: Mon, 19 Jul 2021 23:48:52 +0000 (-0600) Subject: Andrew improvements to split YUV color space, + minor changes X-Git-Tag: 2021-07~5 X-Git-Url: https://git.cinelerra-gg.org/git/?a=commitdiff_plain;h=34d7b567ee523b6185aabe66879026c8e1704152;p=goodguy%2Fcinelerra.git Andrew improvements to split YUV color space, + minor changes --- diff --git a/cinelerra-5.1/cinelerra/appearanceprefs.C b/cinelerra-5.1/cinelerra/appearanceprefs.C index 356fe206..e9b75f21 100644 --- a/cinelerra-5.1/cinelerra/appearanceprefs.C +++ b/cinelerra-5.1/cinelerra/appearanceprefs.C @@ -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; diff --git a/cinelerra-5.1/cinelerra/appearanceprefs.h b/cinelerra-5.1/cinelerra/appearanceprefs.h index fc40b04b..590732b5 100644 --- a/cinelerra-5.1/cinelerra/appearanceprefs.h +++ b/cinelerra-5.1/cinelerra/appearanceprefs.h @@ -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(); diff --git a/cinelerra-5.1/cinelerra/exportedl.C b/cinelerra-5.1/cinelerra/exportedl.C index d4d670eb..cac86bcf 100644 --- a/cinelerra-5.1/cinelerra/exportedl.C +++ b/cinelerra-5.1/cinelerra/exportedl.C @@ -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]); diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C index 90e4a851..a4a385cd 100644 --- a/cinelerra-5.1/cinelerra/ffmpeg.C +++ b/cinelerra-5.1/cinelerra/ffmpeg.C @@ -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 ) { diff --git a/cinelerra-5.1/cinelerra/preferences.C b/cinelerra-5.1/cinelerra/preferences.C index 6f4e57c9..f4716a72 100644 --- a/cinelerra-5.1/cinelerra/preferences.C +++ b/cinelerra-5.1/cinelerra/preferences.C @@ -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); diff --git a/cinelerra-5.1/cinelerra/preferences.h b/cinelerra-5.1/cinelerra/preferences.h index e814f426..7dd3871c 100644 --- a/cinelerra-5.1/cinelerra/preferences.h +++ b/cinelerra-5.1/cinelerra/preferences.h @@ -33,6 +33,8 @@ #include "shbtnprefs.inc" #include "videoconfig.inc" +// for MAX_COLOR_SPACE +#include "appearanceprefs.h" class Preferences { diff --git a/cinelerra-5.1/doc/shortcuts.html b/cinelerra-5.1/doc/shortcuts.html index 0e420e7c..d2cab0ff 100644 --- a/cinelerra-5.1/doc/shortcuts.html +++ b/cinelerra-5.1/doc/shortcuts.html @@ -114,6 +114,12 @@ 'Shift-R' Open render window + +
+ Export EDL… + 'Shift-E' + Export to CMX3600 format +
Batch Render.. diff --git a/cinelerra-5.1/ffmpeg/plugin.opts b/cinelerra-5.1/ffmpeg/plugin.opts index 845a2545..0e52a6d7 100644 --- a/cinelerra-5.1/ffmpeg/plugin.opts +++ b/cinelerra-5.1/ffmpeg/plugin.opts @@ -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 diff --git a/cinelerra-5.1/guicast/bccolors.C b/cinelerra-5.1/guicast/bccolors.C index e587321d..287cc9f8 100644 --- a/cinelerra-5.1/guicast/bccolors.C +++ b/cinelerra-5.1/guicast/bccolors.C @@ -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: diff --git a/cinelerra-5.1/guicast/bccolors.h b/cinelerra-5.1/guicast/bccolors.h index 94be40bc..820b977d 100644 --- a/cinelerra-5.1/guicast/bccolors.h +++ b/cinelerra-5.1/guicast/bccolors.h @@ -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 diff --git a/cinelerra-5.1/guicast/bccolors.inc b/cinelerra-5.1/guicast/bccolors.inc index 010faca5..3557587b 100644 --- a/cinelerra-5.1/guicast/bccolors.inc +++ b/cinelerra-5.1/guicast/bccolors.inc @@ -25,9 +25,11 @@ 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 diff --git a/cinelerra-5.1/plugins/colorspace/colorspace.C b/cinelerra-5.1/plugins/colorspace/colorspace.C index 01814ec8..bb1a7b38 100644 --- a/cinelerra-5.1/plugins/colorspace/colorspace.C +++ b/cinelerra-5.1/plugins/colorspace/colorspace.C @@ -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);