Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add two new Video Options (Slider) for free stretching video width and height #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/media.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,18 @@ mp_create(const char *name, int flags, const char *type)
1, NULL, mp, SETTINGS_INITIAL_UPDATE,
"%", mp->mp_pc, NULL, NULL);

mp->mp_setting_vstretchh =
settings_create_int(mp->mp_setting_video_root, "vstretchh",
_p("Video stretch height"), video_settings.vstretchh, NULL, 0, 240,
1, NULL, mp, SETTINGS_INITIAL_UPDATE,
"%", mp->mp_pc, NULL, NULL);

mp->mp_setting_vstretchw =
settings_create_int(mp->mp_setting_video_root, "vstretchw",
_p("Video stretch width"), video_settings.vstretchw, NULL, 0, 240,
1, NULL, mp, SETTINGS_INITIAL_UPDATE,
"%", mp->mp_pc, NULL, NULL);

mp->mp_setting_av_delta =
settings_create_int(mp->mp_setting_audio_root, "avdelta",
_p("Audio delay"), 0, NULL, -5000, 5000,
Expand Down Expand Up @@ -511,6 +523,8 @@ mp_destroy(media_pipe_t *mp)
setting_destroy(mp->mp_setting_sub_scale);
setting_destroy(mp->mp_setting_sub_on_video);
setting_destroy(mp->mp_setting_vzoom);
setting_destroy(mp->mp_setting_vstretchh);
setting_destroy(mp->mp_setting_vstretchw);

prop_unsubscribe(mp->mp_sub_currenttime);
prop_unsubscribe(mp->mp_sub_stats);
Expand Down
2 changes: 2 additions & 0 deletions src/media.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ typedef struct media_pipe {
struct setting *mp_setting_sub_scale; // Subtitle scaling
struct setting *mp_setting_sub_on_video; // Subtitle always on video
struct setting *mp_setting_vzoom; // Video zoom in %
struct setting *mp_setting_vstretchh; // Video stretch height in %
struct setting *mp_setting_vstretchw; // Video stretch width in %

} media_pipe_t;

Expand Down
36 changes: 36 additions & 0 deletions src/ui/glw/glw_video_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ glw_video_dtor(glw_t *w)

prop_unsubscribe(gv->gv_vo_scaling_sub);
prop_unsubscribe(gv->gv_vzoom_sub);
prop_unsubscribe(gv->gv_vstretchh_sub);
prop_unsubscribe(gv->gv_vstretchw_sub);
prop_unsubscribe(gv->gv_vo_on_video_sub);

free(gv->gv_current_url);
Expand Down Expand Up @@ -392,6 +394,22 @@ glw_video_ctor(glw_t *w)
settings_get_value(gv->gv_mp->mp_setting_vzoom),
NULL);

gv->gv_vstretchh_sub =
prop_subscribe(0,
PROP_TAG_SET_INT, &gv->gv_vstretchh,
PROP_TAG_COURIER, w->glw_root->gr_courier,
PROP_TAG_ROOT,
settings_get_value(gv->gv_mp->mp_setting_vstretchh),
NULL);

gv->gv_vstretchw_sub =
prop_subscribe(0,
PROP_TAG_SET_INT, &gv->gv_vstretchw,
PROP_TAG_COURIER, w->glw_root->gr_courier,
PROP_TAG_ROOT,
settings_get_value(gv->gv_mp->mp_setting_vstretchw),
NULL);

gv->gv_vo_on_video_sub =
prop_subscribe(0,
PROP_TAG_SET_INT, &gv->gv_vo_on_video,
Expand Down Expand Up @@ -521,6 +539,24 @@ glw_video_render(glw_t *w, glw_rctx_t *rc)
if(gv->gv_vzoom != 100) {
float zoom = gv->gv_vzoom / 100.0f;
glw_Scalef(&rc1, zoom, zoom, 1.0);
} else {

if(gv->gv_vstretchh != 0 && gv->gv_vstretchw != 0) {
float stretchh = gv->gv_vstretchh / 100.0f;
float stretchw = gv->gv_vstretchw / 100.0f;
glw_Scalef(&rc1, stretchw, stretchh, 1.0);
} else {

if(gv->gv_vstretchh != 0) {
float stretchh = gv->gv_vstretchh / 100.0f;
glw_Scalef(&rc1, 1.0, stretchh, 1.0);
}

if(gv->gv_vstretchw != 0) {
float stretchw = gv->gv_vstretchw / 100.0f;
glw_Scalef(&rc1, stretchw, 1.0, 1.0);
}
}
}

gv->gv_cfg_cur.gvc_engine->gve_render(gv, &rc1);
Expand Down
6 changes: 6 additions & 0 deletions src/ui/glw/glw_video_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ typedef struct glw_video {
prop_sub_t *gv_vzoom_sub;
int gv_vzoom;

prop_sub_t *gv_vstretchh_sub;
int gv_vstretchh;

prop_sub_t *gv_vstretchw_sub;
int gv_vstretchw;

} glw_video_t;


Expand Down
28 changes: 28 additions & 0 deletions src/video/video_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ set_vzoom(void *opaque, int v)
video_settings.vzoom = v;
}

static void
set_vstretchh(void *opaque, int vh)
{
video_settings.vstretchh = vh;
}

static void
set_vstretchw(void *opaque, int vw)
{
video_settings.vstretchw = vw;
}

static void
set_video_resumemode(void *opaque, const char *str)
{
Expand Down Expand Up @@ -195,7 +207,23 @@ video_settings_init(void)
"%", NULL,
settings_generic_save_settings,
(void *)"videoplayback");

settings_create_int(s, "vstretchh",
_p("Video stretch height"), 0, store, 0, 240,
1, set_vstretchh, NULL,
SETTINGS_INITIAL_UPDATE,
"%", NULL,
settings_generic_save_settings,
(void *)"videoplayback");

settings_create_int(s, "vstretchw",
_p("Video stretch width"), 0, store, 0, 240,
1, set_vstretchw, NULL,
SETTINGS_INITIAL_UPDATE,
"%", NULL,
settings_generic_save_settings,
(void *)"videoplayback");

video_settings.resume_mode = 1;
x = settings_create_multiopt(s, "resumemode",
_p("Resume video playback"),
Expand Down
2 changes: 2 additions & 0 deletions src/video/video_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ struct video_settings {
int stretch_horizontal;
int stretch_fullscreen;
int vzoom;
int vstretchh;
int vstretchw;

enum {
VIDEO_RESUME_NO = 0,
Expand Down