[vlc-commits] [Git][videolan/vlc][master] 4 commits: video_output: add video-stereo-mode option to select the stereoscopic video output mode
Steve Lhomme (@robUx4)
gitlab at videolan.org
Mon Jan 20 14:57:06 UTC 2025
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
5a41b8fd by Mohammed (Shaan) Huzaifa Danish at 2025-01-20T14:43:58+00:00
video_output: add video-stereo-mode option to select the stereoscopic video output mode
New options:
Auto-detect (default), Stereo, Left Only, Right Only, Side by Side
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
- - - - -
0ff84b80 by Mohammed (Shaan) Huzaifa Danish at 2025-01-20T14:43:58+00:00
video_output: handle the dynamic change of video-stereo-mode
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
- - - - -
87785cfa by Mohammed (Shaan) Huzaifa Danish at 2025-01-20T14:43:58+00:00
qt: add menu options for 3d output
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
- - - - -
8677d4a4 by Mohammed (Shaan) Huzaifa Danish at 2025-01-20T14:43:58+00:00
libvlc: add get/set functions for libVLC stereo mode
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
- - - - -
16 changed files:
- include/vlc/libvlc_media_player.h
- include/vlc_vout.h
- include/vlc_vout_display.h
- lib/libvlc.sym
- lib/media_player.c
- lib/video.c
- modules/gui/qt/menus/menus.cpp
- modules/gui/qt/player/player_controller.cpp
- modules/gui/qt/player/player_controller.hpp
- modules/gui/qt/player/player_controller_p.hpp
- src/libvlc-module.c
- src/video_output/display.c
- src/video_output/video_output.c
- src/video_output/vout_internal.h
- src/video_output/vout_intf.c
- src/video_output/vout_wrapper.h
Changes:
=====================================
include/vlc/libvlc_media_player.h
=====================================
@@ -2040,6 +2040,35 @@ LIBVLC_API int libvlc_video_update_viewpoint( libvlc_media_player_t *p_mi,
const libvlc_video_viewpoint_t *p_viewpoint,
bool b_absolute);
+/**
+ * Video stereo modes
+ */
+typedef enum libvlc_video_stereo_mode_t {
+ libvlc_VideoStereoAuto = 0,
+ libvlc_VideoStereoStereo,
+ libvlc_VideoStereoLeftEye,
+ libvlc_VideoStereoRightEye,
+ libvlc_VideoStereoSideBySide,
+} libvlc_video_stereo_mode_t;
+
+/**
+ * Get current video stereo mode.
+ *
+ * \param p_mi the media player
+ * \return the video stereo mode.
+ */
+LIBVLC_API libvlc_video_stereo_mode_t libvlc_video_get_video_stereo_mode(
+ libvlc_media_player_t *p_mi );
+
+/**
+ * Set new video stereo mode.
+ *
+ * \param p_mi the media player
+ * \param i_mode new video stereo mode
+ */
+LIBVLC_API void libvlc_video_set_video_stereo_mode( libvlc_media_player_t *p_mi,
+ const libvlc_video_stereo_mode_t i_mode );
+
/**
* Get the current subtitle delay. Positive values means subtitles are being
* displayed later, negative values earlier.
=====================================
include/vlc_vout.h
=====================================
@@ -84,6 +84,18 @@ enum vlc_vout_order
VLC_VOUT_ORDER_SECONDARY,
};
+/**
+ * Stereoscopic display mode.
+ */
+typedef enum vlc_stereoscopic_mode_t
+{
+ VIDEO_STEREO_OUTPUT_AUTO = 0,
+ VIDEO_STEREO_OUTPUT_STEREO,
+ VIDEO_STEREO_OUTPUT_LEFT_ONLY,
+ VIDEO_STEREO_OUTPUT_RIGHT_ONLY,
+ VIDEO_STEREO_OUTPUT_SIDE_BY_SIDE,
+} vlc_stereoscopic_mode_t;
+
/*****************************************************************************
* Prototypes
*****************************************************************************/
=====================================
include/vlc_vout_display.h
=====================================
@@ -124,6 +124,7 @@ typedef struct vout_display_cfg {
/** Initial viewpoint when projection != PROJECTION_MODE_RECTANGULAR */
vlc_viewpoint_t viewpoint;
+ vlc_stereoscopic_mode_t stereo_mode; /**< Stereoscopic/3D mode used by the display */
} vout_display_cfg_t;
/**
@@ -316,6 +317,16 @@ struct vlc_display_operations
*/
void (*set_icc_profile)(vout_display_t *, const vlc_icc_profile_t *prof);
+ /**
+ * Notifies the new Stereoscopic 3D mode in \ref vout_display_cfg_t changed.
+ *
+ * May be NULL.
+ *
+ * \retval VLC_SUCCESS if the display handled the change
+ * \retval VLC_EGENERIC if the display handled the change was not handled
+ */
+ int (*set_stereo)(vout_display_t *, vlc_stereoscopic_mode_t);
+
/**
* Notifies a change in the input format.
*
=====================================
lib/libvlc.sym
=====================================
@@ -248,6 +248,7 @@ libvlc_video_get_spu_delay
libvlc_video_get_spu_text_scale
libvlc_video_get_teletext
libvlc_video_get_teletext_transparency
+libvlc_video_get_video_stereo_mode
libvlc_video_set_adjust_float
libvlc_video_set_adjust_int
libvlc_video_set_aspect_ratio
@@ -274,6 +275,7 @@ libvlc_video_set_spu_delay
libvlc_video_set_spu_text_scale
libvlc_video_set_teletext
libvlc_video_set_teletext_transparency
+libvlc_video_set_video_stereo_mode
libvlc_video_take_snapshot
libvlc_video_new_viewpoint
libvlc_video_update_viewpoint
=====================================
lib/media_player.c
=====================================
@@ -696,6 +696,7 @@ libvlc_media_player_new( libvlc_instance_t *instance )
var_Create (mp, "deinterlace", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
var_Create (mp, "deinterlace-mode", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
var_Create (mp, "projection-mode", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
+ var_Create (mp, "video-stereo-mode", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
var_Create (mp, "vbi-page", VLC_VAR_INTEGER);
var_SetInteger (mp, "vbi-page", 100);
=====================================
lib/video.c
=====================================
@@ -308,6 +308,35 @@ int libvlc_video_update_viewpoint( libvlc_media_player_t *p_mi,
return 0;
}
+libvlc_video_stereo_mode_t libvlc_video_get_video_stereo_mode(libvlc_media_player_t *p_mi)
+{
+ static_assert( libvlc_VideoStereoAuto == VIDEO_STEREO_OUTPUT_AUTO &&
+ libvlc_VideoStereoStereo == VIDEO_STEREO_OUTPUT_STEREO &&
+ libvlc_VideoStereoLeftEye == VIDEO_STEREO_OUTPUT_LEFT_ONLY &&
+ libvlc_VideoStereoRightEye == VIDEO_STEREO_OUTPUT_RIGHT_ONLY &&
+ libvlc_VideoStereoSideBySide == VIDEO_STEREO_OUTPUT_SIDE_BY_SIDE,
+ "stereo mode mismatch" );
+
+ return var_GetInteger(p_mi, "video-stereo-mode");
+}
+
+void libvlc_video_set_video_stereo_mode(libvlc_media_player_t *p_mi,
+ const libvlc_video_stereo_mode_t i_mode)
+{
+ /* This will work even if the video is not currently active */
+ var_SetInteger(p_mi, "video-stereo-mode", i_mode);
+
+ /* Apply to current video outputs (if any) */
+ size_t n;
+ vout_thread_t **pp_vouts = GetVouts (p_mi, &n);
+ for (size_t i = 0; i < n; i++)
+ {
+ var_SetInteger (pp_vouts[i], "video-stereo-mode", i_mode);
+ vout_Release(pp_vouts[i]);
+ }
+ free (pp_vouts);
+}
+
int64_t libvlc_video_get_spu_delay( libvlc_media_player_t *p_mi )
{
vlc_player_t *player = p_mi->player;
=====================================
modules/gui/qt/menus/menus.cpp
=====================================
@@ -455,6 +455,9 @@ void VLCMenuBar::VideoMenu( qt_intf_t *p_intf, QMenu *current )
{
current->addMenu(new CheckableListMenu(qtr( "Video &Track" ), THEMIM->getVideoTracks(), QActionGroup::ExclusionPolicy::None, current));
+ current->addSeparator();
+ current->addMenu( new CheckableListMenu(qtr( "&3D Output" ), THEMIM->getVideoStereoMode(), QActionGroup::ExclusionPolicy::Exclusive, current) );
+
current->addSeparator();
/* Surface modifiers */
current->addAction(new BooleanPropertyAction(qtr( "&Fullscreen"), THEMIM, "fullscreen", current));
=====================================
modules/gui/qt/player/player_controller.cpp
=====================================
@@ -221,6 +221,7 @@ void PlayerControllerPrivate::UpdateVouts(vout_thread_t **vouts, size_t i_vouts,
if (m_hasVideo)
main_vout = vouts[0];
+ m_videoStereoMode.resetObject( main_vout );
m_zoom.resetObject( main_vout );
m_aspectRatio.resetObject( main_vout );
m_crop.resetObject( main_vout );
@@ -1114,6 +1115,7 @@ PlayerControllerPrivate::PlayerControllerPrivate(PlayerController *playercontrol
, m_titleList(m_player)
, m_chapterList(m_player)
, m_programList(m_player)
+ , m_videoStereoMode((vout_thread_t*)nullptr, "video-stereo-mode")
, m_zoom((vout_thread_t*)nullptr, "zoom")
, m_aspectRatio((vout_thread_t*)nullptr, "aspect-ratio")
, m_crop((vout_thread_t*)nullptr, "crop")
@@ -2070,6 +2072,7 @@ QABSTRACTLIST_GETTER( TitleListModel, getTitles, m_titleList)
QABSTRACTLIST_GETTER( ChapterListModel,getChapters, m_chapterList)
QABSTRACTLIST_GETTER( AudioDeviceModel, getAudioDevices, m_audioDeviceList)
QABSTRACTLIST_GETTER( ProgramListModel, getPrograms, m_programList)
+QABSTRACTLIST_GETTER( VLCVarChoiceModel, getVideoStereoMode, m_videoStereoMode)
QABSTRACTLIST_GETTER( VLCVarChoiceModel, getZoom, m_zoom)
QABSTRACTLIST_GETTER( VLCVarChoiceModel, getAspectRatio, m_aspectRatio)
QABSTRACTLIST_GETTER( VLCVarChoiceModel, getCrop, m_crop)
=====================================
modules/gui/qt/player/player_controller.hpp
=====================================
@@ -168,6 +168,7 @@ public:
//vout properties
Q_PROPERTY(bool hasVideoOutput READ hasVideoOutput NOTIFY hasVideoOutputChanged FINAL)
+ Q_PROPERTY(VLCVarChoiceModel* videoStereoMode READ getVideoStereoMode CONSTANT FINAL)
Q_PROPERTY(VLCVarChoiceModel* zoom READ getZoom CONSTANT FINAL)
Q_PROPERTY(VLCVarChoiceModel* aspectRatio READ getAspectRatio CONSTANT FINAL)
Q_PROPERTY(VLCVarChoiceModel* crop READ getCrop CONSTANT FINAL)
@@ -350,6 +351,7 @@ public slots:
//vout properties
bool hasVideoOutput() const;
+ VLCVarChoiceModel* getVideoStereoMode();
VLCVarChoiceModel* getZoom();
VLCVarChoiceModel* getAspectRatio();
VLCVarChoiceModel* getCrop();
=====================================
modules/gui/qt/player/player_controller_p.hpp
=====================================
@@ -144,6 +144,7 @@ public:
bool m_teletextTransparent = false;
//vout properties
+ VLCVarChoiceModel m_videoStereoMode;
VLCVarChoiceModel m_zoom;
VLCVarChoiceModel m_aspectRatio;
VLCVarChoiceModel m_crop;
=====================================
src/libvlc-module.c
=====================================
@@ -390,6 +390,19 @@ static const char * const ppsz_deinterlace_mode_text[] = {
#define DEINTERLACE_FILTER_TEXT N_("Deinterlace filter")
#define DEINTERLACE_FILTER_LONGTEXT N_("Deinterlace module to use.")
+#define VIDEO_STEREO_FORMAT_TEXT N_("Video Stereo 3D mode")
+#define VIDEO_STEREO_FORMAT_TEXT_LONGTEXT N_("Set the Video Stereo 3D mode.")
+
+static const int video_stereo_formats[] = {
+ VIDEO_STEREO_OUTPUT_AUTO, VIDEO_STEREO_OUTPUT_STEREO,
+ VIDEO_STEREO_OUTPUT_LEFT_ONLY, VIDEO_STEREO_OUTPUT_RIGHT_ONLY,
+ VIDEO_STEREO_OUTPUT_SIDE_BY_SIDE,
+};
+static const char *const video_stereo_formats_text[] = {
+ N_("Auto"), N_("Stereo"), N_("Left Only"), N_("Right Only"),
+ N_("Side-by-Side"),
+};
+
static const int pi_pos_values[] = { 0, 1, 2, 4, 8, 5, 6, 9, 10 };
static const char *const ppsz_pos_descriptions[] =
{ N_("Center"), N_("Left"), N_("Right"), N_("Top"), N_("Bottom"),
@@ -1678,6 +1691,10 @@ vlc_module_begin ()
add_bool( "video-title-show", true, VIDEO_TITLE_SHOW_TEXT,
VIDEO_TITLE_SHOW_LONGTEXT )
change_safe()
+ add_integer ("video-stereo-mode", VIDEO_STEREO_OUTPUT_AUTO, VIDEO_STEREO_FORMAT_TEXT,
+ VIDEO_STEREO_FORMAT_TEXT_LONGTEXT)
+ change_safe()
+ change_integer_list (video_stereo_formats, video_stereo_formats_text)
add_integer( "video-title-timeout", 5000, VIDEO_TITLE_TIMEOUT_TEXT,
VIDEO_TITLE_TIMEOUT_LONGTEXT )
change_safe()
=====================================
src/video_output/display.c
=====================================
@@ -770,6 +770,24 @@ void vout_SetDisplayProjection(vout_display_t *vd,
vout_display_ChangeProjection(vd, projection);
}
+void vout_SetDisplayStereo(vout_display_t *vd, vlc_stereoscopic_mode_t mode)
+{
+ vout_display_priv_t *osys = container_of(vd, vout_display_priv_t, display);
+
+ if (osys->cfg.stereo_mode != mode) {
+ osys->cfg.stereo_mode = mode;
+ int err;
+ if (vd->ops->set_stereo)
+ err = vd->ops->set_stereo(vd, mode);
+ else
+ err = VLC_ENOTSUP; // not handled, we need to do it in the core
+ if (err != VLC_SUCCESS)
+ {
+ msg_Err(vd, "Failed to change multiview display mode");
+ }
+ }
+}
+
vout_display_t *vout_display_New(vlc_object_t *parent,
const video_format_t *source,
vlc_video_context *vctx,
@@ -799,6 +817,8 @@ vout_display_t *vout_display_New(vlc_object_t *parent,
osys->src_vctx = vctx ? vlc_video_context_Hold( vctx ) : NULL;
+ osys->cfg.stereo_mode = cfg->stereo_mode;
+
/* */
vout_display_t *vd = &osys->display;
vd->source = &osys->source;
=====================================
src/video_output/video_output.c
=====================================
@@ -722,6 +722,18 @@ void vout_ChangeProjection(vout_thread_t *vout,
vlc_queuedmutex_unlock(&sys->display_lock);
}
+void vout_ControlChangeStereo(vout_thread_t *vout, vlc_stereoscopic_mode_t mode)
+{
+ vout_thread_sys_t *sys = VOUT_THREAD_TO_SYS(vout);
+ assert(!sys->dummy);
+
+ vlc_queuedmutex_lock(&sys->display_lock);
+ sys->display_cfg.stereo_mode = mode;
+ if (sys->display != NULL)
+ vout_SetDisplayStereo(sys->display, mode);
+ vlc_queuedmutex_unlock(&sys->display_lock);
+}
+
/* */
static void VoutGetDisplayCfg(vout_thread_sys_t *p_vout, const video_format_t *fmt, vout_display_cfg_t *cfg)
{
@@ -760,6 +772,7 @@ static void VoutGetDisplayCfg(vout_thread_sys_t *p_vout, const video_format_t *f
cfg->display.align.vertical = VLC_VIDEO_ALIGN_TOP;
else if (align_mask & VOUT_ALIGN_BOTTOM)
cfg->display.align.vertical = VLC_VIDEO_ALIGN_BOTTOM;
+ cfg->stereo_mode = var_GetInteger(vout, "video-stereo-mode");
}
/* */
=====================================
src/video_output/vout_internal.h
=====================================
@@ -160,6 +160,7 @@ void vout_ControlChangeSubSources(vout_thread_t *, const char *);
void vout_ControlChangeSubFilters(vout_thread_t *, const char *);
void vout_ChangeSpuChannelMargin(vout_thread_t *, enum vlc_vout_order order, int);
void vout_ChangeViewpoint( vout_thread_t *, const vlc_viewpoint_t *);
+void vout_ControlChangeStereo(vout_thread_t *vout, vlc_stereoscopic_mode_t);
void vout_ChangeIccProfile(vout_thread_t *, vlc_icc_profile_t *);
void vout_ChangeProjection(vout_thread_t *, video_projection_mode_t projection);
void vout_ToggleProjection(vout_thread_t *, bool enabled);
=====================================
src/video_output/vout_intf.c
=====================================
@@ -82,6 +82,8 @@ static int SecondarySubMarginCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
static int ViewpointCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
+static int Stereo3DCallback( vlc_object_t *, char const *,
+ vlc_value_t, vlc_value_t, void * );
static int OverrideProjectionCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
@@ -149,6 +151,18 @@ static const struct
{ VLC_VIDEO_FIT_HEIGHT, N_("Window Height") },
};
+static const struct
+{
+ int i_value;
+ char psz_label[13];
+} p_3D_output_format_values[] = {
+ { VIDEO_STEREO_OUTPUT_AUTO, N_("Auto") },
+ { VIDEO_STEREO_OUTPUT_STEREO, N_("Stereo") },
+ { VIDEO_STEREO_OUTPUT_LEFT_ONLY, N_("Left Only") },
+ { VIDEO_STEREO_OUTPUT_RIGHT_ONLY, N_("Right Only") },
+ { VIDEO_STEREO_OUTPUT_SIDE_BY_SIDE, N_("Side-by-Side") },
+};
+
static void AddCustomRatios( vout_thread_t *p_vout, const char *psz_var,
char *psz_list )
{
@@ -217,6 +231,18 @@ void vout_CreateVars( vout_thread_t *p_vout )
vlc_gettext( p_zoom_values[i].psz_label ) );
}
+ var_Create( p_vout, "video-stereo-mode", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+ var_Change( p_vout, "video-stereo-mode", VLC_VAR_SETTEXT, _("video-stereo-output"), NULL );
+
+ for( size_t i = 0; i < ARRAY_SIZE(p_3D_output_format_values); i++ )
+ {
+ val.i_int = p_3D_output_format_values[i].i_value;
+ var_Change( p_vout, "video-stereo-mode", VLC_VAR_ADDCHOICE, val,
+ vlc_gettext( p_3D_output_format_values[i].psz_label ) );
+ }
+
+ var_AddCallback( p_vout, "video-stereo-mode", Stereo3DCallback, NULL );
+
/* Crop offset vars */
var_Create( p_vout, "crop-left", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
var_Create( p_vout, "crop-top", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
@@ -683,6 +709,15 @@ static int ZoomCallback( vlc_object_t *obj, char const *name,
return VLC_SUCCESS;
}
+static int Stereo3DCallback( vlc_object_t *obj, char const *name,
+ vlc_value_t prev, vlc_value_t cur, void *data )
+{
+ vout_thread_t *p_vout = (vout_thread_t *)obj;
+ (void) name; (void) prev; (void) data;
+ vout_ControlChangeStereo( p_vout, cur.i_int );
+ return VLC_SUCCESS;
+}
+
static int AboveCallback( vlc_object_t *obj, char const *name,
vlc_value_t prev, vlc_value_t cur, void *data )
{
=====================================
src/video_output/vout_wrapper.h
=====================================
@@ -43,6 +43,7 @@ int vout_SetDisplayFormat(vout_display_t *, const video_format_t *fmt,
* profile and always updating the display state to a consistent value */
void vout_SetDisplayIccProfile(vout_display_t *, const vlc_icc_profile_t *);
void vout_SetDisplayProjection(vout_display_t *, video_projection_mode_t);
+void vout_SetDisplayStereo(vout_display_t *, vlc_stereoscopic_mode_t);
#endif /* LIBVLC_VOUT_WRAPPER_H */
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6fed97a363c0580bce3f4cb3d700e5fd3b43b2e2...8677d4a47d201cfadea7c6d314d64d43c53534d8
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6fed97a363c0580bce3f4cb3d700e5fd3b43b2e2...8677d4a47d201cfadea7c6d314d64d43c53534d8
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list