Skip to content

Commit

Permalink
Merge pull request #20 from darkxex/master
Browse files Browse the repository at this point in the history
Rewritten interpolation code to 100%
  • Loading branch information
darkxex authored Feb 7, 2022
2 parents e8d0c0f + af51359 commit 89d8151
Showing 1 changed file with 54 additions and 35 deletions.
89 changes: 54 additions & 35 deletions source/UI/playerWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace playerWindows{
static int rotateidx = 0;
static int ignorestyleidx = 0;
static int shaderidx = 0;
static int interpolationidx = 0;



Expand All @@ -50,7 +51,7 @@ namespace playerWindows{
rightmenuposX = item.rightmenu_startpos;
if(item.rightmenu_startpos>1080)item.rightmenu_startpos-=10;
playerWindows::SetupRightWindow();
std::vector<std::string> topmenu = {"Tracks","Chapters","Interpolation","Aspect Ratio","Image","Audio","Subtitle","ShaderMania","Anime4K v4.0.1"};
std::vector<std::string> topmenu = {"Tracks","Chapters","Aspect Ratio","Interpolation","Image","Audio","Subtitle","ShaderMania","Anime4K v4.0.1"};
if (ImGui::Begin("Right Menu Home", nullptr, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollbar)) {
ImGui::SetNextWindowFocus();
if (ImGui::BeginListBox("Right Menu Home List",ImVec2(1280.0f, 720.0f))){
Expand All @@ -63,12 +64,12 @@ namespace playerWindows{
if(topmenu[n] == "Chapters"){
item.rightmenustate = PLAYER_RIGHT_MENU_CHAPTERS;
}
if(topmenu[n] == "Interpolation"){
item.rightmenustate = PLAYER_RIGHT_MENU_INTERPOLATION;
}
if(topmenu[n] == "Aspect Ratio"){
item.rightmenustate = PLAYER_RIGHT_MENU_ARATIO;
}
if(topmenu[n] == "Interpolation"){
item.rightmenustate = PLAYER_RIGHT_MENU_INTERPOLATION;
}
if(topmenu[n] == "Image"){
item.rightmenustate = PLAYER_RIGHT_MENU_IMAGE;
}
Expand Down Expand Up @@ -328,43 +329,61 @@ namespace playerWindows{

void RightHomeInterpolation(bool *focus, bool *first_item){
playerWindows::SetupRightWindow();
std::vector<std::string> topmenu = {"Enable/Disable","Catmull-Rom","Mitchell","Bicubic","OverSample"};
if (ImGui::Begin("Right Menu ARatio", nullptr, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollbar)) {
ImGui::SetNextWindowFocus();
if (ImGui::BeginListBox("Aspect Ratio",ImVec2(200.0f, 720.0f))){
for (unsigned int n = 0; n < topmenu.size(); n++){
static int selected = -1;
if (ImGui::Selectable(topmenu[n].c_str(), selected == n)){
if(n==0){
mpv_command_string(libmpv->getHandle(), "cycle-values video-sync display-resample audio ; cycle-values interpolation yes no ; show-text \"Interpolation: ${interpolation} (${tscale})\"");

}
if(n==1){
mpv_command_string(libmpv->getHandle(), "set tscale \"catmull_rom\" ; show-text \"Interpolation: ${interpolation} (${tscale})\"");

}
if(n==2){
mpv_command_string(libmpv->getHandle(), "set tscale \"mitchell\" ; show-text \"Interpolation: ${interpolation} (${tscale})\"");

}
if(n==3){
mpv_command_string(libmpv->getHandle(), "set tscale \"bicubic\" ; show-text \"Interpolation: ${interpolation} (${tscale})\"");

}
if(n==4){
mpv_command_string(libmpv->getHandle(), "set tscale \"oversample\" ; show-text \"Interpolation: ${interpolation} (${tscale})\"");

if (ImGui::Begin("Right Menu Sub", nullptr, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollbar)) {
ImGui::PushItemWidth(200-10);
auto windowWidth = ImGui::GetWindowSize().x;
//New interpolation
ImGui::SetCursorPosX((windowWidth - ImGui::CalcTextSize("Interpolation", NULL, true).x) * 0.5f);
ImGui::PushItemWidth(200-10);
ImGui::Text("Interpolation");
std::vector<std::string> intermenu = {"Deactivated","Catmull_Rom","Mitchell","Bicubic","OverSample"};
if (ImGui::BeginCombo("Interpolation", intermenu[interpolationidx].c_str(), 0))
{
for (int n = 0; n < intermenu.size(); n++)
{
const bool is_selected = (interpolationidx == n);
if (ImGui::Selectable(intermenu[n].c_str(), is_selected)){
if(n == 0){
interpolationidx = 0;
mpv_command_string(libmpv->getHandle(),"set video-sync audio ; set interpolation no ; show-text \"Interpolation: ${interpolation}\nVideoSync: ${video-sync}\"");
}
if(n == 1){
interpolationidx = 1;
mpv_command_string(libmpv->getHandle(),"set video-sync display-resample ; set interpolation yes ; set tscale catmull_rom ; show-text \"Interpolation: ${interpolation}\nMethod: ${tscale}\nVideoSync: ${video-sync}\"");
}
if(n == 2){
interpolationidx = 2;
mpv_command_string(libmpv->getHandle(),"set video-sync display-resample ; set interpolation yes ; set tscale mitchell ; show-text \"Interpolation: ${interpolation}\nMethod: ${tscale}\nVideoSync: ${video-sync}\"");
}
if(n == 3){
interpolationidx = 3;
mpv_command_string(libmpv->getHandle(),"set video-sync display-resample ; set interpolation yes ; set tscale bicubic ; show-text \"Interpolation: ${interpolation}\nMethod: ${tscale}\nVideoSync: ${video-sync}\"");
}
if(n == 4){
interpolationidx = 4;
mpv_command_string(libmpv->getHandle(),"set video-sync display-resample ; set interpolation yes ; set tscale oversample ; show-text \"Interpolation: ${interpolation}\nMethod: ${tscale}\nVideoSync: ${video-sync}\"");
}
}


if (is_selected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
ImGui::PopItemWidth();
}
if (*first_item) {
ImGui::SetFocusID(ImGui::GetID(topmenu[0].c_str()), ImGui::GetCurrentWindow());
*first_item = false;
ImGui::SetCursorPosY(ImGui::GetWindowSize().y -50);
if(ImGui::Button("Reset to Default")){
interpolationidx = 0;
mpv_command_string(libmpv->getHandle(),"set video-sync audio ; set interpolation no ; show-text \"Interpolation: ${interpolation}\nVideoSync: ${video-sync}\"");

}
ImGui::EndListBox();
}
//end new interpolation


}
playerWindows::ExitWindow();

}
void RightHomeARatio(bool *focus, bool *first_item){
playerWindows::SetupRightWindow();
Expand Down

0 comments on commit 89d8151

Please sign in to comment.