From 1b6f19532526a03845e17696b324c661bdf27fd4 Mon Sep 17 00:00:00 2001 From: madshi Date: Mon, 22 Jan 2018 13:52:34 -0800 Subject: [PATCH] Add setting to allow repositioning of SSA/ASS dialog --- src/filters/transform/vsfilter/DirectVobSub.cpp | 4 ++++ src/filters/transform/vsfilter/DirectVobSub.h | 10 +++++----- .../transform/vsfilter/DirectVobSubPropPage.cpp | 7 +++++++ .../transform/vsfilter/DirectVobSubPropPage.h | 4 ++-- src/filters/transform/vsfilter/IDirectVobSubXy.h | 4 ++++ src/filters/transform/vsfilter/VSFilter.rc | 4 +++- src/filters/transform/vsfilter/resource.h | 2 ++ src/filters/transform/vsfilter/xy_sub_filter.cpp | 12 ++++++++++-- src/subtitles/RTS.cpp | 7 ++++++- src/subtitles/RTS.h | 1 + 10 files changed, 44 insertions(+), 11 deletions(-) diff --git a/src/filters/transform/vsfilter/DirectVobSub.cpp b/src/filters/transform/vsfilter/DirectVobSub.cpp index dadf14465..69c7eb999 100644 --- a/src/filters/transform/vsfilter/DirectVobSub.cpp +++ b/src/filters/transform/vsfilter/DirectVobSub.cpp @@ -1065,6 +1065,7 @@ CDirectVobSub::CDirectVobSub( const Option *options, CCritSec * pLock ) m_xy_int_opt[INT_SELECTED_LANGUAGE] = 0; m_xy_bool_opt[BOOL_HIDE_SUBTITLES] = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_HIDE), 0); + m_xy_bool_opt[BOOL_ALLOW_MOVING] = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ALLOWMOVING), 0); m_xy_bool_opt[BOOL_PRE_BUFFERING] = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_DOPREBUFFERING), 1); m_xy_int_opt[INT_COLOR_SPACE] = GetCompatibleProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_COLOR_SPACE), YuvMatrix_AUTO); @@ -1309,6 +1310,7 @@ STDMETHODIMP CDirectVobSub::UpdateRegistry() CAutoLock cAutoLock(m_propsLock); theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_HIDE), m_xy_bool_opt[BOOL_HIDE_SUBTITLES]); + theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ALLOWMOVING), m_xy_bool_opt[BOOL_ALLOW_MOVING]); theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_DOPREBUFFERING), m_xy_bool_opt[BOOL_PRE_BUFFERING]); theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_YUV_RANGE), m_xy_int_opt[INT_YUV_RANGE]); @@ -1450,6 +1452,7 @@ CDVS4XySubFilter::CDVS4XySubFilter( const Option *options, CCritSec * pLock ) m_xy_int_opt [INT_SELECTED_LANGUAGE] = 0; m_xy_bool_opt[BOOL_HIDE_SUBTITLES ] = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_HIDE), 0); + m_xy_bool_opt[BOOL_ALLOW_MOVING ] = !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ALLOWMOVING), 0); CString str_color_space = theApp.GetProfileString(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_COLOR_SPACE), _T("AUTO")); @@ -1680,6 +1683,7 @@ STDMETHODIMP CDVS4XySubFilter::UpdateRegistry() CAutoLock cAutoLock(m_propsLock); theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_HIDE), m_xy_bool_opt[BOOL_HIDE_SUBTITLES]); + theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ALLOWMOVING), m_xy_bool_opt[BOOL_ALLOW_MOVING]); CString str_color_space; switch(m_xy_int_opt[INT_YUV_RANGE]) diff --git a/src/filters/transform/vsfilter/DirectVobSub.h b/src/filters/transform/vsfilter/DirectVobSub.h index 12f7c70e8..1ca5e898c 100644 --- a/src/filters/transform/vsfilter/DirectVobSub.h +++ b/src/filters/transform/vsfilter/DirectVobSub.h @@ -119,11 +119,11 @@ class DirectVobSubImpl : public IDirectVobSub2, public XyOptionsImpl, public IFi STDMETHODIMP get_FileName(WCHAR* fn); STDMETHODIMP put_FileName(WCHAR* fn); - STDMETHODIMP get_LanguageCount(int* nLangs); - STDMETHODIMP get_LanguageName(int iLanguage, WCHAR** ppName); - STDMETHODIMP get_SelectedLanguage(int* iSelected); - STDMETHODIMP put_SelectedLanguage(int iSelected); - STDMETHODIMP get_HideSubtitles(bool* fHideSubtitles); + STDMETHODIMP get_LanguageCount(int* nLangs); + STDMETHODIMP get_LanguageName(int iLanguage, WCHAR** ppName); + STDMETHODIMP get_SelectedLanguage(int* iSelected); + STDMETHODIMP put_SelectedLanguage(int iSelected); + STDMETHODIMP get_HideSubtitles(bool* fHideSubtitles); STDMETHODIMP put_HideSubtitles(bool fHideSubtitles); STDMETHODIMP get_PreBuffering(bool* fDoPreBuffering); STDMETHODIMP put_PreBuffering(bool fDoPreBuffering); diff --git a/src/filters/transform/vsfilter/DirectVobSubPropPage.cpp b/src/filters/transform/vsfilter/DirectVobSubPropPage.cpp index c1930030d..22afd7105 100644 --- a/src/filters/transform/vsfilter/DirectVobSubPropPage.cpp +++ b/src/filters/transform/vsfilter/DirectVobSubPropPage.cpp @@ -1893,6 +1893,7 @@ CXySubFilterMorePPage::CXySubFilterMorePPage(LPUNKNOWN pUnk, HRESULT* phr) BindControl(IDC_SPIN_LAYOUT_SIZE_X, m_layout_size_x); BindControl(IDC_SPIN_LAYOUT_SIZE_Y, m_layout_size_y); + BindControl(IDC_CHECKBOX_ALLOW_MOVING, m_allowmoving); BindControl(IDC_HIDE, m_hidesub); BindControl(IDC_AUTORELOAD, m_autoreload); BindControl(IDC_INSTANTUPDATE, m_instupd); @@ -2027,6 +2028,8 @@ void CXySubFilterMorePPage::UpdateObjectData(bool fSave) hr = m_pDirectVobSubXy->XySetSize(DirectVobSubXyOptions::SIZE_USER_SPECIFIED_LAYOUT_SIZE, m_layout_size); CHECK_N_LOG(hr, "Failed to set option"); hr = m_pDirectVobSub->put_HideSubtitles(m_fHideSubtitles); + CHECK_N_LOG(hr, "Failed to set option"); + hr = m_pDirectVobSubXy->XySetBool(DirectVobSubXyOptions::BOOL_ALLOW_MOVING, m_fAllowMoving); CHECK_N_LOG(hr, "Failed to set option"); hr = m_pDirectVobSub->put_SubtitleReloader(m_fReloaderDisabled); CHECK_N_LOG(hr, "Failed to set option"); @@ -2063,6 +2066,8 @@ void CXySubFilterMorePPage::UpdateObjectData(bool fSave) CHECK_N_LOG(hr, "Failed to get option"); hr = m_pDirectVobSub->get_HideSubtitles(&m_fHideSubtitles); CHECK_N_LOG(hr, "Failed to get option"); + hr = m_pDirectVobSubXy->XyGetBool(DirectVobSubXyOptions::BOOL_ALLOW_MOVING, &m_fAllowMoving); + CHECK_N_LOG(hr, "Failed to get option"); hr = m_pDirectVobSub->get_SubtitleReloader(&m_fReloaderDisabled); CHECK_N_LOG(hr, "Failed to get option"); @@ -2118,6 +2123,7 @@ void CXySubFilterMorePPage::UpdateControlData(bool fSave) m_layout_size.cy = m_layout_size_y.GetPos32(); m_fHideSubtitles = !!m_hidesub.GetCheck(); + m_fAllowMoving = !!m_allowmoving.GetCheck(); m_fReloaderDisabled = !m_autoreload.GetCheck(); @@ -2215,6 +2221,7 @@ void CXySubFilterMorePPage::UpdateControlData(bool fSave) m_layout_size_y.SetPos32(m_layout_size.cy); m_hidesub.SetCheck(m_fHideSubtitles); + m_allowmoving.SetCheck(m_fAllowMoving); m_autoreload.SetCheck(!m_fReloaderDisabled); m_instupd.SetCheck(!!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INSTANTUPDATE), 1)); diff --git a/src/filters/transform/vsfilter/DirectVobSubPropPage.h b/src/filters/transform/vsfilter/DirectVobSubPropPage.h index aa9044720..f12dc12ca 100644 --- a/src/filters/transform/vsfilter/DirectVobSubPropPage.h +++ b/src/filters/transform/vsfilter/DirectVobSubPropPage.h @@ -291,12 +291,12 @@ class CXySubFilterMorePPage : public CDVSBasePPage int m_yuv_matrix, m_yuv_range, m_rgb_level; SIZE m_layout_size; - bool m_fHideSubtitles, m_fReloaderDisabled; + bool m_fHideSubtitles, m_fAllowMoving, m_fReloaderDisabled; bool m_render_to_original_video_size; int m_cache_size, m_auto_cache_size; - CButton m_hidesub, m_autoreload, m_instupd; + CButton m_hidesub, m_allowmoving, m_autoreload, m_instupd; CSpinButtonCtrl m_path_cache, m_scanline_cache, m_overlay_no_blur_cache, m_overlay_cache; diff --git a/src/filters/transform/vsfilter/IDirectVobSubXy.h b/src/filters/transform/vsfilter/IDirectVobSubXy.h index af5cc18f8..4d16f45b1 100644 --- a/src/filters/transform/vsfilter/IDirectVobSubXy.h +++ b/src/filters/transform/vsfilter/IDirectVobSubXy.h @@ -145,6 +145,8 @@ namespace DirectVobSubXyOptions void_ShowConfigDialog, void_AdviseSubClock, + BOOL_ALLOW_MOVING, + OPTION_COUNT }; struct ColorSpaceOpt @@ -242,6 +244,7 @@ namespace DirectVobSubXyOptions {XyOptionsImpl::OPTION_TYPE_BOOL , XyOptionsImpl::OPTION_MODE_RW, BOOL_FOLLOW_UPSTREAM_PREFERRED_ORDER}, {XyOptionsImpl::OPTION_TYPE_BOOL , XyOptionsImpl::OPTION_MODE_RW, BOOL_HIDE_TRAY_ICON}, {XyOptionsImpl::OPTION_TYPE_BOOL , XyOptionsImpl::OPTION_MODE_RW, BOOL_HIDE_SUBTITLES}, + {XyOptionsImpl::OPTION_TYPE_BOOL , XyOptionsImpl::OPTION_MODE_RW, BOOL_ALLOW_MOVING}, {XyOptionsImpl::OPTION_TYPE_SIZE , XyOptionsImpl::OPTION_MODE_READ, SIZE_ORIGINAL_VIDEO}, {XyOptionsImpl::OPTION_TYPE_SIZE , XyOptionsImpl::OPTION_MODE_READ, SIZE_ASS_PLAY_RESOLUTION}, @@ -331,6 +334,7 @@ namespace DirectVobSubXyOptions {XyOptionsImpl::OPTION_TYPE_BOOL , XyOptionsImpl::OPTION_MODE_RW, BOOL_HIDE_TRAY_ICON}, {XyOptionsImpl::OPTION_TYPE_BOOL , XyOptionsImpl::OPTION_MODE_RW, BOOL_HIDE_SUBTITLES}, + {XyOptionsImpl::OPTION_TYPE_BOOL , XyOptionsImpl::OPTION_MODE_RW, BOOL_ALLOW_MOVING}, {XyOptionsImpl::OPTION_TYPE_INT , XyOptionsImpl::OPTION_MODE_RW, INT_MAX_BITMAP_COUNT}, {XyOptionsImpl::OPTION_TYPE_BOOL , XyOptionsImpl::OPTION_MODE_RW, BOOL_COMBINE_BITMAPS}, diff --git a/src/filters/transform/vsfilter/VSFilter.rc b/src/filters/transform/vsfilter/VSFilter.rc index db98a94f7..c6f8351d5 100644 --- a/src/filters/transform/vsfilter/VSFilter.rc +++ b/src/filters/transform/vsfilter/VSFilter.rc @@ -415,7 +415,7 @@ BEGIN CONTROL "Force Default",IDC_CHECKBOX_FORCE_DEFAULT_STYLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,107,55,12 END -IDD_XY_SUB_FILTER_MOREPAGE DIALOGEX 0, 0, 247, 282 +IDD_XY_SUB_FILTER_MOREPAGE DIALOGEX 0, 0, 247, 297 STYLE DS_SETFONT | WS_CHILD | WS_SYSMENU FONT 8, "MS Sans Serif", 400, 0, 0x1 BEGIN @@ -454,6 +454,7 @@ BEGIN "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,212,224,10 LTEXT " (reloading is disabled while showing the property pages)",IDC_STATIC,25,222,182,8 CONTROL "Appl&y changes immediately",IDC_INSTANTUPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,236,104,10 + CONTROL "Allow video renderer to &reposition simple SSA/ASS subtitles",IDC_CHECKBOX_ALLOW_MOVING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,251,224,10 CONTROL "Render To Original Video Size",IDC_CHECKBOX_RENDER_TO_ORIGINAL_VIDEO_SIZE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,127,132,10 EDITTEXT IDC_EDIT_CACHE_SIZE,22,72,40,14,ES_AUTOHSCROLL,WS_EX_RIGHT @@ -742,6 +743,7 @@ BEGIN IDS_RG_EMBEDDEDLOAD "emb_load" IDS_RG_DISABLERELOADER "disable_reloader" IDS_RG_HIDE "hide" + IDS_RG_ALLOWMOVING "allow_moving" IDS_RG_COLOR_SPACE "color_space" IDS_RG_BT601_WIDTH "bt_601_width_for_guess" IDS_RG_BT601_HEIGHT "bt_601_height_for_guess" diff --git a/src/filters/transform/vsfilter/resource.h b/src/filters/transform/vsfilter/resource.h index 4c02d0cff..4f4c45b50 100644 --- a/src/filters/transform/vsfilter/resource.h +++ b/src/filters/transform/vsfilter/resource.h @@ -241,6 +241,8 @@ #define IDC_COLORSEC 1064 #define IDC_COLOROUTL 1065 #define IDC_COLORSHAD 1066 +#define IDS_RG_ALLOWMOVING 1070 +#define IDC_CHECKBOX_ALLOW_MOVING 1071 // Next default values for new objects // diff --git a/src/filters/transform/vsfilter/xy_sub_filter.cpp b/src/filters/transform/vsfilter/xy_sub_filter.cpp index e173b85fb..814b49f2f 100644 --- a/src/filters/transform/vsfilter/xy_sub_filter.cpp +++ b/src/filters/transform/vsfilter/xy_sub_filter.cpp @@ -571,6 +571,14 @@ STDMETHODIMP XySubFilter::XySetBool(unsigned field, bool value) return XyOptionsImpl::XySetBool(field, value); } break; + case BOOL_ALLOW_MOVING: + { + CAutoLock cAutolock1(&m_csFilter); + CRenderedTextSubtitle * rts = dynamic_cast(m_curSubStream); + if (rts) + m_xy_bool_opt[BOOL_IS_MOVABLE] = ((rts->IsMovable()) && ((rts->IsSimple()) || (value))); + } + break; } return DirectVobSubImpl::XySetBool(field, value); } @@ -1237,7 +1245,7 @@ STDMETHODIMP XySubFilter::RequestFrame( REFERENCE_TIME start, REFERENCE_TIME sto if (m_xy_bool_opt[BOOL_IS_MOVABLE]) { CRenderedTextSubtitle * rts = dynamic_cast(m_curSubStream); - if ((rts) && (!rts->IsMovable())) + if ((rts) && ((!rts->IsMovable()) || ((!rts->IsSimple()) && (!m_xy_bool_opt[BOOL_ALLOW_MOVING])))) m_xy_bool_opt[BOOL_IS_MOVABLE] = false; } } @@ -1750,7 +1758,7 @@ void XySubFilter::SetSubtitle( ISubStream* pSubStream, bool fApplyDefStyle /*= t pRTS->Deinit(); playres = pRTS->m_dstScreenSize; m_xy_bool_opt[BOOL_IS_BITMAP] = false; - m_xy_bool_opt[BOOL_IS_MOVABLE] = pRTS->IsMovable(); + m_xy_bool_opt[BOOL_IS_MOVABLE] = ((pRTS->IsMovable()) && ((pRTS->IsSimple()) || (m_xy_bool_opt[BOOL_ALLOW_MOVING]))); } else if(clsid == __uuidof(HdmvSubtitleProvider) || clsid == __uuidof(SupFileSubtitleProvider)) { diff --git a/src/subtitles/RTS.cpp b/src/subtitles/RTS.cpp index 7e1c13a50..48d5373b8 100644 --- a/src/subtitles/RTS.cpp +++ b/src/subtitles/RTS.cpp @@ -3381,7 +3381,7 @@ STDMETHODIMP CRenderedTextSubtitle::RenderEx( IXySubRenderFrame**subRenderFrame, while ( pos!=NULL ) { const CSubtitle2& sub2 = sub2List.GetNext(pos); - if (sub2.s->m_hard_position_level >= POS_LVL_NONE || sub2.s->m_hard_position_level == -1) + if (sub2.s->m_hard_position_level > POS_LVL_NONE) { m_movable = false; break; @@ -3592,6 +3592,11 @@ STDMETHODIMP_(bool) CRenderedTextSubtitle::IsMovable() return m_movable; } +STDMETHODIMP_(bool) CRenderedTextSubtitle::IsSimple() +{ + return m_simple; +} + STDMETHODIMP CRenderedTextSubtitle::Lock() { return CSubPicProviderImpl::Lock(); diff --git a/src/subtitles/RTS.h b/src/subtitles/RTS.h index 313eec431..fc84d3f48 100644 --- a/src/subtitles/RTS.h +++ b/src/subtitles/RTS.h @@ -519,6 +519,7 @@ class CRenderedTextSubtitle : public CSubPicProviderImpl, public ISubStream, pub CompositeDrawItemList* compDrawItemList /*output*/); STDMETHODIMP_(bool) IsColorTypeSupported(int type); STDMETHODIMP_(bool) IsMovable(); + STDMETHODIMP_(bool) IsSimple(); // IPersist STDMETHODIMP GetClassID(CLSID* pClassID);