summaryrefslogtreecommitdiffstats
path: root/demux
diff options
context:
space:
mode:
authorMartin Herkt <lachs0r@srsfckn.biz>2016-11-20 18:15:08 +0100
committerMartin Herkt <lachs0r@srsfckn.biz>2016-11-20 18:15:08 +0100
commit8700700de8a4103724796077034f7f254ad974bc (patch)
tree2fce4dee518a202c45c3f16567db36edc92ed914 /demux
parente6b85c91700bee0ddc92e98a30d5021691bd6f65 (diff)
parenteafc273d2c2ae6d247d741202e58ca23dc938cb2 (diff)
downloadmpv-8700700de8a4103724796077034f7f254ad974bc.tar.bz2
mpv-8700700de8a4103724796077034f7f254ad974bc.tar.xz
Merge branch 'master' into release/current
Diffstat (limited to 'demux')
-rw-r--r--demux/demux.c31
-rw-r--r--demux/demux.h1
-rw-r--r--demux/demux_lavf.c4
-rw-r--r--demux/demux_mkv.c41
-rw-r--r--demux/demux_mkv_timeline.c31
-rw-r--r--demux/demux_timeline.c4
-rw-r--r--demux/stheader.h2
7 files changed, 84 insertions, 30 deletions
diff --git a/demux/demux.c b/demux/demux.c
index 3af0651dae..8aa9989de3 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -503,7 +503,7 @@ static double get_refresh_seek_pts(struct demux_internal *in)
// Streams which didn't have any packets yet will return all packets,
// other streams return packets only starting from the last position.
if (ds->last_pos != -1 || ds->last_dts != MP_NOPTS_VALUE)
- ds->refreshing = true;
+ ds->refreshing |= ds->selected;
}
// Seek back to player's current position, with a small offset added.
@@ -681,8 +681,7 @@ static void ds_get_packets(struct demux_stream *ds)
struct demux_internal *in = ds->in;
MP_DBG(in, "reading packet for %s\n", t);
in->eof = false; // force retry
- ds->eof = false;
- while (ds->selected && !ds->head && !ds->eof) {
+ while (ds->selected && !ds->head) {
ds->active = true;
// Note: the following code marks EOF if it can't continue
if (in->threading) {
@@ -692,6 +691,8 @@ static void ds_get_packets(struct demux_stream *ds)
} else {
read_packet(in);
}
+ if (ds->eof)
+ break;
}
}
@@ -1287,16 +1288,18 @@ static struct demuxer *open_given_type(struct mpv_global *global,
demux_changed(in->d_thread, DEMUX_EVENT_ALL);
demux_update(demuxer);
stream_control(demuxer->stream, STREAM_CTRL_SET_READAHEAD, &(int){false});
- struct timeline *tl = timeline_load(global, log, demuxer);
- if (tl) {
- struct demuxer_params params2 = {0};
- params2.timeline = tl;
- struct demuxer *sub = open_given_type(global, log,
- &demuxer_desc_timeline, stream,
- &params2, DEMUX_CHECK_FORCE);
- if (sub)
- return sub;
- timeline_destroy(tl);
+ if (!(params && params->disable_timeline)) {
+ struct timeline *tl = timeline_load(global, log, demuxer);
+ if (tl) {
+ struct demuxer_params params2 = {0};
+ params2.timeline = tl;
+ struct demuxer *sub =
+ open_given_type(global, log, &demuxer_desc_timeline, stream,
+ &params2, DEMUX_CHECK_FORCE);
+ if (sub)
+ return sub;
+ timeline_destroy(tl);
+ }
}
return demuxer;
}
@@ -1660,7 +1663,7 @@ static int cached_demux_control(struct demux_internal *in, int cmd, void *arg)
int num_packets = 0;
for (int n = 0; n < in->num_streams; n++) {
struct demux_stream *ds = in->streams[n]->ds;
- if (ds->active) {
+ if (ds->active && !(!ds->head && ds->eof)) {
r->underrun |= !ds->head && !ds->eof;
r->ts_range[0] = MP_PTS_MAX(r->ts_range[0], ds->base_ts);
r->ts_range[1] = MP_PTS_MIN(r->ts_range[1], ds->last_ts);
diff --git a/demux/demux.h b/demux/demux.h
index 39c2600257..18f52d463d 100644
--- a/demux/demux.h
+++ b/demux/demux.h
@@ -161,6 +161,7 @@ struct demuxer_params {
int matroska_wanted_segment;
bool *matroska_was_valid;
struct timeline *timeline;
+ bool disable_timeline;
// -- demux_open_url() only
int stream_flags;
bool allow_capture;
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c
index 0188801aba..7857934642 100644
--- a/demux/demux_lavf.c
+++ b/demux/demux_lavf.c
@@ -699,6 +699,10 @@ static void handle_new_stream(demuxer_t *demuxer, int i)
AVDictionaryEntry *title = av_dict_get(st->metadata, "title", NULL, 0);
if (title && title->value)
sh->title = talloc_strdup(sh, title->value);
+ if (!sh->title && st->disposition & AV_DISPOSITION_VISUAL_IMPAIRED)
+ sh->title = talloc_asprintf(sh, "visual impaired");
+ if (!sh->title && st->disposition & AV_DISPOSITION_HEARING_IMPAIRED)
+ sh->title = talloc_asprintf(sh, "hearing impaired");
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
if (lang && lang->value)
sh->lang = talloc_strdup(sh, lang->value);
diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c
index 95eab29ec9..63b58cdb15 100644
--- a/demux/demux_mkv.c
+++ b/demux/demux_mkv.c
@@ -107,6 +107,7 @@ typedef struct mkv_track {
double v_frate;
uint32_t colorspace;
int stereo_mode;
+ struct mp_colorspace color;
uint32_t a_channels, a_bps;
float a_sfreq;
@@ -536,6 +537,42 @@ static void parse_trackaudio(struct demuxer *demuxer, struct mkv_track *track,
}
}
+static void parse_trackcolour(struct demuxer *demuxer, struct mkv_track *track,
+ struct ebml_colour *colour)
+{
+ // Note: As per matroska spec, the order is consistent with ISO/IEC
+ // 23001-8:2013/DCOR1, which is the same order used by libavutil/pixfmt.h,
+ // so we can just re-use our avcol_ conversion functions.
+ if (colour->n_matrix_coefficients) {
+ track->color.space = avcol_spc_to_mp_csp(colour->matrix_coefficients);
+ MP_VERBOSE(demuxer, "| + Matrix: %s\n",
+ m_opt_choice_str(mp_csp_names, track->color.space));
+ }
+ if (colour->n_primaries) {
+ track->color.primaries = avcol_pri_to_mp_csp_prim(colour->primaries);
+ MP_VERBOSE(demuxer, "| + Primaries: %s\n",
+ m_opt_choice_str(mp_csp_prim_names, track->color.primaries));
+ }
+ if (colour->n_transfer_characteristics) {
+ track->color.gamma = avcol_trc_to_mp_csp_trc(colour->transfer_characteristics);
+ MP_VERBOSE(demuxer, "| + Gamma: %s\n",
+ m_opt_choice_str(mp_csp_trc_names, track->color.gamma));
+ }
+ if (colour->n_range) {
+ track->color.levels = avcol_range_to_mp_csp_levels(colour->range);
+ MP_VERBOSE(demuxer, "| + Levels: %s\n",
+ m_opt_choice_str(mp_csp_levels_names, track->color.levels));
+ }
+ if (colour->n_mastering_metadata) {
+ struct ebml_mastering_metadata *mastering = &colour->mastering_metadata;
+
+ if (mastering->n_luminance_max) {
+ track->color.sig_peak = mastering->luminance_max;
+ MP_VERBOSE(demuxer, "| + HDR peak: %f\n", track->color.sig_peak);
+ }
+ }
+}
+
static void parse_trackvideo(struct demuxer *demuxer, struct mkv_track *track,
struct ebml_video *video)
{
@@ -575,6 +612,8 @@ static void parse_trackvideo(struct demuxer *demuxer, struct mkv_track *track,
MP_WARN(demuxer, "Unknown StereoMode: %d\n", (int)video->stereo_mode);
}
}
+ if (video->n_colour)
+ parse_trackcolour(demuxer, track, &video->colour);
}
/**
@@ -862,6 +901,7 @@ static int demux_mkv_read_chapters(struct demuxer *demuxer)
if (wanted_edition_uid) {
MP_ERR(demuxer, "Unable to find expected edition uid: %"PRIu64"\n",
wanted_edition_uid);
+ talloc_free(parse_ctx.talloc_ctx);
return -1;
} else {
selected_edition = 0;
@@ -1396,6 +1436,7 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track)
sh_v->par_h = p.p_h;
sh_v->stereo_mode = track->stereo_mode;
+ sh_v->color = track->color;
done:
demux_add_sh_stream(demuxer, sh);
diff --git a/demux/demux_mkv_timeline.c b/demux/demux_mkv_timeline.c
index 30d669c77f..15f9a5d594 100644
--- a/demux/demux_mkv_timeline.c
+++ b/demux/demux_mkv_timeline.c
@@ -170,6 +170,7 @@ static bool check_file_seg(struct tl_ctx *ctx, char *filename, int segment)
.matroska_wanted_uids = ctx->uids,
.matroska_wanted_segment = segment,
.matroska_was_valid = &was_valid,
+ .disable_timeline = true,
.disable_cache = true,
};
struct mp_cancel *cancel = ctx->tl->cancel;
@@ -187,27 +188,31 @@ static bool check_file_seg(struct tl_ctx *ctx, char *filename, int segment)
if (ctx->sources[i])
continue;
/* Accept the source if the segment uid matches and the edition
- * either matches or isn't specified. */
+ * either matches or isn't specified. */
if (!memcmp(uid->segment, m->uid.segment, 16) &&
(!uid->edition || uid->edition == m->uid.edition))
{
MP_INFO(ctx, "Match for source %d: %s\n", i, d->filename);
- for (int j = 0; j < m->num_ordered_chapters; j++) {
- struct matroska_chapter *c = m->ordered_chapters + j;
+ if (!uid->edition) {
+ m->uid.edition = 0;
+ } else {
+ for (int j = 0; j < m->num_ordered_chapters; j++) {
+ struct matroska_chapter *c = m->ordered_chapters + j;
- if (!c->has_segment_uid)
- continue;
+ if (!c->has_segment_uid)
+ continue;
- if (has_source_request(ctx, &c->uid))
- continue;
+ if (has_source_request(ctx, &c->uid))
+ continue;
- /* Set the requested segment. */
- MP_TARRAY_GROW(NULL, ctx->uids, ctx->num_sources);
- ctx->uids[ctx->num_sources] = c->uid;
+ /* Set the requested segment. */
+ MP_TARRAY_GROW(NULL, ctx->uids, ctx->num_sources);
+ ctx->uids[ctx->num_sources] = c->uid;
- /* Add a new source slot. */
- MP_TARRAY_APPEND(NULL, ctx->sources, ctx->num_sources, NULL);
+ /* Add a new source slot. */
+ MP_TARRAY_APPEND(NULL, ctx->sources, ctx->num_sources, NULL);
+ }
}
if (stream_wants_cache(d->stream, ctx->opts->stream_cache)) {
@@ -378,7 +383,7 @@ static void build_timeline_loop(struct tl_ctx *ctx,
/* If we're the source or it's a non-ordered edition reference,
* just add a timeline part from the source. */
- if (current_source == j || !linked_m->num_ordered_chapters) {
+ if (current_source == j || !linked_m->uid.edition) {
uint64_t source_full_length =
demuxer_get_time_length(linked_source) * 1e9;
uint64_t source_length = source_full_length - c->start;
diff --git a/demux/demux_timeline.c b/demux/demux_timeline.c
index a7024fef16..8784dcf8f6 100644
--- a/demux/demux_timeline.c
+++ b/demux/demux_timeline.c
@@ -93,7 +93,6 @@ static void switch_segment(struct demuxer *demuxer, struct segment *new,
double start_pts, int flags)
{
struct priv *p = demuxer->priv;
- bool new_segment = p->current != new;
if (!(flags & (SEEK_FORWARD | SEEK_BACKWARD)))
flags |= SEEK_BACKWARD | SEEK_HR;
@@ -107,8 +106,7 @@ static void switch_segment(struct demuxer *demuxer, struct segment *new,
for (int n = 0; n < p->num_streams; n++) {
struct virtual_stream *vs = &p->streams[n];
- if (new_segment)
- vs->new_segment = true;
+ vs->new_segment = true;
vs->eos_packets = 0;
}
diff --git a/demux/stheader.h b/demux/stheader.h
index 8dcd8351a6..240be72a46 100644
--- a/demux/stheader.h
+++ b/demux/stheader.h
@@ -22,6 +22,7 @@
#include "common/common.h"
#include "audio/chmap.h"
+#include "video/csputils.h"
struct MPOpts;
struct demuxer;
@@ -93,6 +94,7 @@ struct mp_codec_params {
int disp_w, disp_h; // display size
int rotate; // intended display rotation, in degrees, [0, 359]
int stereo_mode; // mp_stereo3d_mode (0 if none/unknown)
+ struct mp_colorspace color; // colorspace info where available
// STREAM_VIDEO + STREAM_AUDIO
int bits_per_coded_sample;