[vlc-commits] OpenGL: display only the left eye of stereo video
Adrien Maglo
git at videolan.org
Wed Nov 15 13:09:54 CET 2017
vlc | branch: master | Adrien Maglo <magsoft at videolan.org> | Wed Nov 15 12:56:29 2017 +0100| [94065d38b867cde3fc4c17eeccdd7e2dd2786e63] | committer: Thomas Guillem
OpenGL: display only the left eye of stereo video
This allows to display an usable view of 360 stereo video.
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=94065d38b867cde3fc4c17eeccdd7e2dd2786e63
---
modules/video_output/opengl/vout_helper.c | 50 +++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/modules/video_output/opengl/vout_helper.c b/modules/video_output/opengl/vout_helper.c
index 1fbbfc3665..caf6b1d579 100644
--- a/modules/video_output/opengl/vout_helper.c
+++ b/modules/video_output/opengl/vout_helper.c
@@ -1561,6 +1561,55 @@ static void DrawWithShaders(vout_display_opengl_t *vgl, struct prgm *prgm)
glDrawElements(GL_TRIANGLES, vgl->nb_indices, GL_UNSIGNED_SHORT, 0);
}
+
+static void GetTextureCropParamsForStereo(unsigned i_nbTextures,
+ const float *stereoCoefs,
+ const float *stereoOffsets,
+ float *left, float *top,
+ float *right, float *bottom)
+{
+ for (unsigned i = 0; i < i_nbTextures; ++i)
+ {
+ float f_2eyesWidth = right[i] - left[i];
+ left[i] = left[i] + f_2eyesWidth * stereoOffsets[0];
+ right[i] = left[i] + f_2eyesWidth * stereoCoefs[0];
+
+ float f_2eyesHeight = bottom[i] - top[i];
+ top[i] = top[i] + f_2eyesHeight * stereoOffsets[1];
+ bottom[i] = top[i] + f_2eyesHeight * stereoCoefs[1];
+ }
+}
+
+static void TextureCropForStereo(vout_display_opengl_t *vgl,
+ float *left, float *top,
+ float *right, float *bottom)
+{
+ float stereoCoefs[2];
+ float stereoOffsets[2];
+
+ switch (vgl->fmt.multiview_mode)
+ {
+ case MULTIVIEW_STEREO_TB:
+ // Display only the left eye.
+ stereoCoefs[0] = 1; stereoCoefs[1] = 0.5;
+ stereoOffsets[0] = 0; stereoOffsets[1] = 0;
+ GetTextureCropParamsForStereo(vgl->prgm->tc->tex_count,
+ stereoCoefs, stereoOffsets,
+ left, top, right, bottom);
+ break;
+ case MULTIVIEW_STEREO_SBS:
+ // Display only the left eye.
+ stereoCoefs[0] = 0.5; stereoCoefs[1] = 1;
+ stereoOffsets[0] = 0; stereoOffsets[1] = 0;
+ GetTextureCropParamsForStereo(vgl->prgm->tc->tex_count,
+ stereoCoefs, stereoOffsets,
+ left, top, right, bottom);
+ break;
+ default:
+ break;
+ }
+}
+
int vout_display_opengl_Display(vout_display_opengl_t *vgl,
const video_format_t *source)
{
@@ -1607,6 +1656,7 @@ int vout_display_opengl_Display(vout_display_opengl_t *vgl,
bottom[j] = (source->i_y_offset + source->i_visible_height) * scale_h;
}
+ TextureCropForStereo(vgl, left, top, right, bottom);
int ret = SetupCoords(vgl, left, top, right, bottom);
if (ret != VLC_SUCCESS)
return ret;
More information about the vlc-commits
mailing list