Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature 3D SBS mode (not found in any existing media players) #127

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/DSUtil/HdmvClipInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ HRESULT CHdmvClipInfo::ReadProgramInfo()
case VIDEO_STREAM_MPEG1:
case VIDEO_STREAM_MPEG2:
case VIDEO_STREAM_H264:
case VIDEO_STREAM_VC1: {
case VIDEO_STREAM_VC1:
case VIDEO_STREAM_HEVC: {
UINT8 Temp = ReadByte();
BDVM_VideoFormat VideoFormat = (BDVM_VideoFormat)(Temp >> 4);
BDVM_FrameRate FrameRate = (BDVM_FrameRate)(Temp & 0xf);
Expand Down Expand Up @@ -177,7 +178,7 @@ HRESULT CHdmvClipInfo::ReadInfo(LPCTSTR strFile)
}

ReadBuffer(Buff, 4);
if ((memcmp(Buff, "0200", 4) != 0) && (memcmp(Buff, "0100", 4) != 0)) {
if ((memcmp(Buff, "0300", 4) != 0) && (memcmp(Buff, "0200", 4) != 0) && (memcmp(Buff, "0100", 4) != 0)) {
return CloseFile(VFW_E_INVALID_FILE_FORMAT);
}

Expand Down Expand Up @@ -217,6 +218,8 @@ LPCTSTR CHdmvClipInfo::Stream::Format()
return _T("H264");
case VIDEO_STREAM_VC1:
return _T("VC1");
case VIDEO_STREAM_HEVC:
return _T("HEVC");
case AUDIO_STREAM_MPEG1:
return _T("MPEG1");
case AUDIO_STREAM_MPEG2:
Expand Down Expand Up @@ -271,7 +274,7 @@ HRESULT CHdmvClipInfo::ReadPlaylist(CString strPlaylistFile, REFERENCE_TIME& rtD
}

ReadBuffer(Buff, 4);
if ((memcmp(Buff, "0200", 4) != 0) && (memcmp(Buff, "0100", 4) != 0)) {
if ((memcmp(Buff, "0300", 4) != 0) && (memcmp(Buff, "0200", 4) != 0) && (memcmp(Buff, "0100", 4) != 0)) {
return CloseFile(VFW_E_INVALID_FILE_FORMAT);
}

Expand Down Expand Up @@ -359,7 +362,7 @@ HRESULT CHdmvClipInfo::ReadChapters(CString strPlaylistFile, CAtlList<CHdmvClipI
}

ReadBuffer(Buff, 4);
if ((memcmp(Buff, "0200", 4) != 0) && (memcmp(Buff, "0100", 4) != 0)) {
if ((memcmp(Buff, "0300", 4) != 0) && (memcmp(Buff, "0200", 4) != 0) && (memcmp(Buff, "0100", 4) != 0)) {
SAFE_DELETE_ARRAY(rtOffset);
return CloseFile(VFW_E_INVALID_FILE_FORMAT);
}
Expand Down
6 changes: 6 additions & 0 deletions src/SubPic/ISubPic.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ public IUnknown {

STDMETHOD_(bool, ResetDevice)() PURE;
STDMETHOD_(bool, DisplayChange)() PURE;

bool m_3DEnabled;
bool m_3DSquish;
int m_3DLeftVerticalOffset;
int m_3DSeperation;
float m_3DZoom;
};

interface __declspec(uuid("767AEBA8-A084-488a-89C8-F6B74E53A90F"))
Expand Down
103 changes: 102 additions & 1 deletion src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,108 @@ HRESULT CDX9RenderingEngine::RenderVideo(IDirect3DSurface9* pRenderTarget, const
}

if (m_RenderingPath == RENDERING_PATH_DRAW) {
return RenderVideoDrawPath(pRenderTarget, srcRect, destRect);
if (m_3DEnabled)
{
//Left eye

CRect leftDestCopy(destRect);
CRect leftSrcCopy(srcRect);

int w = leftDestCopy.Width();
int h = leftDestCopy.Height();

//move to left quarter
leftDestCopy.left -= w / 4;
leftDestCopy.right -= w / 4;

//half the output size (pring in bpth left and riht)
//as left eye is half the size of a full both eyes
leftDestCopy.left += w / 4;
leftDestCopy.right -= w / 4;

w = leftDestCopy.Width();
h = leftDestCopy.Height();

//Shift up/down as required
leftDestCopy.top -= (m_3DLeftVerticalOffset * h)/1000;
leftDestCopy.bottom -= (m_3DLeftVerticalOffset * h) / 1000;

//Shift inward/outward as required
leftDestCopy.left -= (m_3DSeperation * w)/1000;
leftDestCopy.right -= (m_3DSeperation * w)/1000;

//half the output again as we need to squish so wide expand corrects.
if (m_3DSquish)
{
w = leftDestCopy.Width();
leftDestCopy.left += w / 4;
leftDestCopy.right -= w / 4;
}

//Zoom
w = leftDestCopy.Width();
leftDestCopy.left -= (int)((float)w * m_3DZoom - (float)w);
leftDestCopy.right += (int)((float)w * m_3DZoom - (float)w);
h = leftDestCopy.Height();
leftDestCopy.top -= (int)((float)h * m_3DZoom - (float)h);
leftDestCopy.bottom += (int)((float)h * m_3DZoom - (float)h);

//Trim right half off source
leftSrcCopy.right -= leftSrcCopy.Width() / 2;
RenderVideoDrawPath(pRenderTarget, leftSrcCopy, leftDestCopy);

//Right eye

CRect rightDestCopy(destRect);
CRect rightSrcCopy(srcRect);

w = rightDestCopy.Width();

//move to left quarter
rightDestCopy.left += w / 4;
rightDestCopy.right += w / 4;

//half the output size (pring in bpth left and riht)
//as left eye is half the size of a full both eyes
rightDestCopy.left += w / 4;
rightDestCopy.right -= w / 4;

w = rightDestCopy.Width();
h = rightDestCopy.Height();

//Shift up/down as required
rightDestCopy.top += (m_3DLeftVerticalOffset * h) / 1000;
rightDestCopy.bottom += (m_3DLeftVerticalOffset * h) / 1000;

//Shift inward/outward as required
rightDestCopy.left += (m_3DSeperation * w) / 1000;
rightDestCopy.right += (m_3DSeperation * w) / 1000;

//half the output again as we need to squish so wide expand corrects.
if (m_3DSquish)
{
w = rightDestCopy.Width();
rightDestCopy.left += w / 4;
rightDestCopy.right -= w / 4;
}

//Zoom
w = rightDestCopy.Width();
rightDestCopy.left -= (int)((float)w * m_3DZoom - (float)w);
rightDestCopy.right += (int)((float)w * m_3DZoom - (float)w);
h = rightDestCopy.Height();
rightDestCopy.top -= (int)((float)h * m_3DZoom - (float)h);
rightDestCopy.bottom += (int)(float)(h * m_3DZoom - (float)h);

//Trim left half off source
rightSrcCopy.left += rightSrcCopy.Width() / 2;

return RenderVideoDrawPath(pRenderTarget, rightSrcCopy, rightDestCopy);
}
else
{
return RenderVideoDrawPath(pRenderTarget, srcRect, destRect);
}
} else {
return RenderVideoStretchRectPath(pRenderTarget, srcRect, destRect);
}
Expand Down
18 changes: 14 additions & 4 deletions src/mpc-hc/AppSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ static constexpr wmcmd_base default_wmcmds[] = {
{ ID_FILE_SUBTITLES_LOAD, 'L', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_LOAD_SUBTITLES },
{ ID_FILE_SUBTITLES_SAVE, 'S', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_SAVE_SUBTITLES },
{ ID_FILE_SUBTITLES_DOWNLOAD, 'D', FVIRTKEY | FNOINVERT, IDS_SUBTITLES_DOWNLOAD },
{ ID_FILE_SUBTITLES_UPLOAD, 'U', FVIRTKEY | FNOINVERT, IDS_SUBTITLES_UPLOAD },
{ ID_FILE_SUBTITLES_UPLOAD, 0, FVIRTKEY | FNOINVERT, IDS_SUBTITLES_UPLOAD },
{ ID_FILE_CLOSE_AND_RESTORE, 'C', FVIRTKEY | FCONTROL | FNOINVERT, IDS_AG_CLOSE },
{ ID_FILE_PROPERTIES, VK_F10, FVIRTKEY | FSHIFT | FNOINVERT, IDS_AG_PROPERTIES },
{ ID_FILE_EXIT, 'X', FVIRTKEY | FALT | FNOINVERT, IDS_AG_EXIT },
Expand Down Expand Up @@ -564,7 +564,7 @@ static constexpr wmcmd_base default_wmcmds[] = {
{ ID_MENU_PLAYER_SHORT, VK_APPS, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_77, 0, wmcmd::RUP, wmcmd::RUP },
{ ID_MENU_PLAYER_LONG, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_78 },
{ ID_MENU_FILTERS, 0, FVIRTKEY | FNOINVERT, IDS_AG_FILTERS_MENU },
{ ID_VIEW_OPTIONS, 'O', FVIRTKEY | FNOINVERT, IDS_AG_OPTIONS },
{ ID_VIEW_OPTIONS, 0, FVIRTKEY | FNOINVERT, IDS_AG_OPTIONS },
{ ID_STREAM_AUDIO_NEXT, 'A', FVIRTKEY | FNOINVERT, IDS_AG_NEXT_AUDIO },
{ ID_STREAM_AUDIO_PREV, 'A', FVIRTKEY | FSHIFT | FNOINVERT, IDS_AG_PREV_AUDIO },
{ ID_STREAM_SUB_NEXT, 'S', FVIRTKEY | FNOINVERT, IDS_AG_NEXT_SUBTITLE },
Expand All @@ -585,7 +585,7 @@ static constexpr wmcmd_base default_wmcmds[] = {
{ ID_SHADERS_PRESET_PREV, 0, FVIRTKEY | FNOINVERT, IDS_AG_SHADERS_PRESET_PREV },
{ ID_D3DFULLSCREEN_TOGGLE, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_99 },
{ ID_GOTO_PREV_SUB, 'Y', FVIRTKEY | FNOINVERT, IDS_MPLAYERC_100 },
{ ID_GOTO_NEXT_SUB, 'U', FVIRTKEY | FNOINVERT, IDS_MPLAYERC_101 },
{ ID_GOTO_NEXT_SUB, 0, FVIRTKEY | FNOINVERT, IDS_MPLAYERC_101 },
{ ID_SHIFT_SUB_DOWN, VK_NEXT, FVIRTKEY | FALT | FNOINVERT, IDS_MPLAYERC_102 },
{ ID_SHIFT_SUB_UP, VK_PRIOR, FVIRTKEY | FALT | FNOINVERT, IDS_MPLAYERC_103 },
{ ID_VIEW_DISPLAY_RENDERER_STATS, 'J', FVIRTKEY | FCONTROL | FNOINVERT, IDS_OSD_DISPLAY_RENDERER_STATS },
Expand All @@ -612,7 +612,17 @@ static constexpr wmcmd_base default_wmcmds[] = {
{ ID_EDL_IN, 0, FVIRTKEY | FNOINVERT, IDS_AG_EDL_IN },
{ ID_EDL_OUT, 0, FVIRTKEY | FNOINVERT, IDS_AG_EDL_OUT },
{ ID_EDL_NEWCLIP, 0, FVIRTKEY | FNOINVERT, IDS_AG_EDL_NEW_CLIP },
{ ID_EDL_SAVE, 0, FVIRTKEY | FNOINVERT, IDS_AG_EDL_SAVE }
{ ID_EDL_SAVE, 0, FVIRTKEY | FNOINVERT, IDS_AG_EDL_SAVE },

{ ID_3D_TOGGLE, '3', FVIRTKEY | FNOINVERT, IDS_3D_TOGGLE },
{ ID_3D_MOVE_APART, 'J', FVIRTKEY | FNOINVERT, IDS_3D_MOVE_APART },
{ ID_3D_MOVE_CLOSER, 'L', FVIRTKEY | FNOINVERT, IDS_3D_MOVE_CLOSER },
{ ID_3D_RAISE_LEFT_REL_TO_RIGHT, 'I', FVIRTKEY | FNOINVERT, IDS_3D_RAISE_LEFT_REL_TO_RIGHT },
{ ID_3D_LOWER_LEFT_REL_TO_RIGHT, 'K', FVIRTKEY | FNOINVERT, IDS_3D_LOWER_LEFT_REL_TO_RIGHT },
{ ID_3D_ENLARGE, 'O', FVIRTKEY | FNOINVERT, IDS_3D_ENLARGE },
{ ID_3D_SHRINK, 'U', FVIRTKEY | FNOINVERT, IDS_3D_SHRINK },
{ ID_3D_TOGGLE_HORZIONTAL_SQUISH, 'S', FVIRTKEY | FNOINVERT, IDS_3D_TOGGLE_HORZIONTAL_SQUISH }

};

void CAppSettings::CreateCommands()
Expand Down
67 changes: 66 additions & 1 deletion src/mpc-hc/MainFrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,16 @@ BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_UPDATE_COMMAND_UI_RANGE(ID_ONTOP_DEFAULT, ID_ONTOP_WHILEPLAYINGVIDEO, OnUpdateViewOntop)
ON_COMMAND(ID_VIEW_OPTIONS, OnViewOptions)

//3D Hotkey Handling
ON_COMMAND(ID_3D_TOGGLE, On3DToggle)
ON_COMMAND(ID_3D_TOGGLE_HORZIONTAL_SQUISH, On3DSquish)
ON_COMMAND(ID_3D_RAISE_LEFT_REL_TO_RIGHT, On3DLeftMoveUp)
ON_COMMAND(ID_3D_LOWER_LEFT_REL_TO_RIGHT, On3DLeftMoveDown)
ON_COMMAND(ID_3D_MOVE_CLOSER, On3DMoveTogether)
ON_COMMAND(ID_3D_MOVE_APART, On3DMoveApart)
ON_COMMAND(ID_3D_ENLARGE, On3DZoomIn)
ON_COMMAND(ID_3D_SHRINK, On3DZoomOut)

// Casimir666
ON_UPDATE_COMMAND_UI(ID_VIEW_TEARING_TEST, OnUpdateViewTearingTest)
ON_COMMAND(ID_VIEW_TEARING_TEST, OnViewTearingTest)
Expand Down Expand Up @@ -776,6 +786,11 @@ CMainFrame::CMainFrame()
, m_dLastVideoScaleFactor(0)
, m_bExtOnTop(false)
, m_bIsBDPlay(false)
, m_3DEnabled(false)
, m_3DSquish(true)
, m_3DLeftVerticalOffset(0)
, m_3DSeperation(0)
, m_3DZoom(1.0f)
{
// Don't let CFrameWnd handle automatically the state of the menu items.
// This means that menu items without handlers won't be automatically
Expand Down Expand Up @@ -6842,6 +6857,54 @@ void CMainFrame::OnUpdateViewOntop(CCmdUI* pCmdUI)
}
}

void CMainFrame::On3DToggle()
{
m_3DEnabled = !m_3DEnabled;
set3DSettingsIn_pCAP();
}

void CMainFrame::On3DSquish()
{
m_3DSquish = !m_3DSquish;
set3DSettingsIn_pCAP();
}

void CMainFrame::On3DLeftMoveUp()
{
m_3DLeftVerticalOffset += 2;
set3DSettingsIn_pCAP();
}

void CMainFrame::On3DLeftMoveDown()
{
m_3DLeftVerticalOffset -= 2;
set3DSettingsIn_pCAP();
}

void CMainFrame::On3DMoveTogether()
{
m_3DSeperation -= 10;
set3DSettingsIn_pCAP();
}

void CMainFrame::On3DMoveApart()
{
m_3DSeperation += 10;
set3DSettingsIn_pCAP();
}

void CMainFrame::On3DZoomIn()
{
m_3DZoom *= 1.0246983032;
set3DSettingsIn_pCAP();
}

void CMainFrame::On3DZoomOut()
{
m_3DZoom *= 0.975897;
set3DSettingsIn_pCAP();
}

void CMainFrame::OnViewOptions()
{
ShowOptions();
Expand Down Expand Up @@ -11574,7 +11637,7 @@ int CMainFrame::SetupAudioStreams()

// If the splitter is the internal LAV Splitter and no language preferences
// have been set at splitter level, we can override its choice safely
CComQIPtr<IBaseFilter> pBF = bIsSplitter ? pSS : pObject;
CComQIPtr<IBaseFilter> pBF = (CComQIPtr<IBaseFilter>)(bIsSplitter ? (CComQIPtr<IBaseFilter>) pSS : (CComQIPtr<IBaseFilter>)pObject);
if (pBF && CFGFilterLAV::IsInternalInstance(pBF)) {
bSkipTrack = false;
if (CComQIPtr<ILAVFSettings> pLAVFSettings = pBF) {
Expand Down Expand Up @@ -11868,6 +11931,8 @@ bool CMainFrame::OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD)
m_pMVRSR = m_pCAP;
pMVTO = m_pCAP;

set3DSettingsIn_pCAP();

if (s.fShowOSD || s.fShowDebugInfo) { // Force OSD on when the debug switch is used
if (pVMB) {
m_OSD.Start(m_pVideoWnd, pVMB, IsD3DFullScreenMode());
Expand Down
29 changes: 29 additions & 0 deletions src/mpc-hc/MainFrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,24 @@ class CMainFrame : public CFrameWnd, public CDropClient

bool m_fLiveWM;

bool m_3DEnabled;
bool m_3DSquish;
int m_3DLeftVerticalOffset;
int m_3DSeperation;
float m_3DZoom;

void set3DSettingsIn_pCAP()
{
if (m_pCAP)
{
m_pCAP->m_3DEnabled = m_3DEnabled;
m_pCAP->m_3DSquish = m_3DSquish;
m_pCAP->m_3DLeftVerticalOffset = m_3DLeftVerticalOffset;
m_pCAP->m_3DSeperation = m_3DSeperation;
m_pCAP->m_3DZoom = m_3DZoom;
}
}

void SendStatusMessage(CString msg, int nTimeOut);
CString m_playingmsg, m_closingmsg;

Expand Down Expand Up @@ -669,6 +687,17 @@ class CMainFrame : public CFrameWnd, public CDropClient
afx_msg void OnDisplayChange();
afx_msg void OnWindowPosChanging(WINDOWPOS* lpwndpos);


afx_msg void On3DToggle();
afx_msg void On3DSquish();
afx_msg void On3DLeftMoveUp();
afx_msg void On3DLeftMoveDown();
afx_msg void On3DMoveTogether();
afx_msg void On3DMoveApart();
afx_msg void On3DZoomIn();
afx_msg void On3DZoomOut();


LRESULT OnDpiChanged(WPARAM wParam, LPARAM lParam);

afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
Expand Down
12 changes: 12 additions & 0 deletions src/mpc-hc/mpc-hc.rc
Original file line number Diff line number Diff line change
Expand Up @@ -3673,6 +3673,18 @@ BEGIN
IDS_SUBMENU_COPYURL "Copy URL"
END

STRINGTABLE
BEGIN
IDS_3D_TOGGLE "3D Mode Enable/Disable"
IDS_3D_MOVE_APART "3D Increase Distance"
IDS_3D_MOVE_CLOSER "3D Decrease Distance"
IDS_3D_RAISE_LEFT_REL_TO_RIGHT "3D Raise Left Eye Relative to Right"
IDS_3D_LOWER_LEFT_REL_TO_RIGHT "3D Lower Left Eye Relative to Right"
IDS_3D_ENLARGE "3D Enlarge Both Images"
IDS_3D_SHRINK "3D Shrink Both Images"
IDS_3D_TOGGLE_HORZIONTAL_SQUISH "3D Squish Each Eye's Width 50% Enable/Disable"
END

#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////

Expand Down
Loading