summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-07-05 16:57:56 +0200
committerwm4 <wm4@nowhere>2014-07-05 17:07:15 +0200
commit338004bcfc224727d1477d303aa1521bf3ac21be (patch)
tree5066a689bb13f4c00a360d9b33a485d81eb17d72 /player
parent4d2a4afdef24c343b98e71dddcb3382e85c09c96 (diff)
downloadmpv-338004bcfc224727d1477d303aa1521bf3ac21be.tar.bz2
mpv-338004bcfc224727d1477d303aa1521bf3ac21be.tar.xz
dvd, bluray, cdda: add demux_disc containing all related hacks
DVD and Bluray (and to some extent cdda) require awful hacks all over the codebase to make them work. The main reason is that they act like container, but are entirely implemented on the stream layer. The raw mpeg data resulting from these streams must be "extended" with the container-like metadata transported via STREAM_CTRLs. The result were hacks all over demux.c and some higher-level parts. Add a "disc" pseudo-demuxer, and move all these hacks and special-cases to it.
Diffstat (limited to 'player')
-rw-r--r--player/loadfile.c68
-rw-r--r--player/sub.c41
-rw-r--r--player/video.c5
3 files changed, 0 insertions, 114 deletions
diff --git a/player/loadfile.c b/player/loadfile.c
index bae8f74fe9..c2242ea7c2 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -351,14 +351,6 @@ double timeline_set_from_time(struct MPContext *mpctx, double pts, bool *need_re
return -1;
}
-// Map stream number (as used by libdvdread) to MPEG IDs (as used by demuxer).
-static int map_id_from_demuxer(struct demuxer *d, enum stream_type type, int id)
-{
- if (d->stream->uncached_type == STREAMTYPE_DVD && type == STREAM_SUB)
- id = id & 0x1F;
- return id;
-}
-
static int find_new_tid(struct MPContext *mpctx, enum stream_type t)
{
int new_id = 0;
@@ -378,22 +370,6 @@ static struct track *add_stream_track(struct MPContext *mpctx,
struct track *track = mpctx->tracks[i];
if (track->stream == stream)
return track;
- // DVD subtitle track that was added later
- if (stream->type == STREAM_SUB && track->type == STREAM_SUB &&
- map_id_from_demuxer(stream->demuxer, stream->type,
- stream->demuxer_id) == track->demuxer_id
- && !track->stream)
- {
- track->stream = stream;
- track->demuxer_id = stream->demuxer_id;
- // Initialize lazily selected track
- demuxer_select_track(track->demuxer, stream, track->selected);
- if (mpctx->current_track[0][STREAM_SUB] == track)
- reinit_subs(mpctx, 0);
- if (mpctx->current_track[1][STREAM_SUB] == track)
- reinit_subs(mpctx, 1);
- return track;
- }
}
struct track *track = talloc_ptrtype(NULL, track);
@@ -411,21 +387,6 @@ static struct track *add_stream_track(struct MPContext *mpctx,
};
MP_TARRAY_APPEND(mpctx, mpctx->tracks, mpctx->num_tracks, track);
- // Needed for DVD and Blu-ray.
- struct stream *st = track->demuxer->stream;
- if (!track->lang && (st->uncached_type == STREAMTYPE_BLURAY ||
- st->uncached_type == STREAMTYPE_DVD))
- {
- struct stream_lang_req req = {
- .type = track->type,
- .id = map_id_from_demuxer(track->demuxer, track->type,
- track->demuxer_id)
- };
- stream_control(st, STREAM_CTRL_GET_LANG, &req);
- if (req.name[0])
- track->lang = talloc_strdup(track, req.name);
- }
-
demuxer_select_track(track->demuxer, stream, false);
mp_notify(mpctx, MPV_EVENT_TRACKS_CHANGED, NULL);
@@ -439,34 +400,6 @@ void add_demuxer_tracks(struct MPContext *mpctx, struct demuxer *demuxer)
add_stream_track(mpctx, demuxer->streams[n], !!mpctx->timeline);
}
-static void add_dvd_tracks(struct MPContext *mpctx)
-{
- struct demuxer *demuxer = mpctx->demuxer;
- struct stream *stream = demuxer->stream;
- struct stream_dvd_info_req info;
- if (stream->uncached_type != STREAMTYPE_DVD)
- return;
- if (stream_control(stream, STREAM_CTRL_GET_DVD_INFO, &info) > 0) {
- for (int n = 0; n < info.num_subs; n++) {
- struct track *track = talloc_ptrtype(NULL, track);
- *track = (struct track) {
- .type = STREAM_SUB,
- .user_tid = find_new_tid(mpctx, STREAM_SUB),
- .demuxer_id = n,
- .demuxer = mpctx->demuxer,
- };
- MP_TARRAY_APPEND(mpctx, mpctx->tracks, mpctx->num_tracks, track);
-
- struct stream_lang_req req = {.type = STREAM_SUB, .id = n};
- stream_control(stream, STREAM_CTRL_GET_LANG, &req);
- track->lang = talloc_strdup(track, req.name);
-
- mp_notify(mpctx, MPV_EVENT_TRACKS_CHANGED, NULL);
- }
- }
- demuxer_enable_autoselect(demuxer);
-}
-
// Result numerically higher => better match. 0 == no match.
static int match_lang(char **langs, char *lang)
{
@@ -1182,7 +1115,6 @@ goto_reopen_demuxer: ;
mpctx->demuxer = mpctx->timeline[0].source;
main_is_ok: ;
}
- add_dvd_tracks(mpctx);
add_demuxer_tracks(mpctx, mpctx->demuxer);
mpctx->timeline_part = 0;
diff --git a/player/sub.c b/player/sub.c
index e46438e66e..7202eff9e5 100644
--- a/player/sub.c
+++ b/player/sub.c
@@ -158,46 +158,6 @@ void update_subtitles(struct MPContext *mpctx)
update_subtitle(mpctx, 1);
}
-static void set_dvdsub_fake_extradata(struct dec_sub *dec_sub, struct stream *st,
- int width, int height)
-{
- if (!st)
- return;
-
- struct stream_dvd_info_req info;
- if (stream_control(st, STREAM_CTRL_GET_DVD_INFO, &info) < 0)
- return;
-
- struct mp_csp_params csp = MP_CSP_PARAMS_DEFAULTS;
- csp.int_bits_in = 8;
- csp.int_bits_out = 8;
- float cmatrix[3][4];
- mp_get_yuv2rgb_coeffs(&csp, cmatrix);
-
- if (width == 0 || height == 0) {
- width = 720;
- height = 480;
- }
-
- char *s = NULL;
- s = talloc_asprintf_append(s, "size: %dx%d\n", width, height);
- s = talloc_asprintf_append(s, "palette: ");
- for (int i = 0; i < 16; i++) {
- int color = info.palette[i];
- int c[3] = {(color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff};
- mp_map_int_color(cmatrix, 8, c);
- color = (c[2] << 16) | (c[1] << 8) | c[0];
-
- if (i != 0)
- s = talloc_asprintf_append(s, ", ");
- s = talloc_asprintf_append(s, "%06x", color);
- }
- s = talloc_asprintf_append(s, "\n");
-
- sub_set_extradata(dec_sub, s, strlen(s));
- talloc_free(s);
-}
-
static void reinit_subdec(struct MPContext *mpctx, struct track *track,
struct dec_sub *dec_sub)
{
@@ -210,7 +170,6 @@ static void reinit_subdec(struct MPContext *mpctx, struct track *track,
int h = sh_video ? sh_video->disp_h : 0;
float fps = sh_video ? sh_video->fps : 25;
- set_dvdsub_fake_extradata(dec_sub, track->demuxer->stream, w, h);
sub_set_video_res(dec_sub, w, h);
sub_set_video_fps(dec_sub, fps);
sub_set_ass_renderer(dec_sub, mpctx->ass_library, mpctx->ass_renderer);
diff --git a/player/video.c b/player/video.c
index c7d5cd8ddb..3d742c0081 100644
--- a/player/video.c
+++ b/player/video.c
@@ -183,7 +183,6 @@ int reinit_video_chain(struct MPContext *mpctx)
sh->video->disp_w, sh->video->disp_h,
sh->video->fps);
- double ar = -1.0;
//================== Init VIDEO (codec & libvo) ==========================
if (!opts->fixed_vo || !(mpctx->initialized_flags & INITIALIZED_VO)) {
mpctx->video_out = init_best_video_out(mpctx->global, mpctx->input,
@@ -212,10 +211,6 @@ int reinit_video_chain(struct MPContext *mpctx)
vo_control(mpctx->video_out, VOCTRL_GET_HWDEC_INFO, &d_video->hwdec_info);
- if (stream_control(sh->demuxer->stream, STREAM_CTRL_GET_ASPECT_RATIO, &ar)
- != STREAM_UNSUPPORTED)
- d_video->stream_aspect = ar;
-
recreate_video_filters(mpctx);
if (!video_init_best_codec(d_video, opts->video_decoders))