Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Subtitles: Make the subtitle zoom factor into a live setting.

OSDCC708TextZoom is removed from the frontend OSD setup screen and
added as a "live setting" to the Subtitles menu of the playback OSD.
This brings up an adjustment dialog similar to adjusting audio sync or
timestretch.

The menu item is only offered when subtitles are currently enabled.

For text and CEA-708 subtitles, adjustments take effect immediately.
For CEA-608, the adjustment takes effect only when the next caption is
displayed, due to the way the 608 reader is structured.

For now, only the Subtitles menu entry is provided, but if needed, it
would be practical to add a wider set of actions and keybindings to
match the implementation of audio sync and timestretch adjustment.
  • Loading branch information...
commit 0089f7d6b2cd706ad1f91c6df74b8a7047c16b41 1 parent 76ed2bc
@stichnot stichnot authored
View
3  mythtv/libs/libmythtv/osd.h
@@ -42,7 +42,8 @@ enum OSDFunctionalType
kOSDFunctionalType_PictureAdjust,
kOSDFunctionalType_SmartForward,
kOSDFunctionalType_TimeStretchAdjust,
- kOSDFunctionalType_AudioSyncAdjust
+ kOSDFunctionalType_AudioSyncAdjust,
+ kOSDFunctionalType_SubtitleZoomAdjust
};
enum OSDTimeout
View
12 mythtv/libs/libmythtv/subtitlescreen.cpp
@@ -528,7 +528,7 @@ SubtitleScreen::SubtitleScreen(MythPlayer *player, const char * name,
m_player(player), m_subreader(NULL), m_608reader(NULL),
m_708reader(NULL), m_safeArea(QRect()),
m_removeHTML(QRegExp("</?.+>")), m_subtitleType(kDisplayNone),
- m_textFontZoom(100), m_refreshArea(false),
+ m_textFontZoom(100), m_textFontZoomPrev(100), m_refreshArea(false),
m_fontStretch(fontStretch),
m_format(new SubtitleFormat)
{
@@ -614,12 +614,14 @@ bool SubtitleScreen::Create(void)
if (!m_708reader)
LOG(VB_GENERAL, LOG_WARNING, LOC + "Failed to get CEA-708 reader.");
m_textFontZoom = gCoreContext->GetNumSetting("OSDCC708TextZoom", 100);
+ m_textFontZoomPrev = m_textFontZoom;
return true;
}
void SubtitleScreen::Pulse(void)
{
+ m_textFontZoom = gCoreContext->GetNumSetting("OSDCC708TextZoom", 100);
ExpireSubtitles();
DisplayAVSubtitles(); // allow forced subtitles to work
@@ -636,6 +638,7 @@ void SubtitleScreen::Pulse(void)
OptimiseDisplayedArea();
MythScreenType::Pulse();
m_refreshArea = false;
+ m_textFontZoomPrev = m_textFontZoom;
}
void SubtitleScreen::ClearAllSubtitles(void)
@@ -867,7 +870,7 @@ void SubtitleScreen::DisplayTextSubtitles(void)
if (!m_player || !m_subreader)
return;
- bool changed = false;
+ bool changed = (m_textFontZoom != m_textFontZoomPrev);
VideoOutput *vo = m_player->GetVideoOutput();
if (!vo)
return;
@@ -1099,7 +1102,7 @@ void SubtitleScreen::DisplayCC608Subtitles(void)
if (!m_608reader)
return;
- bool changed = false;
+ bool changed = (m_textFontZoom != m_textFontZoomPrev);
if (!m_player || !m_player->GetVideoOutput())
return;
@@ -1145,7 +1148,8 @@ void SubtitleScreen::DisplayCC708Subtitles(void)
video_aspect = m_player->GetVideoAspect();
QRect oldsafe = m_safeArea;
m_safeArea = m_player->GetVideoOutput()->GetSafeRect();
- changed = (oldsafe != m_safeArea);
+ changed = (oldsafe != m_safeArea ||
+ m_textFontZoom != m_textFontZoomPrev);
if (changed)
{
for (uint i = 0; i < 8; i++)
View
1  mythtv/libs/libmythtv/subtitlescreen.h
@@ -85,6 +85,7 @@ class SubtitleScreen : public MythScreenType
QHash<MythUIType*, long long> m_expireTimes;
int m_fontSize;
int m_textFontZoom; // valid for 708 & text subs
+ int m_textFontZoomPrev;
bool m_refreshArea;
QHash<int,QList<MythUIType*> > m_708imageCache;
int m_fontStretch;
View
1  mythtv/libs/libmythtv/tv_actions.h
@@ -64,6 +64,7 @@
#define ACTION_DISABLEEXTTEXT "DISABLEEXTTEXT"
#define ACTION_ENABLEEXTTEXT "ENABLEEXTTEXT"
#define ACTION_TOGGLEEXTTEXT "TOGGLETEXT"
+#define ACTION_TOGGLESUBTITLEZOOM "TOGGLESUBZOOM"
/* Interactive Television keys */
#define ACTION_MENURED "MENURED"
View
64 mythtv/libs/libmythtv/tv_play.cpp
@@ -932,6 +932,7 @@ TV::TV(void)
wantsToQuit(true),
stretchAdjustment(false),
audiosyncAdjustment(false),
+ subtitleZoomAdjustment(false),
editmode(false), zoomMode(false),
sigMonMode(false),
endOfRecording(false),
@@ -1414,6 +1415,7 @@ TVState TV::GetState(int player_idx) const
return ret;
}
+// XXX what about subtitlezoom?
void TV::GetStatus(void)
{
QVariantMap status;
@@ -3806,6 +3808,7 @@ bool TV::ProcessKeypress(PlayerContext *actx, QKeyEvent *e)
handled = handled || PictureAttributeHandleAction(actx, actions);
handled = handled || TimeStretchHandleAction(actx, actions);
handled = handled || AudioSyncHandleAction(actx, actions);
+ handled = handled || SubtitleZoomHandleAction(actx, actions);
handled = handled || DiscMenuHandleAction(actx, actions);
handled = handled || ActiveHandleAction(
actx, actions, isDVD, isMenuOrStill);
@@ -4036,6 +4039,30 @@ bool TV::AudioSyncHandleAction(PlayerContext *ctx,
return handled;
}
+bool TV::SubtitleZoomHandleAction(PlayerContext *ctx,
+ const QStringList &actions)
+{
+ if (!subtitleZoomAdjustment)
+ return false;
+
+ bool handled = true;
+
+ if (has_action(ACTION_LEFT, actions))
+ ChangeSubtitleZoom(ctx, -1);
+ else if (has_action(ACTION_RIGHT, actions))
+ ChangeSubtitleZoom(ctx, 1);
+ else if (has_action(ACTION_UP, actions))
+ ChangeSubtitleZoom(ctx, -10);
+ else if (has_action(ACTION_DOWN, actions))
+ ChangeSubtitleZoom(ctx, 10);
+ else if (has_action(ACTION_TOGGLESUBTITLEZOOM, actions))
+ ClearOSD(ctx);
+ else
+ handled = false;
+
+ return handled;
+}
+
bool TV::DiscMenuHandleAction(PlayerContext *ctx, const QStringList &actions)
{
int64_t pts = 0;
@@ -4407,6 +4434,8 @@ bool TV::ToggleHandleAction(PlayerContext *ctx,
ToggleAdjustFill(ctx);
else if (has_action(ACTION_TOGGELAUDIOSYNC, actions))
ChangeAudioSync(ctx, 0); // just display
+ else if (has_action(ACTION_TOGGLESUBTITLEZOOM, actions))
+ ChangeSubtitleZoom(ctx, 0); // just display
else if (has_action(ACTION_TOGGLEVISUALISATION, actions))
EnableVisualisation(ctx, false, true /*toggle*/);
else if (has_action(ACTION_ENABLEVISUALISATION, actions))
@@ -8374,6 +8403,33 @@ void TV::EnableUpmix(PlayerContext *ctx, bool enable, bool toggle)
SetOSDMessage(ctx, enabled ? tr("Upmixer On") : tr("Upmixer Off"));
}
+void TV::ChangeSubtitleZoom(PlayerContext *ctx, int dir)
+{
+ ctx->LockDeletePlayer(__FILE__, __LINE__);
+ if (!ctx->player)
+ {
+ ctx->UnlockDeletePlayer(__FILE__, __LINE__);
+ return;
+ }
+
+ subtitleZoomAdjustment = true;
+ bool showing = ctx->player->GetCaptionsEnabled();
+ int newval = gCoreContext->GetNumSetting("OSDCC708TextZoom", 100) + dir;
+ newval = max(50, newval);
+ newval = min(200, newval);
+ ctx->UnlockDeletePlayer(__FILE__, __LINE__);
+
+ if (showing && !browsehelper->IsBrowsing())
+ {
+ UpdateOSDStatus(ctx, tr("Adjust Subtitle Zoom"), tr("Subtitle Zoom"),
+ QString::number(newval),
+ kOSDFunctionalType_SubtitleZoomAdjust,
+ "%", newval * 1000 / 200, 0, 0, kOSDTimeout_Long);
+ SetUpdateOSDPosition(false);
+ gCoreContext->SaveSetting("OSDCC708TextZoom", newval);
+ }
+}
+
// dir in 10ms jumps
void TV::ChangeAudioSync(PlayerContext *ctx, int dir, int newsync)
{
@@ -9251,6 +9307,9 @@ void TV::HandleOSDClosed(int osdType)
case kOSDFunctionalType_AudioSyncAdjust:
audiosyncAdjustment = false;
break;
+ case kOSDFunctionalType_SubtitleZoomAdjust:
+ subtitleZoomAdjustment = false;
+ break;
case kOSDFunctionalType_Default:
break;
}
@@ -10172,6 +10231,8 @@ void TV::OSDDialogEvent(int result, QString text, QString action)
}
else if (action.left(15) == ACTION_TOGGELAUDIOSYNC)
ChangeAudioSync(actx, 0);
+ else if (action == ACTION_TOGGLESUBTITLEZOOM)
+ ChangeSubtitleZoom(actx, 0);
else if (action == ACTION_TOGGLEVISUALISATION)
EnableVisualisation(actx, false, true /*toggle*/);
else if (action == ACTION_ENABLEVISUALISATION)
@@ -10879,6 +10940,9 @@ void TV::FillOSDMenuSubtitles(const PlayerContext *ctx, OSD *osd,
}
if (!ttm_tracks.empty())
osd->DialogAddButton(tr("Toggle Teletext Menu"), "TOGGLETTM");
+ if (enabled)
+ osd->DialogAddButton(tr("Adjust Subtitle Zoom"),
+ ACTION_TOGGLESUBTITLEZOOM);
}
else if (category == "AVSUBTITLES")
{
View
6 mythtv/libs/libmythtv/tv_play.h
@@ -478,6 +478,11 @@ class MTV_PUBLIC TV : public QObject
void UpdateOSDAskAllowDialog(PlayerContext*);
void SetUpdateOSDPosition(bool set_it);
+ // Captions/subtitles
+ bool SubtitleZoomHandleAction(PlayerContext *ctx,
+ const QStringList &actions);
+ void ChangeSubtitleZoom(PlayerContext *ctx, int dir);
+
// PxP handling
bool CreatePBP(PlayerContext *lctx, const ProgramInfo *info);
bool CreatePIP(PlayerContext *lctx, const ProgramInfo *info);
@@ -666,6 +671,7 @@ class MTV_PUBLIC TV : public QObject
mutable bool wantsToQuit;
bool stretchAdjustment; ///< True if time stretch is turned on
bool audiosyncAdjustment; ///< True if audiosync is turned on
+ bool subtitleZoomAdjustment; ///< True if subtitle zoom is turned on
bool editmode; ///< Are we in video editing mode
bool zoomMode;
bool sigMonMode; ///< Are we in signal monitoring mode?
View
11 mythtv/programs/mythfrontend/globalsettings.cpp
@@ -1323,16 +1323,6 @@ static HostComboBox MUNUSED *DecodeVBIFormat()
return gc;
}
-static HostSpinBox *OSDCC708TextZoomPercentage(void)
-{
- HostSpinBox *gs = new HostSpinBox("OSDCC708TextZoom", 50, 200, 5);
- gs->setLabel(QObject::tr("Subtitle text zoom percentage"));
- gs->setValue(100);
- gs->setHelpText(QObject::tr("Use this to enlarge or shrink text based subtitles."));
-
- return gs;
-}
-
static HostComboBox *SubtitleCodec()
{
HostComboBox *gc = new HostComboBox("SubtitleCodec");
@@ -3400,7 +3390,6 @@ OSDSettings::OSDSettings()
osd->addChild(PersistentBrowseMode());
osd->addChild(BrowseAllTuners());
osd->addChild(DefaultCCMode());
- osd->addChild(OSDCC708TextZoomPercentage());
osd->addChild(SubtitleCodec());
addChild(osd);
Please sign in to comment.
Something went wrong with that request. Please try again.