demux: expose demuxer colorimetry metadata to player

Implementation-wise, the values from the demuxer/codec header are merged
with the values from the decoder such that the former are used only
where the latter are unknown (0/auto).
This commit is contained in:
Niklas Haas 2016-11-08 17:53:55 +01:00 committed by wm4
parent 81ceb7b6a5
commit c676c31815
5 changed files with 23 additions and 0 deletions

View File

@ -1436,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);

View File

@ -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;

View File

@ -100,6 +100,22 @@ const struct m_opt_choice_alternatives mp_chroma_names[] = {
{0}
};
void mp_colorspace_merge(struct mp_colorspace *orig, struct mp_colorspace *new)
{
if (!orig->space)
orig->space = new->space;
if (!orig->levels)
orig->levels = new->levels;
if (!orig->primaries)
orig->primaries = new->primaries;
if (!orig->gamma)
orig->gamma = new->gamma;
if (!orig->nom_peak)
orig->nom_peak = new->nom_peak;
if (!orig->sig_peak)
orig->sig_peak = new->sig_peak;
}
// The short name _must_ match with what vf_stereo3d accepts (if supported).
// The long name in comments is closer to the Matroska spec (StereoMode element).
// The numeric index matches the Matroska StereoMode value. If you add entries

View File

@ -125,6 +125,9 @@ struct mp_colorspace {
float sig_peak; // signal peak, highest value that occurs in the source
};
// Replaces unknown values in the first struct by those of the second struct
void mp_colorspace_merge(struct mp_colorspace *orig, struct mp_colorspace *new);
struct mp_csp_params {
struct mp_colorspace color; // input colorspace
enum mp_csp_levels levels_out; // output device

View File

@ -245,6 +245,7 @@ static void fix_image_params(struct dec_video *d_video,
p.stereo_out = opts->video_stereo_mode;
// Detect colorspace from resolution.
mp_colorspace_merge(&p.color, &c->color);
mp_image_params_guess_csp(&p);
d_video->last_format = *params;