[vlc-devel] [PATCH 1/4] vout: move aspect ratio members from vout_display_state_t to vout_display_cfg_t
Felix Abecassis
felix.abecassis at gmail.com
Mon Feb 10 19:14:50 CET 2014
---
include/vlc_vout_display.h | 5 +++++
include/vlc_vout_wrapper.h | 4 ----
modules/visualization/glspectrum.c | 4 ++--
src/video_output/display.c | 16 ++++++++++++----
src/video_output/video_output.c | 19 +++++++++++++++----
5 files changed, 34 insertions(+), 14 deletions(-)
diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index d99cf7e..870e207 100644
--- a/include/vlc_vout_display.h
+++ b/include/vlc_vout_display.h
@@ -110,6 +110,11 @@ typedef struct {
int den;
} zoom;
+ /* Aspect ratio */
+ struct {
+ int num;
+ int den;
+ } sar;
} vout_display_cfg_t;
/**
diff --git a/include/vlc_vout_wrapper.h b/include/vlc_vout_wrapper.h
index 575a51f..fa2db50 100644
--- a/include/vlc_vout_wrapper.h
+++ b/include/vlc_vout_wrapper.h
@@ -63,10 +63,6 @@ static inline void vout_display_Display(vout_display_t *vd,
typedef struct {
vout_display_cfg_t cfg;
unsigned wm_state;
- struct {
- int num;
- int den;
- } sar;
} vout_display_state_t;
/**
diff --git a/modules/visualization/glspectrum.c b/modules/visualization/glspectrum.c
index 3b0ad9d..bb23acb 100644
--- a/modules/visualization/glspectrum.c
+++ b/modules/visualization/glspectrum.c
@@ -382,8 +382,8 @@ static void *Thread( void *p_data )
state.cfg.is_display_filled = true;
state.cfg.zoom.num = 1;
state.cfg.zoom.den = 1;
- state.sar.num = 1;
- state.sar.den = 1;
+ state.cfg.sar.num = 1;
+ state.cfg.sar.den = 1;
p_sys->p_vd = vout_NewDisplay(p_sys->p_vout, &fmt, &state,
"opengl", 1000000, 1000000);
diff --git a/src/video_output/display.c b/src/video_output/display.c
index 1f38c22..b4c954e 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -1238,8 +1238,18 @@ static vout_display_t *DisplayNew(vout_thread_t *vout,
*cfg = state->cfg;
osys->wm_state_initial = -1;
- osys->sar_initial.num = state->sar.num;
- osys->sar_initial.den = state->sar.den;
+
+ unsigned sar_num = cfg->sar.num * source->i_visible_height;
+ unsigned sar_den = cfg->sar.den * source->i_visible_width;;
+ if (sar_num > 0 && sar_den > 0) {
+ vlc_ureduce(&sar_num, &sar_den, sar_num, sar_den, 0);
+ } else {
+ sar_num = 1;
+ sar_den = 1;
+ }
+ osys->sar_initial.num = sar_num;
+ osys->sar_initial.den = sar_den;
+
vout_display_GetDefaultDisplaySize(&cfg->display.width, &cfg->display.height,
source, cfg);
@@ -1328,8 +1338,6 @@ void vout_DeleteDisplay(vout_display_t *vd, vout_display_state_t *state)
if (!osys->is_wrapper )
state->cfg = osys->cfg;
state->wm_state = osys->wm_state;
- state->sar.num = osys->sar_initial.num;
- state->sar.den = osys->sar_initial.den;
}
VoutDisplayDestroyRender(vd);
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 64bef99..f9d283d 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -607,6 +607,19 @@ static void VoutGetDisplayCfg(vout_thread_t *vout, vout_display_cfg_t *cfg, cons
cfg->align.vertical = VOUT_DISPLAY_ALIGN_TOP;
else if (align_mask & 0x8)
cfg->align.vertical = VOUT_DISPLAY_ALIGN_BOTTOM;
+
+ char* aspect_ratio = var_CreateGetString(vout, "aspect-ratio");
+ unsigned sar_num = 0;
+ unsigned sar_den = 0;
+ if (sscanf(aspect_ratio, "%u:%u", &sar_num, &sar_den) != 2 ||
+ sar_num == 0 || sar_den == 0) {
+ sar_num = 0;
+ sar_den = 0;
+ }
+ vlc_ureduce(&sar_num, &sar_den, sar_num, sar_den, 0);
+ cfg->sar.num = sar_num;
+ cfg->sar.den = sar_den;
+ free(aspect_ratio);
}
vout_window_t * vout_NewDisplayWindow(vout_thread_t *vout, vout_display_t *vd,
@@ -1335,8 +1348,6 @@ static int ThreadStart(vout_thread_t *vout, const vout_display_state_t *state)
state_default.wm_state = below ? VOUT_WINDOW_STATE_BELOW
: above ? VOUT_WINDOW_STATE_ABOVE
: VOUT_WINDOW_STATE_NORMAL;
- state_default.sar.num = 0;
- state_default.sar.den = 0;
state = &state_default;
}
@@ -1438,8 +1449,8 @@ static int ThreadReinit(vout_thread_t *vout,
state.cfg.display.width = 0;
state.cfg.display.height = 0;
}
- state.sar.num = 0;
- state.sar.den = 0;
+ state.cfg.sar.num = 0;
+ state.cfg.sar.den = 0;
/* FIXME current vout "variables" are not in sync here anymore
* and I am not sure what to do */
--
1.8.3.2
More information about the vlc-devel
mailing list