summaryrefslogtreecommitdiffstats
path: root/sub
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-12-12 01:44:28 +0100
committerwm4 <wm4@nowhere>2013-12-12 01:46:45 +0100
commit053044741713eddc4aea024fb0c175aa01fc092d (patch)
treebdf12e75b406696c19519649a4ba32d0e170e8f0 /sub
parent76ce5434b2716abf063b6d581fe2930825cdecab (diff)
downloadmpv-053044741713eddc4aea024fb0c175aa01fc092d.tar.bz2
mpv-053044741713eddc4aea024fb0c175aa01fc092d.tar.xz
Add prelimimary (basic, possibly broken) dvdnav support
This readds a more or less completely new dvdnav implementation, though it's based on the code from before commit 41fbcee. Note that this is rather basic, and might be broken or not quite usable in many cases. Most importantly, navigation highlights are not correctly implemented. This would require changes in the FFmpeg dvdsub decoder (to apply a different internal CLUT), so supporting it is not really possible right now. And in fact, I don't think I ever want to support it, because it's a very small gain for a lot of work. Instead, mpv will display fake highlights, which are an approximate bounding box around the real highlights. Some things like mouse input or switching audio/subtitles stream using the dvdnav VM are not supported. Might be quite fragile on transitions: if dvdnav initiates a transition, and doesn't give us enough mpeg data to initialize video playback, the player will just quit. This is added only because some users seem to want it. I don't intend to make mpv a good DVD player, so the very basic minimum will have to do. How about you just convert your DVD to proper video files?
Diffstat (limited to 'sub')
-rw-r--r--sub/dec_sub.h1
-rw-r--r--sub/osd.c2
-rw-r--r--sub/osd.h8
-rw-r--r--sub/sd_lavc.c19
4 files changed, 26 insertions, 4 deletions
diff --git a/sub/dec_sub.h b/sub/dec_sub.h
index 4fa62d7b97..36b947fffa 100644
--- a/sub/dec_sub.h
+++ b/sub/dec_sub.h
@@ -19,6 +19,7 @@ struct sd;
enum sd_ctrl {
SD_CTRL_SUB_STEP,
SD_CTRL_SET_VIDEO_PARAMS,
+ SD_CTRL_GET_RESOLUTION,
};
struct dec_sub *sub_create(struct MPOpts *opts);
diff --git a/sub/osd.c b/sub/osd.c
index 66b79f7bb8..ab3764cb00 100644
--- a/sub/osd.c
+++ b/sub/osd.c
@@ -167,6 +167,8 @@ static void render_object(struct osd_state *osd, struct osd_object *obj,
*out_imgs = osd->external2;
osd->external2.bitmap_id = osd->external2.bitmap_pos_id = 0;
}
+ } else if (obj->type == OSDTYPE_NAV_HIGHLIGHT) {
+ mp_nav_get_highlight(osd, obj->vo_res, out_imgs);
} else {
osd_object_get_bitmaps(osd, obj, out_imgs);
}
diff --git a/sub/osd.h b/sub/osd.h
index fc2b76df00..75536f6692 100644
--- a/sub/osd.h
+++ b/sub/osd.h
@@ -86,6 +86,8 @@ enum mp_osdtype {
OSDTYPE_SUB,
OSDTYPE_SUBTEXT,
+ OSDTYPE_NAV_HIGHLIGHT, // dvdnav fake highlights
+
OSDTYPE_PROGBAR,
OSDTYPE_OSD,
@@ -148,6 +150,8 @@ struct osd_state {
struct sub_bitmaps external2;
// OSDTYPE_SUB
struct dec_sub *dec_sub;
+ // OSDTYPE_NAV_HIGHLIGHT
+ void *highlight_priv;
struct MPOpts *opts;
@@ -244,4 +248,8 @@ void osd_get_function_sym(char *buffer, size_t buffer_size, int osd_function);
void osd_init_backend(struct osd_state *osd);
void osd_destroy_backend(struct osd_state *osd);
+// defined in player
+void mp_nav_get_highlight(struct osd_state *osd, struct mp_osd_res res,
+ struct sub_bitmaps *out_imgs);
+
#endif /* MPLAYER_SUB_H */
diff --git a/sub/sd_lavc.c b/sub/sd_lavc.c
index 724a4fe77c..da8a07e48e 100644
--- a/sub/sd_lavc.c
+++ b/sub/sd_lavc.c
@@ -83,6 +83,14 @@ static void guess_resolution(enum AVCodecID type, int *w, int *h)
}
}
+static void get_resolution(struct sd *sd, int wh[2])
+{
+ struct sd_lavc_priv *priv = sd->priv;
+ wh[0] = priv->avctx->width;
+ wh[1] = priv->avctx->height;
+ guess_resolution(priv->avctx->codec_id, &wh[0], &wh[1]);
+}
+
static int init(struct sd *sd)
{
struct sd_lavc_priv *priv = talloc_zero(NULL, struct sd_lavc_priv);
@@ -216,9 +224,7 @@ static void get_bitmaps(struct sd *sd, struct mp_osd_res d, double pts,
if (!priv->outbitmaps)
priv->outbitmaps = talloc_size(priv, size);
memcpy(priv->outbitmaps, priv->inbitmaps, size);
- int inw = priv->avctx->width;
- int inh = priv->avctx->height;
- guess_resolution(priv->avctx->codec_id, &inw, &inh);
+
res->parts = priv->outbitmaps;
res->num_parts = priv->count;
if (priv->bitmaps_changed)
@@ -234,7 +240,9 @@ static void get_bitmaps(struct sd *sd, struct mp_osd_res d, double pts,
(priv->video_params.d_w / (double)priv->video_params.d_h)
/ (priv->video_params.w / (double)priv->video_params.h);
}
- osd_rescale_bitmaps(res, inw, inh, d, video_par);
+ int insize[2];
+ get_resolution(sd, insize);
+ osd_rescale_bitmaps(res, insize[0], insize[1], d, video_par);
}
static void reset(struct sd *sd)
@@ -264,6 +272,9 @@ static int control(struct sd *sd, enum sd_ctrl cmd, void *arg)
case SD_CTRL_SET_VIDEO_PARAMS:
priv->video_params = *(struct mp_image_params *)arg;
return CONTROL_OK;
+ case SD_CTRL_GET_RESOLUTION:
+ get_resolution(sd, arg);
+ return CONTROL_OK;
default:
return CONTROL_UNKNOWN;
}