diff options
author | xylosper <darklin20@gmail.com> | 2014-03-25 22:54:58 +0900 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-03-25 15:37:14 +0100 |
commit | b5fe3e9a826243e1edd315b60c0269fd559b0354 (patch) | |
tree | 3c2346154d9810ccd13f7f0a3b71814944a3d665 /player | |
parent | 448b535d4830c8b21d86f554bb354d9670eaee3f (diff) | |
download | mpv-b5fe3e9a826243e1edd315b60c0269fd559b0354.tar.bz2 mpv-b5fe3e9a826243e1edd315b60c0269fd559b0354.tar.xz |
dvdnav: check and update video resolution whenever rendering
Previous implementation updated video resolution when highlight
event was given. However, this may not work if highlight event
is given before video size is queried.
This commit adds checking routine into rendering function, too.
Diffstat (limited to 'player')
-rw-r--r-- | player/dvdnav.c | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/player/dvdnav.c b/player/dvdnav.c index 50b2e93d70..d267d156f8 100644 --- a/player/dvdnav.c +++ b/player/dvdnav.c @@ -48,6 +48,25 @@ struct mp_nav_state { struct sub_bitmap *hi_elem; }; +static inline bool is_valid_size(int size[2]) { + return size[0] >= 1 && size[1] >= 1; +} + +static void update_resolution(struct MPContext *mpctx) { + struct mp_nav_state *nav = mpctx->nav_state; + if (!nav) + return; + if (mpctx->d_sub[0]) + sub_control(mpctx->d_sub[0], SD_CTRL_GET_RESOLUTION, nav->vidsize); + if (!is_valid_size(nav->vidsize)) { + struct mp_image_params vid = {0}; + if (mpctx->d_video) + vid = mpctx->d_video->decoder_output; + nav->vidsize[0] = vid.w; + nav->vidsize[1] = vid.h; + } +} + // Allocate state and enable navigation features. Must happen before // initializing cache, because the cache would read data. Since stream_dvdnav is // in a mode which skips all transitions on reading data (before enabling @@ -183,18 +202,7 @@ void mp_handle_nav(struct MPContext *mpctx) nav->highlight[2] = ev->u.highlight.ex; nav->highlight[3] = ev->u.highlight.ey; nav->hi_visible = ev->u.highlight.display; - int sizes[2] = {0}; - if (mpctx->d_sub[0]) - sub_control(mpctx->d_sub[0], SD_CTRL_GET_RESOLUTION, sizes); - if (sizes[0] < 1 || sizes[1] < 1) { - struct mp_image_params vid = {0}; - if (mpctx->d_video) - vid = mpctx->d_video->decoder_output; - sizes[0] = vid.w; - sizes[1] = vid.h; - } - for (int n = 0; n < 2; n++) - nav->vidsize[n] = sizes[n]; + update_resolution(mpctx); osd_set_nav_highlight(mpctx->osd, mpctx); break; } @@ -242,9 +250,12 @@ void mp_nav_get_highlight(void *priv, struct mp_osd_res res, sub = talloc_zero(nav, struct sub_bitmap); nav->hi_elem = sub; + if (!is_valid_size(nav->vidsize)) { + update_resolution(mpctx); + if (!is_valid_size(nav->vidsize)) + return; + } int sizes[2] = {nav->vidsize[0], nav->vidsize[1]}; - if (sizes[0] < 1 || sizes[1] < 1) - return; if (sizes[0] != nav->subsize[0] || sizes[1] != nav->subsize[1]) { talloc_free(sub->bitmap); sub->bitmap = talloc_array(sub, uint32_t, sizes[0] * sizes[1]); |