From 0be07fc3b2eac7e7be496a8e2d80112b1be3f026 Mon Sep 17 00:00:00 2001 From: jbleyel Date: Fri, 20 Dec 2024 14:58:25 +0100 Subject: [PATCH 1/3] [DVB subtitles] * add more colors Cherry pick -> https://github.com/OpenPLi/enigma2/commit/3c3adb179fbc0b2396fdf3bee38d8198c6ffb746 --- data/setup.xml | 2 +- lib/base/esettings.cpp | 2 +- lib/base/esettings.h | 4 ++-- lib/dvb/subtitle.cpp | 31 +++++++++++++++++++++++----- lib/python/Components/UsageConfig.py | 8 +++---- lib/python/Screens/AudioSelection.py | 2 +- 6 files changed, 35 insertions(+), 14 deletions(-) diff --git a/data/setup.xml b/data/setup.xml index 99417b75262..8a8cabe2f22 100644 --- a/data/setup.xml +++ b/data/setup.xml @@ -893,7 +893,7 @@ config.subtitles.subtitles_backtrans config.subtitles.subtitle_fontsize config.subtitles.subtitle_noPTSrecordingdelay - config.subtitles.dvb_subtitles_yellow + config.subtitles.dvb_subtitles_color config.subtitles.dvb_subtitles_original_position config.subtitles.subtitle_bad_timing_delay config.subtitles.dvb_subtitles_backtrans diff --git a/lib/base/esettings.cpp b/lib/base/esettings.cpp index fba5b9def71..e33888990f7 100644 --- a/lib/base/esettings.cpp +++ b/lib/base/esettings.cpp @@ -7,7 +7,7 @@ int eSubtitleSettings::ttx_subtitle_colors = 1; int eSubtitleSettings::subtitle_position = 50; int eSubtitleSettings::dvb_subtitles_original_position = 0; int eSubtitleSettings::dvb_subtitles_backtrans = 0; -bool eSubtitleSettings::dvb_subtitles_yellow = false; +bool eSubtitleSettings::dvb_subtitles_color = 0; bool eSubtitleSettings::dvb_subtitles_centered = false; int eSubtitleSettings::subtitle_alignment_flag = gPainter::RT_HALIGN_CENTER; bool eSubtitleSettings::colorise_dialogs = false; diff --git a/lib/base/esettings.h b/lib/base/esettings.h index 54109cec0a8..f9d8f8ba38a 100644 --- a/lib/base/esettings.h +++ b/lib/base/esettings.h @@ -17,7 +17,7 @@ class eSubtitleSettings static void setPangoSubtitleAutoRun(bool value) { pango_autoturnon = value; } static void setDVBSubtitleOriginalPosition(int value) { dvb_subtitles_original_position = value; } static void setDVBSubtitleBacktrans(int value) { dvb_subtitles_backtrans = value; } - static void setDVBSubtitleYellow(bool value) { dvb_subtitles_yellow = value; } + static void setDVBSubtitleColor(int value) { dvb_subtitles_color = value; } static void setDVBSubtitleCentered(bool value) { dvb_subtitles_centered = value; } static void setSubtitleReWrap(bool value) { subtitle_rewrap = value; } static void setSubtitlePosition(int value) { subtitle_position = value; } @@ -47,7 +47,7 @@ class eSubtitleSettings static int subtitle_position; static int dvb_subtitles_original_position; static int dvb_subtitles_backtrans; - static bool dvb_subtitles_yellow; + static int dvb_subtitles_color; static bool dvb_subtitles_centered; static int subtitle_alignment_flag; static int subtitle_borderwidth; diff --git a/lib/dvb/subtitle.cpp b/lib/dvb/subtitle.cpp index dbc34d8467a..870df85fc38 100644 --- a/lib/dvb/subtitle.cpp +++ b/lib/dvb/subtitle.cpp @@ -1055,9 +1055,13 @@ void eDVBSubtitleParser::subtitle_redraw(int page_id) } int bcktrans = eSubtitleSettings::dvb_subtitles_backtrans; - bool yellow = eSubtitleSettings::dvb_subtitles_yellow; + int color = eSubtitleSettings::dvb_subtitles_color; - for (int i=0; i Date: Fri, 20 Dec 2024 15:07:38 +0100 Subject: [PATCH 2/3] fix typo --- lib/base/esettings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/base/esettings.cpp b/lib/base/esettings.cpp index e33888990f7..f03d7ae4c05 100644 --- a/lib/base/esettings.cpp +++ b/lib/base/esettings.cpp @@ -7,7 +7,7 @@ int eSubtitleSettings::ttx_subtitle_colors = 1; int eSubtitleSettings::subtitle_position = 50; int eSubtitleSettings::dvb_subtitles_original_position = 0; int eSubtitleSettings::dvb_subtitles_backtrans = 0; -bool eSubtitleSettings::dvb_subtitles_color = 0; +int eSubtitleSettings::dvb_subtitles_color = 0; bool eSubtitleSettings::dvb_subtitles_centered = false; int eSubtitleSettings::subtitle_alignment_flag = gPainter::RT_HALIGN_CENTER; bool eSubtitleSettings::colorise_dialogs = false; From e7139c9e5f03f535746866d64d1fa41bf9534c6b Mon Sep 17 00:00:00 2001 From: jbleyel Date: Fri, 20 Dec 2024 17:22:33 +0100 Subject: [PATCH 3/3] small refactor --- lib/dvb/subtitle.cpp | 85 ++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/lib/dvb/subtitle.cpp b/lib/dvb/subtitle.cpp index 870df85fc38..697d24599a8 100644 --- a/lib/dvb/subtitle.cpp +++ b/lib/dvb/subtitle.cpp @@ -1054,56 +1054,57 @@ void eDVBSubtitleParser::subtitle_redraw(int page_id) break; } - int bcktrans = eSubtitleSettings::dvb_subtitles_backtrans; - int color = eSubtitleSettings::dvb_subtitles_color; - - bool yellow = color == 1; - bool green = color == 2; - bool cyan = color == 4; - - for (int i = 0; i < clut_size; ++i) + int backgroundTransparency = eSubtitleSettings::dvb_subtitles_backtrans; + int subtitleColor = eSubtitleSettings::dvb_subtitles_color; + bool isYellow = subtitleColor == 1; + bool isGreen = subtitleColor == 2; + bool isCyan = subtitleColor == 4; + if (entries) { - if (entries && entries[i].valid) + for (int i = 0; i < clut_size; ++i) { - int y = entries[i].Y, - cr = entries[i].Cr, - cb = entries[i].Cb; - if (y > 0) + if (entries[i].valid) { - y -= 16; - cr -= 128; - cb -= 128; - palette[i].r = (green || cyan) ? 0 : MAX(MIN(((298 * y + 460 * cr) / 256), 255), 0); - palette[i].b = (yellow || green) ? 0 : MAX(MIN(((298 * y + 543 * cb) / 256), 255), 0); - - if (green) + int y = entries[i].Y, + cr = entries[i].Cr, + cb = entries[i].Cb; + if (y > 0) { - palette[i].g = MAX(MIN(((298 * y) / 256), 255), 0); + y -= 16; + cr -= 128; + cb -= 128; + palette[i].r = (isGreen || isCyan) ? 0 : std::max(std::min(((298 * y + 460 * cr) / 256), 255), 0); + palette[i].b = (isYellow || isGreen) ? 0 : std::max(std::min(((298 * y + 543 * cb) / 256), 255), 0); + + if (isGreen) + { + palette[i].g = std::max(std::min(((298 * y) / 256), 255), 0); + } + else if (subtitleColor == 3) // magenta + { + palette[i].g = 0; + } + else if (isCyan) + { + palette[i].g = std::max(std::min(((298 * y + 543 * cb) / 256), 255), 0); + } + else // yellow , original + { + palette[i].g = std::max(std::min(((298 * y - 55 * cb - 137 * cr) / 256), 255), 0); + } + + if (palette[i].r || palette[i].g || palette[i].b) + palette[i].a = (entries[i].T) & 0xFF; + else + palette[i].a = backgroundTransparency; } - else if (color == 3) // magenta + else { + palette[i].r = 0; palette[i].g = 0; + palette[i].b = 0; + palette[i].a = 0xFF; } - else if (cyan) - { - palette[i].g = MAX(MIN(((298 * y + 543 * cb) / 256), 255), 0); - } - else // yellow , original - { - palette[i].g = MAX(MIN(((298 * y - 55 * cb - 137 * cr) / 256), 255), 0); - } - - if (palette[i].r || palette[i].g || palette[i].b) - palette[i].a = (entries[i].T) & 0xFF; - else - palette[i].a = bcktrans; - } - else - { - palette[i].r = 0; - palette[i].g = 0; - palette[i].b = 0; - palette[i].a = 0xFF; } } }