Skip to content
This repository

video calibration fix #1231

Merged
merged 1 commit into from over 1 year ago

6 participants

Rainer Hochecker Matthias Kortstiege Memphiz jpsdr jmarshallnz Begall
Rainer Hochecker
Collaborator

Video calibrations loading broke after the GUI creation was moved.

This is a bit more flexible than it was because it allows to apply calibrations for resolutions being added while is running. Typical use case when a user connects a projector.

Matthias Kortstiege
Collaborator
vdrfan commented July 31, 2012

+1 for asap merge :)

Rainer Hochecker
Collaborator

Updated

Memphiz
Owner

If the typo is fixed i can confirm that xbmc loads my handcrafted calibration. Good work on that one. If FernetMenta gets to fix the compilation (because of the iHight typo) we should consider merging this fix before the alpha5 tag aswell...

Memphiz
Owner

Well to late - versions already bumped. Assign it to august merge window and merge if you ask me (it will hit nightlies and alpha5 then). Please also track this PR in the August merge thread in the forum.

jmarshallnz
Owner

Fix - merge at will.

jpsdr

Warning : I had a strange issue when tested it. Video played fine on my standard PC with a VGA PC screen, but was totaly broken on my PC to view video, linked by HDMI to my audio receveir, and TV screen afterward. Video was ultra zommed, i think roughly only the upper left quarter was displayed. I'll have to make more test (but compliling is long), to check if it this patch, or if actual git is broken.

Rainer Hochecker
Collaborator

@jpsdr
Make sure your receiver is powered up before you start XBMC.

jpsdr

It is, that's for sure, as all HDMI enter in receiver, and after output to TV => Receiver off => No screen...
Receiver if powered on even before i power on the PC.

Rainer Hochecker
Collaborator

@jpsdr
What is the status? Are you sure this commit breaks your system?

jpsdr

I have to compile two version, one updated to last git i'll do very shortly, and the same with the patch, but compile take around half an hour for me, so, expect me to be back with result no before at least an hour... More likely in two hours.
As i said, it'll take time for me to check.

Memphiz
Owner

Honestly - imo its more then unlikly that this patch leads to the reported problem. Just look at the code. Its doesn't care where you plug in your tv. If the calibrations are not matching for receiver and vga, then its not XBMCs fault imho.

Begall

Did you turn on your xbmc box while the display was shut off? This for me leads to a problem almost exactly as you've described here.

jpsdr

It's not the patch, something broke video display in git update between the 28/07 and yesterday.

Rainer Hochecker
Collaborator

@Memphiz
Check ticket 13224, the problem is in master. Software rendering on Windows is broken,

Rainer Hochecker FernetMenta merged commit dea8c9b into from August 05, 2012
Rainer Hochecker FernetMenta closed this August 05, 2012
Memphiz
Owner

@FernetMenta

Any idea if this PR could lead to growing guisettings.xml on profile changes? (resolutions get written over and over again and make the file huge like gozilla) Described here:

http://forum.xbmc.org/showthread.php?tid=138804&page=2

Couldn't reproduce it.

Rainer Hochecker
Collaborator

A resolution is defined by a string like this "720x480 @ 29.97 - Full Screen". I would assume that this string changes when they switch profiles. Unfortunately all links in the post are expired.

Rainer Hochecker
Collaborator

The vector m_calibrations is not cleared in LoadCalibrations(). This can lead to duplicate entries if settings are loaded more than once. I am not aware that this can happen.
Nevertheless, it is a good practice to do so. Will provide a fix tomorrow with a check for duplicate entries. This way users get rid of duplicates without having to manually edit guisettings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Aug 01, 2012
Rainer Hochecker video calibration fix, broke after 9ad6f4e 0cc8b87
This page is out of date. Refresh to see the latest.
1  xbmc/settings/GUIWindowSettingsScreenCalibration.cpp
@@ -117,6 +117,7 @@ bool CGUIWindowSettingsScreenCalibration::OnMessage(CGUIMessage& message)
117 117
   {
118 118
   case GUI_MSG_WINDOW_DEINIT:
119 119
     {
  120
+      g_settings.UpdateCalibrations();
120 121
       g_settings.Save();
121 122
       g_graphicsContext.SetCalibrating(false);
122 123
       g_windowManager.ShowOverlay(OVERLAY_STATE_SHOWN);
170  xbmc/settings/Settings.cpp
@@ -488,60 +488,114 @@ bool CSettings::LoadCalibration(const TiXmlElement* pRoot, const CStdString& str
488 488
   const TiXmlElement *pResolution = pElement->FirstChildElement("resolution");
489 489
   while (pResolution)
490 490
   {
491  
-    // get the data for this resolution
492  
-    CStdString mode;
493  
-    XMLUtils::GetString(pResolution, "description", mode);
494  
-    // find this resolution in our resolution vector
495  
-    for (unsigned int res = 0; res < m_ResInfo.size(); res++)
496  
-    {
497  
-      if (res == RES_WINDOW)
498  
-        continue;
  491
+    // get the data for this calibration
  492
+    RESOLUTION_INFO cal;
499 493
 
500  
-      if (m_ResInfo[res].strMode == mode)
501  
-      { // found, read in the rest of the information for this item
502  
-        const TiXmlElement *pOverscan = pResolution->FirstChildElement("overscan");
503  
-        if (pOverscan)
504  
-        {
505  
-          GetInteger(pOverscan, "left", m_ResInfo[res].Overscan.left, 0, -m_ResInfo[res].iWidth / 4, m_ResInfo[res].iWidth / 4);
506  
-          GetInteger(pOverscan, "top", m_ResInfo[res].Overscan.top, 0, -m_ResInfo[res].iHeight / 4, m_ResInfo[res].iHeight / 4);
507  
-          GetInteger(pOverscan, "right", m_ResInfo[res].Overscan.right, m_ResInfo[res].iWidth, m_ResInfo[res].iWidth / 2, m_ResInfo[res].iWidth*3 / 2);
508  
-          GetInteger(pOverscan, "bottom", m_ResInfo[res].Overscan.bottom, m_ResInfo[res].iHeight, m_ResInfo[res].iHeight / 2, m_ResInfo[res].iHeight*3 / 2);
509  
-        }
  494
+    XMLUtils::GetString(pResolution, "description", cal.strMode);
  495
+    XMLUtils::GetInt(pResolution, "subtitles", cal.iSubtitles);
  496
+    XMLUtils::GetFloat(pResolution, "pixelratio", cal.fPixelRatio);
  497
+#ifdef HAS_XRANDR
  498
+    XMLUtils::GetFloat(pResolution, "refreshrate", cal.fRefreshRate);
  499
+    XMLUtils::GetString(pResolution, "output", cal.strOutput);
  500
+    XMLUtils::GetString(pResolution, "xrandrid", cal.strId);
  501
+#endif
510 502
 
511  
-        // get the appropriate "safe graphics area" = 10% for 4x3, 3.5% for 16x9
512  
-        float fSafe;
513  
-        if (res == RES_PAL_4x3 || res == RES_NTSC_4x3 || res == RES_PAL60_4x3 || res == RES_HDTV_480p_4x3)
514  
-          fSafe = 0.1f;
515  
-        else
516  
-          fSafe = 0.035f;
517  
-
518  
-        GetInteger(pResolution, "subtitles", m_ResInfo[res].iSubtitles, (int)((1 - fSafe)*m_ResInfo[res].iHeight), m_ResInfo[res].iHeight / 2, m_ResInfo[res].iHeight*5 / 4);
519  
-        GetFloat(pResolution, "pixelratio", m_ResInfo[res].fPixelRatio, 128.0f / 117.0f, 0.5f, 2.0f);
520  
-    /*    CLog::Log(LOGDEBUG, "  calibration for %s %ix%i", m_ResInfo[res].strMode, m_ResInfo[res].iWidth, m_ResInfo[res].iHeight);
521  
-        CLog::Log(LOGDEBUG, "    subtitle yposition:%i pixelratio:%03.3f offsets:(%i,%i)->(%i,%i)",
522  
-                  m_ResInfo[res].iSubtitles, m_ResInfo[res].fPixelRatio,
523  
-                  m_ResInfo[res].Overscan.left, m_ResInfo[res].Overscan.top,
524  
-                  m_ResInfo[res].Overscan.right, m_ResInfo[res].Overscan.bottom);*/
525  
-      }
  503
+    const TiXmlElement *pOverscan = pResolution->FirstChildElement("overscan");
  504
+    if (pOverscan)
  505
+    {
  506
+      XMLUtils::GetInt(pOverscan, "left", cal.Overscan.left);
  507
+      XMLUtils::GetInt(pOverscan, "top", cal.Overscan.top);
  508
+      XMLUtils::GetInt(pOverscan, "right", cal.Overscan.right);
  509
+      XMLUtils::GetInt(pOverscan, "bottom", cal.Overscan.bottom);
526 510
     }
  511
+
  512
+    // mark calibration as not updated
  513
+    // we must not delete those, resolution just might not be available
  514
+    cal.iWidth = cal.iHeight = 0;
  515
+
  516
+    // store calibration
  517
+    m_Calibrations.push_back(cal);
  518
+
527 519
     // iterate around
528 520
     pResolution = pResolution->NextSiblingElement("resolution");
  521
+  }
  522
+  ApplyCalibrations();
  523
+  return true;
  524
+}
529 525
 
  526
+void CSettings::ApplyCalibrations()
  527
+{
  528
+  // apply all calibrations to the resolutions
  529
+  for (size_t i = 0; i < m_Calibrations.size(); ++i)
  530
+  {
  531
+    // find resolutions
  532
+    for (size_t res = 0; res < m_ResInfo.size(); ++res)
  533
+    {
  534
+      if (res == RES_WINDOW)
  535
+        continue;
  536
+      if (m_Calibrations[i].strMode.Equals(m_ResInfo[res].strMode))
  537
+      {
  538
+        // overscan
  539
+        m_ResInfo[res].Overscan.left = m_Calibrations[i].Overscan.left;
  540
+        if (m_ResInfo[res].Overscan.left < -m_ResInfo[res].iWidth/4)
  541
+          m_ResInfo[res].Overscan.left = -m_ResInfo[res].iWidth/4;
  542
+        if (m_ResInfo[res].Overscan.left > m_ResInfo[res].iWidth/4)
  543
+          m_ResInfo[res].Overscan.left = m_ResInfo[res].iWidth/4;
  544
+
  545
+        m_ResInfo[res].Overscan.top = m_Calibrations[i].Overscan.top;
  546
+        if (m_ResInfo[res].Overscan.top < -m_ResInfo[res].iHeight/4)
  547
+          m_ResInfo[res].Overscan.top = -m_ResInfo[res].iHeight/4;
  548
+        if (m_ResInfo[res].Overscan.top > m_ResInfo[res].iHeight/4)
  549
+          m_ResInfo[res].Overscan.top = m_ResInfo[res].iHeight/4;
  550
+
  551
+        m_ResInfo[res].Overscan.right = m_Calibrations[i].Overscan.right;
  552
+        if (m_ResInfo[res].Overscan.right < m_ResInfo[res].iWidth / 2)
  553
+          m_ResInfo[res].Overscan.right = m_ResInfo[res].iWidth / 2;
  554
+        if (m_ResInfo[res].Overscan.right > m_ResInfo[res].iWidth * 3/2)
  555
+          m_ResInfo[res].Overscan.right = m_ResInfo[res].iWidth *3/2;
  556
+
  557
+        m_ResInfo[res].Overscan.bottom = m_Calibrations[i].Overscan.bottom;
  558
+        if (m_ResInfo[res].Overscan.bottom < m_ResInfo[res].iHeight / 2)
  559
+          m_ResInfo[res].Overscan.bottom = m_ResInfo[res].iHeight / 2;
  560
+        if (m_ResInfo[res].Overscan.bottom > m_ResInfo[res].iHeight * 3/2)
  561
+          m_ResInfo[res].Overscan.bottom = m_ResInfo[res].iHeight * 3/2;
  562
+
  563
+        m_ResInfo[res].iSubtitles = m_Calibrations[i].iSubtitles;
  564
+        if (m_ResInfo[res].iSubtitles < m_ResInfo[res].iHeight / 2)
  565
+          m_ResInfo[res].iSubtitles = m_ResInfo[res].iHeight / 2;
  566
+        if (m_ResInfo[res].iSubtitles > m_ResInfo[res].iHeight* 5/4)
  567
+          m_ResInfo[res].iSubtitles = m_ResInfo[res].iHeight* 5/4;
  568
+
  569
+        m_ResInfo[res].fPixelRatio = m_Calibrations[i].fPixelRatio;
  570
+        if (m_ResInfo[res].fPixelRatio < 0.5f)
  571
+          m_ResInfo[res].fPixelRatio = 0.5f;
  572
+        if (m_ResInfo[res].fPixelRatio > 2.0f)
  573
+          m_ResInfo[res].fPixelRatio = 2.0f;
  574
+        break;
  575
+      }
  576
+    }
  577
+  }
  578
+}
530 579
 
531  
-/* Hmm, these stuff shouldn't be releaded, they should be used instead of our internal
532  
-   id counter to select what resolution is affected by this settings
533  
-#ifdef HAS_XRANDR
534  
-    const CStdString def("");
535  
-    CStdString val;
536  
-    GetString(pResolution, "xrandrid", val, def);
537  
-    strncpy(m_ResInfo[iRes].strId, val.c_str(), sizeof(m_ResInfo[iRes].strId));
538  
-    GetString(pResolution, "output", val, def);
539  
-    strncpy(m_ResInfo[iRes].strOutput, val.c_str(), sizeof(m_ResInfo[iRes].strOutput));
540  
-    GetFloat(pResolution, "refreshrate", m_ResInfo[iRes].fRefreshRate, 0, 0, 200);
541  
-#endif
542  
-*/
  580
+void CSettings::UpdateCalibrations()
  581
+{
  582
+  for (size_t res = RES_DESKTOP; res < m_ResInfo.size(); ++res)
  583
+  {
  584
+    // find calibration
  585
+    bool found = false;
  586
+    for (std::vector<RESOLUTION_INFO>::iterator  it = m_Calibrations.begin(); it != m_Calibrations.end(); ++it)
  587
+    {
  588
+      if (it->strMode.Equals(m_ResInfo[res].strMode))
  589
+      {
  590
+        // TODO: erase calibrations with default values
  591
+        (*it) = m_ResInfo[res];
  592
+        found = true;
  593
+        break;
  594
+      }
  595
+    }
  596
+    if (!found)
  597
+      m_Calibrations.push_back(m_ResInfo[res]);
543 598
   }
544  
-  return true;
545 599
 }
546 600
 
547 601
 bool CSettings::SaveCalibration(TiXmlNode* pRootNode) const
@@ -549,28 +603,28 @@ bool CSettings::SaveCalibration(TiXmlNode* pRootNode) const
549 603
   TiXmlElement xmlRootElement("resolutions");
550 604
   TiXmlNode *pRoot = pRootNode->InsertEndChild(xmlRootElement);
551 605
 
552  
-  // save WINDOW, DESKTOP and CUSTOM resolution
553  
-  for (size_t i = RES_WINDOW ; i < m_ResInfo.size() ; i++)
  606
+  // save calibrations
  607
+  for (size_t i = 0 ; i < m_Calibrations.size() ; i++)
554 608
   {
555 609
     // Write the resolution tag
556 610
     TiXmlElement resElement("resolution");
557 611
     TiXmlNode *pNode = pRoot->InsertEndChild(resElement);
558 612
     // Now write each of the pieces of information we need...
559  
-    XMLUtils::SetString(pNode, "description", m_ResInfo[i].strMode);
560  
-    XMLUtils::SetInt(pNode, "subtitles", m_ResInfo[i].iSubtitles);
561  
-    XMLUtils::SetFloat(pNode, "pixelratio", m_ResInfo[i].fPixelRatio);
  613
+    XMLUtils::SetString(pNode, "description", m_Calibrations[i].strMode);
  614
+    XMLUtils::SetInt(pNode, "subtitles", m_Calibrations[i].iSubtitles);
  615
+    XMLUtils::SetFloat(pNode, "pixelratio", m_Calibrations[i].fPixelRatio);
562 616
 #ifdef HAS_XRANDR
563  
-    XMLUtils::SetFloat(pNode, "refreshrate", m_ResInfo[i].fRefreshRate);
564  
-    XMLUtils::SetString(pNode, "output", m_ResInfo[i].strOutput);
565  
-    XMLUtils::SetString(pNode, "xrandrid", m_ResInfo[i].strId);
  617
+    XMLUtils::SetFloat(pNode, "refreshrate", m_Calibrations[i].fRefreshRate);
  618
+    XMLUtils::SetString(pNode, "output", m_Calibrations[i].strOutput);
  619
+    XMLUtils::SetString(pNode, "xrandrid", m_Calibrations[i].strId);
566 620
 #endif
567 621
     // create the overscan child
568 622
     TiXmlElement overscanElement("overscan");
569 623
     TiXmlNode *pOverscanNode = pNode->InsertEndChild(overscanElement);
570  
-    XMLUtils::SetInt(pOverscanNode, "left", m_ResInfo[i].Overscan.left);
571  
-    XMLUtils::SetInt(pOverscanNode, "top", m_ResInfo[i].Overscan.top);
572  
-    XMLUtils::SetInt(pOverscanNode, "right", m_ResInfo[i].Overscan.right);
573  
-    XMLUtils::SetInt(pOverscanNode, "bottom", m_ResInfo[i].Overscan.bottom);
  624
+    XMLUtils::SetInt(pOverscanNode, "left", m_Calibrations[i].Overscan.left);
  625
+    XMLUtils::SetInt(pOverscanNode, "top", m_Calibrations[i].Overscan.top);
  626
+    XMLUtils::SetInt(pOverscanNode, "right", m_Calibrations[i].Overscan.right);
  627
+    XMLUtils::SetInt(pOverscanNode, "bottom", m_Calibrations[i].Overscan.bottom);
574 628
   }
575 629
   return true;
576 630
 }
4  xbmc/settings/Settings.h
@@ -335,6 +335,7 @@ class CSettings
335 335
   int GetCurrentProfileId() const;
336 336
 
337 337
   std::vector<RESOLUTION_INFO> m_ResInfo;
  338
+  std::vector<RESOLUTION_INFO> m_Calibrations;
338 339
 
339 340
   // utility functions for user data folders
340 341
 
@@ -381,6 +382,9 @@ class CSettings
381 382
   static bool GetString(const TiXmlElement* pRootElement, const char *strTagName, CStdString& strValue, const CStdString& strDefaultValue);
382 383
   bool GetString(const TiXmlElement* pRootElement, const char *strTagName, char *szValue, const CStdString& strDefaultValue);
383 384
   bool GetSource(const CStdString &category, const TiXmlNode *source, CMediaSource &share);
  385
+
  386
+  void ApplyCalibrations();
  387
+  void UpdateCalibrations();
384 388
 protected:
385 389
   void GetSources(const TiXmlElement* pRootElement, const CStdString& strTagName, VECSOURCES& items, CStdString& strDefault);
386 390
   bool SetSources(TiXmlNode *root, const char *section, const VECSOURCES &shares, const char *defaultPath);
2  xbmc/windowing/WinSystem.cpp
@@ -45,7 +45,7 @@ CWinSystemBase::~CWinSystemBase()
45 45
 bool CWinSystemBase::InitWindowSystem()
46 46
 {
47 47
   UpdateResolutions();
48  
-
  48
+  g_settings.ApplyCalibrations();
49 49
   return true;
50 50
 }
51 51
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.