Skip to content
This repository
Browse code

Merge pull request #3574 from afedchin/3d_subs_depth

[3D] add 3D subtitle depth setting
  • Loading branch information...
commit 79aee04c3aa8fb0dd4c05cfde84cd13318fed84a 2 parents 76b5b1c + 12fe554
Joakim Plate authored December 09, 2013
12  language/English/strings.po
@@ -14871,7 +14871,17 @@ msgctxt "#36544"
14871 14871
 msgid "Enable hardware decoding of video files."
14872 14872
 msgstr ""
14873 14873
 
14874  
-#empty strings from id 36545 to 36999
  14874
+#: system/settings/settings.xml
  14875
+msgctxt "#36545"
  14876
+msgid "Subtitle stereoscopic depth"
  14877
+msgstr ""
  14878
+
  14879
+#: system/settings/settings.xml
  14880
+msgctxt "#36546"
  14881
+msgid "Sets the visual depth of subtitles for stereoscopic videos. The higher the value, the closer the subtitles will appear to the viewer."
  14882
+msgstr ""
  14883
+
  14884
+#empty strings from id 36547 to 36999
14875 14885
 #reserved strings 365XX
14876 14886
 
14877 14887
 #: xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp
12  system/settings/settings.xml
@@ -809,6 +809,18 @@
809 809
           <control type="toggle" />
810 810
         </setting>
811 811
       </group>
  812
+      <group id="3">
  813
+        <setting id="subtitles.stereoscopicdepth" type="integer" label="36545" help="36546">
  814
+          <level>0</level>
  815
+          <default>0</default>
  816
+          <constraints>
  817
+            <minimum>0</minimum>
  818
+            <step>1</step>
  819
+            <maximum>10</maximum>
  820
+          </constraints>
  821
+          <control type="spinner" format="integer" delayed="true"/>
  822
+        </setting>
  823
+      </group>
812 824
     </category>
813 825
     <category id="dvds" label="14087" help="36193">
814 826
       <group id="1">
3  xbmc/cores/VideoRenderers/OverlayRendererGUI.cpp
@@ -33,6 +33,7 @@
33 33
 #include "guilib/GUIFont.h"
34 34
 #include "cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayText.h"
35 35
 #include "cores/VideoRenderers/RenderManager.h"
  36
+#include "cores/VideoRenderers/OverlayRendererUtil.h"
36 37
 
37 38
 using namespace OVERLAY;
38 39
 
@@ -165,7 +166,7 @@ void COverlayText::Render(OVERLAY::SRenderState &state)
165 166
   mat.m[0][3] = rd.x1;
166 167
   mat.m[1][3] = rd.y1;
167 168
 
168  
-  float x = state.x, y = state.y;
  169
+  float x = state.x + GetStereoscopicDepth(), y = state.y;
169 170
   mat.InverseTransformPosition(x, y);
170 171
 
171 172
   g_graphicsContext.SetTransform(mat, 1.0f, 1.0f);
11  xbmc/cores/VideoRenderers/OverlayRendererUtil.cpp
@@ -25,6 +25,8 @@
25 25
 #include "cores/dvdplayer/DVDCodecs/Overlay/DVDOverlaySpu.h"
26 26
 #include "cores/dvdplayer/DVDCodecs/Overlay/DVDOverlaySSA.h"
27 27
 #include "windowing/WindowingFactory.h"
  28
+#include "guilib/GraphicContext.h"
  29
+#include "settings/Settings.h"
28 30
 
29 31
 namespace OVERLAY {
30 32
 
@@ -295,4 +297,13 @@ bool convert_quad(ASS_Image* images, SQuads& quads)
295 297
   return true;
296 298
 }
297 299
 
  300
+int GetStereoscopicDepth()
  301
+{
  302
+  int depth = CSettings::Get().GetInt("subtitles.stereoscopicdepth");
  303
+  if (depth && g_graphicsContext.GetStereoMode() && g_graphicsContext.GetStereoMode() != RENDER_STEREO_MODE_MONO)
  304
+    depth *= (g_graphicsContext.GetStereoView() == RENDER_STEREO_VIEW_LEFT ? 1 : -1);
  305
+
  306
+  return depth;
  307
+}
  308
+
298 309
 }
1  xbmc/cores/VideoRenderers/OverlayRendererUtil.h
@@ -64,5 +64,6 @@ namespace OVERLAY {
64 64
                        , int& min_x, int& max_x
65 65
                        , int& min_y, int& max_y);
66 66
   bool      convert_quad(ASS_Image* images, SQuads& quads);
  67
+  int       GetStereoscopicDepth();
67 68
 
68 69
 }
5  xbmc/cores/dvdplayer/DVDOverlayRenderer.cpp
@@ -24,6 +24,7 @@
24 24
 #include "DVDCodecs/Overlay/DVDOverlayText.h"
25 25
 #include "DVDCodecs/Overlay/DVDOverlayImage.h"
26 26
 #include "DVDCodecs/Overlay/DVDOverlaySSA.h"
  27
+#include "cores/VideoRenderers/OverlayRendererUtil.h"
27 28
 
28 29
 #define CLAMP(a, min, max) ((a) > (max) ? (max) : ( (a) < (min) ? (min) : a ))
29 30
 
@@ -72,6 +73,8 @@ void CDVDOverlayRenderer::Render(DVDPictureRenderer* pPicture, CDVDOverlaySSA* p
72 73
 
73 74
   ASS_Image* img = pOverlay->m_libass->RenderImage(width, height, pts);
74 75
 
  76
+  int depth = OVERLAY::GetStereoscopicDepth();
  77
+
75 78
   while(img)
76 79
   {
77 80
     unsigned int color = img->color;
@@ -94,7 +97,7 @@ void CDVDOverlayRenderer::Render(DVDPictureRenderer* pPicture, CDVDOverlaySSA* p
94 97
     uint8_t u     = (uint8_t)(127.5 + 255 * CLAMP(-0.169 * r - 0.331 * g + 0.500 * b, -0.5, 0.5));
95 98
 
96 99
     int y = std::max(0,std::min(img->dst_y, pPicture->height-img->h));
97  
-    int x = std::max(0,std::min(img->dst_x, pPicture->width-img->w));
  100
+    int x = std::max(0,std::min(img->dst_x + depth, pPicture->width-img->w));
98 101
 
99 102
     for(int i=0; i<img->h; i++)
100 103
     {

0 notes on commit 79aee04

Please sign in to comment.
Something went wrong with that request. Please try again.