Compare commits

...
25 Commits
Author SHA1 Message Date
Alessandro Ghedini 18b15a436f Release 0.7.1 2014-12-02 18:24:30 +01:00
Stefano Pigozzi 6583ad6970 cocoa: fix opening reference URLs (.file/id=)
Fixes #1202

/cc @mpv-player/stable
2014-12-01 21:38:51 +01:00
Niklas Haas 863701391c vo_opengl: Linearize non-RGB sRGB files correctly (eg. JPEG)
Signed-off-by: wm4 <wm4@nowhere>
2014-12-01 21:07:26 +01:00
Niklas Haas 3803c14279 vo_opengl: Reword comment in shader
I didn't quite understand this comment after looking at the code again
months later, so I reworded it for better clarity.
2014-12-01 21:07:12 +01:00
wm4 39126c3828 vo_opengl: make operator precedence explicit
More readable.
2014-12-01 21:07:06 +01:00
Stefano Pigozzi b9cfc3622c ao_coreaudio: initialize fetched properties to zeros
Should hopefully fix #1249 and #1279
2014-12-01 21:06:07 +01:00
wm4 1b0bf6507e options: fix channel map options sometimes failing
Channel amp otpions were not copied correctly: it copied the size of a
pointer to struct chmap, not the struct itself. Since mp_chmap is
currently 9 bytes, this meant the last channel entry was not copied
correctly on 64 bit systems, leading to very strange failures. It could
be triggered especially when using the client API, because the client
API always copies options on access (mpv command line options tend to
work directly on options).
2014-12-01 21:06:00 +01:00
wm4 7ca6aa4ad0 options: fix swapped deprecated/replacement in warning
This was relevant for --af and --vo (both use this option type, and have
deprecated aliases).
2014-12-01 21:05:56 +01:00
wm4 b82a98722a player: simplify and fix ordered chapter EOF handling
Ordered chapter EOF was handled as special-case of ending the last
segment. This broke --kee-open, because it set AT_END_OF_FILE in an
"inconvenient" place (after checking for --keep-open, and before the
code that exits playback if EOF is reached).

We don't actually need to handle the last segment specially. Instead, we
remain in the same segment if it ends. The normal playback logic will
recognize EOF, because the end of the segment "cuts off" the file.

Now timeline_set_from_time() never "fails", and we can remove the old
segment EOF handling code in mp_seek().
2014-12-01 21:05:53 +01:00
wm4 3d6d7012ff command: sub_add with "auto" should not always select a subtitle track
Running "sub_add file.srt auto" during hook execution automatically
selected the first added track. This happened because all tracks added
with sub_add are marked as "external", and external subtitles are always
selected by default.

Fix this by negating the "external" flag when autoselecting subtitles
during loading. The no_default flag exists for this purpose; it was
probably added for libquvi originally, where we had the same issue.
2014-12-01 21:05:49 +01:00
wm4 3051ff9f25 mixer: don't show softvol neutral marker on OSD if not using softvol
Also fix the comment on the softvol field.
2014-12-01 21:05:45 +01:00
wm4 9bf66294f8 vo_opengl: fix srgb with certain inputs
Sampling from the source texture and scaling must always be done
separately in this mode.

Fix suggested by haasn.

Still looks a bit wrong, though.
2014-12-01 21:05:20 +01:00
wm4 577378b827 vo_opengl: something
Insert explanation here.

Fixes #1023.
2014-12-01 21:05:15 +01:00
wm4 1679222e18 audio: fix one of the previous commits
Fixes commit 52c51149. It broke multichannel (or possibly everything)
for ao_alsa, ao_oss, ao_sndio.
2014-12-01 18:31:49 +01:00
wm4 74270cd1db audio: allow more than 20 channel map entries
This could trigger an assertion when using ao_alsa or ao_coreaudio. The
code was simply assuming the number of channel maps was bounded
statically (which was true at first in both AOs).

Fix by using dynamic memory allocation. It needs to be explicitly
enabled by the AOs by setting a temp context, because otherwise the
memory couldn't be freed. (Or at least this seems to be the most elegant
solution.)

Fixes #1306.
2014-12-01 15:41:26 +01:00
wm4 718bf3b39e vd_lavc: don't crash if codec could not be opened
Fixes #1307.
2014-12-01 15:41:17 +01:00
wm4 5ecb381d78 demux_playlist: don't ignore last line in m3u
If EOF is reached after reading a line, the EOF flag is set. This was a
problem for the m3u code, which checked for EOF _after_ reading a line,
which will discard the last line read.

Also fix a typo in an unrelated part of the file.
2014-12-01 15:40:57 +01:00
wm4 17f1332955 win32: add screen offset when handling overlarge windows
MS Windows doesn't allow windows larger than the screen, so we include
a hack to make the window smaller. This hack recenters the window (what
else would it do?).

It didn't account for the virtual offset of the current screen, and it
was reported that it forces the window to the first screen.

Should fix #1292.
2014-12-01 15:38:28 +01:00
Stefano Pigozzi f4a1dfdffb build: fix typos
thanks to @Nikoli
2014-11-28 15:51:43 +01:00
James Ross-Gowan d3972125a1 subprocess-win: remove a Vista-only flag
PIPE_REJECT_REMOTE_CLIENTS isn't supported on XP. It's not really
needed, so remove it. Also fix error checking for CreateNamedPipe.
2014-11-28 15:51:39 +01:00
wm4 71f504a43d demux_mkv: fix a possible out of bounds access
The if branch has a weak check to test whether the codec_id is the short
ID, and handles the long IDs in the else branch. The long IDs are all
longer than 12 bytes long, so hardcoding the string offset to get the
trailing part of the name makes sense. But the if condition checks for
another thing, which could get the else branch run even if the codec_id
is short.

Fix the bogus control flow and check if the codec_id is long enough. One
of these checks could be considered redundant, but include them both for
defensive coding.
2014-11-28 15:51:32 +01:00
wm4 bc1370041d audio: alternative fix for previous commit
This is a somewhat obscure situation, and happens only if audio starts
again after it has ended (in particular can happens with files where
audio starts later). It doesn't matter much whether audio starts
immediately or some milliseconds later, so simplify it.
2014-11-28 15:51:03 +01:00
wm4 4f74869cd8 audio: fix busy loop when seeking while paused
When playing paused, the amount of decoded audio is limited to a small
amount (1 sample), because we don't write any audio to the AO when
paused. The small amount could trigger the case of the wanted audio
being too far in the future in the PTS sync code, which set the audio
status to STATUS_DRAINING, which in turn triggered the EOF code in the
next iteration. This was ok, but unfortunately, this triggered another
retry in order to check resuming from EOF by setting the status to
STATUS_SYNCING, which in turn lead to the busy loop by alternating
between the 2 states. So don't try resyncing while paused.

Since the PTS syncing code also calls ao_reset(), this could cause the
pulseaudio daemon to consume some CPU time as well.

This was caused by commit 33b57f55. Before that, the playloop was merely
run more often, but didn't cause any problems.

Fixes #1288.
2014-11-28 15:50:58 +01:00
Alessandro Ghedini 8d8b36df1b manpage: lua: fix typo paramater -> parameter 2014-11-28 15:49:52 +01:00
Alessandro Ghedini 2da6c95208 Release 0.7.0 2014-11-25 20:18:53 +01:00
25 changed files with 212 additions and 61 deletions

No files matched your search

+1
View File
@@ -25,6 +25,7 @@ API changes
::
--- mpv 0.7.0 is released ---
1.10 - deprecate/disable everything directly related to script_dispatch
(most likely affects nobody)
1.9 - add enum mpv_end_file_reason for mpv_event_end_file.reason
+1 -1
View File
@@ -573,7 +573,7 @@ strictly part of the guaranteed API.
Runs an external process and waits until it exits. Returns process status
and the captured output.
The paramater ``t`` is a table. The function reads the following entries:
The parameter ``t`` is a table. The function reads the following entries:
``args``
Array of strings. The first array entry is the executable. This
+97
View File
@@ -0,0 +1,97 @@
Release 0.7.1
=============
Changes
-------
- Don't show the volume neutral marker on the OSD if softvol is disabled.
- Don't select a subtitle track when executing the sub_add input command in
"auto" mode.
Bug fixes
---------
- Fix busy loop when seeking while paused (this fixes a problem with pulseaudio
that caused mpv and the pulseaudio daemon to use 100% CPU).
- Fix Lua function utils.subprocess() in Windows versions older than Vista.
- Avoid creating a window bigger than the screen on Windows.
- Don't ignore the last line in m3u playlists.
- Don't crash if a codec could not be opened.
- Dynamically allocate audio channel map entries (this should fix a crash in
the alsa and coreaudio AOs with audio devices that support more than 20
channel maps).
- Ignore the "srgb" option in the opengl VO if hardware decoding is enabled.
- Linearize non-RGB sRGB files correctly (eg. JPEG).
- Fix opening reference URLs (.file/id=) on OS X.
This listing is not complete. There are many more bug fixes and changes. The
complete change log can be viewed by running ``git log 8d8b36d..6583ad6`` in
the git repository.
Release 0.7.0
=============
Changes
-------
- Buffer partial log messages in the client API (the client API will now only
pass full log messages to clients).
- Remove ncurses/terminfo/termcap support (it was disabled by default and
replaced by new code since v0.6.0).
- Enable cdda:// support by default again (it was disabled since v0.6.0).
- Cascade-load input.conf (if there are several input.confs in the set of valid
config paths, load them all).
- Draw the OSD twice in 3D mode (this fixes subtitles display in 3D mode).
- Make wasapi the default AO on Windows again since many of its problems have
been solved.
- Use "site-functions" subdir to install the zsh completion script instead of
the Debian-specific "vendor-completions" (also provide the --zshdir waf
configure option for changing this value).
- Improve synchronization between the Cocoa GUI and the player (this fixes some
long standing deadlock issues on Mac OS X).
- Remove --fs-missioncontrol option (only relevant to Mac OS X).
New features
------------
- Enable pitch correction by default when playing at higher speeds (this can be
controlled with the --audio-pitch-correction option).
- Open stream and demuxer asynchronously (this should avoid having the player
get blocked on network streams).
- Add cache-buffering-state property for querying the cache fill status until
the player unpauses.
- Add support for listing and selecting the audio device (note that it is not
implemented for all AOs, see the --audio-device option for more information).
- Add support for a JSON-based IPC mechanism (note that this is not currently
supported on Windows, see the JSON IPC section in the manpage for more
information).
- Add Lua utility function for starting processes (see utils.subprocess() in the
manpage).
- Add Lua utility function for parsing JSON (see utils.parse_json() in the
manpage).
- Add field-dominance property (see --field-dominance option).
- Add video-rotate property (see --video-rotate option).
- Add playback-abort property for querying whether playback is stopped or is to
be stopped.
- Add cursor-autohide property (see --cursor-autohide option).
- Add vo-configured property for querying whether a window is created.
- Add support for dxva2 hardware acceleration on Windows.
- Drop libquvi support (this has been replaced by a built-in Lua script that
invokes the youtube-dl tool, which needs to be installed, see the --ytdl
option).
- Add support for loading chapters from an external file (see the
--chapters-file option).
- Add window-minimized property for querying whether the window is minimized
(works for X11 only).
- Make it possible to configure the OSC seekbar style (see the "seekbarstyle"
OSC option).
- Add support for libmpv on Mac OS X (it used to be broken, now it's fully
functional and also provides support for embedding the mpv window inside a
Cocoa/Qt application).
- Try to use the audio channel map reported by ALSA in the alsa AO.
- Add option to disable text OSD rendering completely (useful for working around
certain fontconfig issues, see the --use-text-osd option).
This listing is not complete. There are many more bug fixes and changes. The
complete change log can be viewed by running ``git log 7759c18..9479daa`` in
the git repository.
+1
View File
@@ -0,0 +1 @@
0.7.1
+12 -5
View File
@@ -81,14 +81,21 @@ void mp_chmap_sel_add_alsa_def(struct mp_chmap_sel *s)
}
}
#define ARRAY_LEN(x) (sizeof(x) / sizeof((x)[0]))
// Add a channel map that should be allowed.
void mp_chmap_sel_add_map(struct mp_chmap_sel *s, const struct mp_chmap *map)
{
assert(s->num_chmaps < ARRAY_LEN(s->chmaps));
if (mp_chmap_is_valid(map))
s->chmaps[s->num_chmaps++] = *map;
if (!mp_chmap_is_valid(map))
return;
if (!s->chmaps)
s->chmaps = s->chmaps_storage;
if (s->num_chmaps == MP_ARRAY_SIZE(s->chmaps_storage)) {
if (!s->tmp)
return;
s->chmaps = talloc_memdup(s->tmp, s->chmaps, sizeof(s->chmaps_storage));
}
if (s->chmaps != s->chmaps_storage)
MP_TARRAY_GROW(s->tmp, s->chmaps, s->num_chmaps);
s->chmaps[s->num_chmaps++] = *map;
}
// Allow all waveext formats in default order.
+5 -1
View File
@@ -26,8 +26,12 @@ struct mp_chmap_sel {
// should be considered opaque
bool allow_any, allow_waveext;
bool speakers[MP_SPEAKER_ID_COUNT];
struct mp_chmap chmaps[20];
struct mp_chmap *chmaps;
int num_chmaps;
struct mp_chmap chmaps_storage[20];
void *tmp; // set to any talloc context to allow more chmaps entries
};
void mp_chmap_sel_add_any(struct mp_chmap_sel *s);
+2 -2
View File
@@ -36,7 +36,7 @@ struct mixer {
struct ao *ao;
struct af_stream *af;
// Static, dependent on ao/softvol settings
bool softvol; // use AO (true) or af_volume (false)
bool softvol; // use AO (false) or af_volume (true)
bool ao_softvol; // AO has private or per-app volume
bool emulate_mute; // if true, emulate mute with volume=0
// Last known values (possibly out of sync with reality)
@@ -72,7 +72,7 @@ bool mixer_audio_initialized(struct mixer *mixer)
float mixer_getneutralvolume(struct mixer *mixer)
{
// gain == 1
return 1.0 / mixer->opts->softvol_max * 100.0 * 100.0;
return mixer->softvol ? 1.0 / mixer->opts->softvol_max * 100.0 * 100.0 : 100;
}
static void checkvolume(struct mixer *mixer)
+1 -1
View File
@@ -279,7 +279,7 @@ static int find_alsa_channel(int mp_channel)
static bool query_chmaps(struct ao *ao, struct mp_chmap *chmap)
{
struct priv *p = ao->priv;
struct mp_chmap_sel chmap_sel = {0};
struct mp_chmap_sel chmap_sel = {.tmp = p};
snd_pcm_chmap_query_t **maps = snd_pcm_query_chmaps(p->alsa);
if (!maps)
+1 -1
View File
@@ -185,7 +185,7 @@ static bool init_chmap(struct ao *ao)
&layouts, &n_layouts);
CHECK_CA_ERROR("could not get audio device prefered layouts");
struct mp_chmap_sel chmap_sel = {0};
struct mp_chmap_sel chmap_sel = {.tmp = p};
for (int i = 0; i < n_layouts; i++) {
struct mp_chmap chmap = {0};
if (ca_layout_to_mp_chmap(ao, &layouts[i], &chmap))
+2 -2
View File
@@ -62,7 +62,7 @@ OSStatus ca_get_ary(AudioObjectID id, ca_scope scope, ca_sel selector,
err = AudioObjectGetPropertyDataSize(id, &p_addr, 0, NULL, &p_size);
CHECK_CA_ERROR_SILENT_L(coreaudio_error);
*data = talloc_size(NULL, p_size);
*data = talloc_zero_size(NULL, p_size);
*elements = p_size / element_size;
err = ca_get(id, scope, selector, p_size, *data);
@@ -87,7 +87,7 @@ OSStatus ca_get_str(AudioObjectID id, ca_scope scope, ca_sel selector,
CFStringGetMaximumSizeForEncoding(
CFStringGetLength(string), CA_CFSTR_ENCODING) + 1;
*data = talloc_size(NULL, size);
*data = talloc_zero_size(NULL, size);
CFStringGetCString(string, *data, size, CA_CFSTR_ENCODING);
CFRelease(string);
coreaudio_error:
+8 -6
View File
@@ -1414,20 +1414,22 @@ static int demux_mkv_open_audio(demuxer_t *demuxer, mkv_track_t *track)
sh_a->bitrate = 16000 * 8;
sh_a->block_align = 1024;
if (!strcmp(track->codec_id, MKV_A_AAC) && track->private_data) {
if (!extradata_len) {
if (!strcmp(track->codec_id, MKV_A_AAC)) {
if (track->private_data && !extradata_len) {
extradata = track->private_data;
extradata_len = track->private_size;
}
} else {
/* Recreate the 'private data' */
/* which faad2 uses in its initialization */
srate_idx = aac_get_sample_rate_index(track->a_sfreq);
if (!strncmp(&track->codec_id[12], "MAIN", 4))
const char *tail = "";
if (strlen(track->codec_id) >= 12)
tail = &track->codec_id[12];
if (!strncmp(tail, "MAIN", 4))
profile = 0;
else if (!strncmp(&track->codec_id[12], "LC", 2))
else if (!strncmp(tail, "LC", 2))
profile = 1;
else if (!strncmp(&track->codec_id[12], "SSR", 3))
else if (!strncmp(tail, "SSR", 3))
profile = 2;
else
profile = 3;
+2 -2
View File
@@ -86,7 +86,7 @@ static int parse_m3u(struct pl_parser *p)
return -1;
if (p->probing)
return 0;
while (!pl_eof(p)) {
while (line.len || !pl_eof(p)) {
if (line.len > 0 && !bstr_startswith0(line, "#"))
pl_add(p, line);
line = bstr_strip(pl_get_line(p));
@@ -110,7 +110,7 @@ static int parse_ref_init(struct pl_parser *p)
"application/vnd.ms.wms-hdr.asfv1", NULL};
bstr burl = bstr0(p->s->url);
if (bstr_eatstart0(&burl, "http://") && check_mimetype(p->s, mmsh_types)) {
MP_INFO(p, "Redirectiong to mmsh://\n");
MP_INFO(p, "Redirecting to mmsh://\n");
playlist_add_file(p->pl, talloc_asprintf(p, "mmsh://%.*s", BSTR_P(burl)));
return 0;
}
+2 -2
View File
@@ -2146,7 +2146,7 @@ static int parse_chmap(struct mp_log *log, const m_option_t *opt,
const m_option_type_t m_option_type_chmap = {
.name = "Audio channels or channel map",
.size = sizeof(struct mp_chmap *),
.size = sizeof(struct mp_chmap),
.parse = parse_chmap,
.copy = copy_opt,
};
@@ -2620,7 +2620,7 @@ static int parse_obj_settings(struct mp_log *log, struct bstr opt,
if (m_obj_list_find(&desc, list, str)) {
if (desc.replaced_name)
mp_warn(log, "Driver '%s' has been replaced with '%s'!\n",
desc.name, desc.replaced_name);
desc.replaced_name, desc.name);
} else {
if (!list->allow_unknown_entries) {
mp_err(log, "Option %.*s: %.*s doesn't exist.\n",
+4 -2
View File
@@ -440,8 +440,10 @@ void cocoa_set_input_context(struct input_ctx *input_context)
size_t num_files = [files count];
char **files_utf8 = talloc_array(NULL, char*, num_files);
[files enumerateObjectsUsingBlock:^(id obj, NSUInteger i, BOOL *_){
char *filename = (char *)[obj UTF8String];
size_t bytes = [obj lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString:obj];
NSString *path = [url path];
char *filename = (char *)[path UTF8String];
size_t bytes = [path lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
files_utf8[i] = talloc_memdup(files_utf8, filename, bytes + 1);
}];
mp_event_drop_files(_inputContext, num_files, files_utf8);
+2 -3
View File
@@ -111,9 +111,8 @@ static int create_overlapped_pipe(HANDLE *read, HANDLE *write)
// overlapped pipes, so instead, use a named pipe with a unique name
*read = CreateNamedPipeW(buf, PIPE_ACCESS_INBOUND |
FILE_FLAG_FIRST_PIPE_INSTANCE | FILE_FLAG_OVERLAPPED,
PIPE_TYPE_BYTE | PIPE_WAIT | PIPE_REJECT_REMOTE_CLIENTS,
1, 0, 4096, 0, NULL);
if (!*read)
PIPE_TYPE_BYTE | PIPE_WAIT, 1, 0, 4096, 0, NULL);
if (*read == INVALID_HANDLE_VALUE)
goto error;
// Open the write end of the pipe as a synchronous handle
-1
View File
@@ -515,7 +515,6 @@ static void do_fill_audio_out_buffers(struct MPContext *mpctx, double endpts)
// later. Retrying is needed to get the correct sync PTS.
if (mpctx->audio_status >= STATUS_DRAINING && status == AD_OK) {
mpctx->audio_status = STATUS_SYNCING;
mpctx->sleeptime = 0;
return; // retry on next iteration
}
+3 -1
View File
@@ -4350,7 +4350,9 @@ int run_command(MPContext *mpctx, mp_cmd_t *cmd)
struct track *sub = mp_add_subtitles(mpctx, cmd->args[0].v.s);
if (!sub)
return -1;
if (cmd->args[1].v.i != 1) {
if (cmd->args[1].v.i == 1) {
sub->no_default = true;
} else {
mp_switch_track(mpctx, sub->type, sub);
mp_mark_user_track_selection(mpctx, 0, sub->type);
}
+8 -5
View File
@@ -300,14 +300,17 @@ double timeline_set_from_time(struct MPContext *mpctx, double pts, bool *need_re
{
if (pts < 0)
pts = 0;
int new = mpctx->num_timeline_parts - 1;
for (int i = 0; i < mpctx->num_timeline_parts; i++) {
struct timeline_part *p = mpctx->timeline + i;
if (pts < (p + 1)->start) {
*need_reset = timeline_set_part(mpctx, i, false);
return pts - p->start + p->source_start;
if (pts < mpctx->timeline[i + 1].start) {
new = i;
break;
}
}
return MP_NOPTS_VALUE;
*need_reset = timeline_set_part(mpctx, new, false);
return pts - mpctx->timeline[new].start + mpctx->timeline[new].source_start;
}
static int find_new_tid(struct MPContext *mpctx, enum stream_type t)
+3 -12
View File
@@ -214,16 +214,6 @@ static int mp_seek(MPContext *mpctx, struct seek_params seek,
bool need_reset = false;
demuxer_amount = timeline_set_from_time(mpctx, seek.amount,
&need_reset);
if (demuxer_amount == MP_NOPTS_VALUE) {
assert(!need_reset);
mpctx->stop_play = AT_END_OF_FILE;
// When seeking outside of the file, but not when ending last segment.
if (!timeline_fallthrough) {
clear_audio_output_buffers(mpctx);
reset_playback_state(mpctx);
}
return -1;
}
if (need_reset) {
reinit_video_chain(mpctx);
reinit_audio_chain(mpctx);
@@ -961,10 +951,11 @@ void run_playloop(struct MPContext *mpctx)
mpctx->audio_status == STATUS_EOF &&
mpctx->video_status == STATUS_EOF)
{
if (end_is_new_segment) {
int new_part = mpctx->timeline_part + 1;
if (end_is_new_segment && new_part < mpctx->num_timeline_parts) {
mp_seek(mpctx, (struct seek_params){
.type = MPSEEK_ABSOLUTE,
.amount = mpctx->timeline[mpctx->timeline_part+1].start
.amount = mpctx->timeline[new_part].start
}, true);
} else
mpctx->stop_play = AT_END_OF_FILE;
+7
View File
@@ -67,6 +67,13 @@ enum mp_csp_prim {
MP_CSP_PRIM_COUNT
};
enum mp_csp_trc {
MP_CSP_TRC_NONE,
MP_CSP_TRC_BT_2020_APPROX,
MP_CSP_TRC_BT_2020_EXACT,
MP_CSP_TRC_SRGB
};
// Any enum mp_csp_prim value is a valid index (except MP_CSP_PRIM_COUNT)
extern const char *const mp_csp_prim_names[MP_CSP_PRIM_COUNT];
+1 -1
View File
@@ -430,7 +430,7 @@ static void uninit_avctx(struct dec_video *vd)
vd_ffmpeg_ctx *ctx = vd->priv;
AVCodecContext *avctx = ctx->avctx;
if (avctx)
if (avctx && avctx->codec)
avcodec_flush_buffers(avctx);
if (ctx->hwdec && ctx->hwdec->uninit)
+26 -7
View File
@@ -901,10 +901,25 @@ static void compile_shaders(struct gl_video *p)
bool use_conv_gamma = p->conv_gamma != 1.0;
bool use_const_luma = p->image_params.colorspace == MP_CSP_BT_2020_C;
enum mp_csp_trc gamma_fun = MP_CSP_TRC_NONE;
// Linear light scaling is only enabled when either color correction
// option (3dlut or srgb) is enabled, otherwise scaling is done in the
// source space. We also need to linearize for constant luminance systems.
bool convert_to_linear_gamma = !p->is_linear_rgb && use_cms || use_const_luma;
if ((!p->is_linear_rgb && use_cms) || use_const_luma) {
// We just use the color level range to distinguish between PC
// content like images, which are most likely sRGB, and TV content
// like movies, which are most likely BT.2020
if (p->image_params.colorlevels == MP_CSP_LEVELS_PC && !p->hwdec_active) {
// FIXME: I don't know if hwdec sets the color levels to PC or not,
// but let's avoid the bug just in case.
gamma_fun = MP_CSP_TRC_SRGB;
} else if (p->opts.approx_gamma) {
gamma_fun = MP_CSP_TRC_BT_2020_APPROX;
} else {
gamma_fun = MP_CSP_TRC_BT_2020_EXACT;
}
}
// Figure out the right color spaces we need to convert, if any
enum mp_csp_prim prim_src = p->image_params.primaries, prim_dest;
@@ -943,9 +958,11 @@ static void compile_shaders(struct gl_video *p)
char *header_osd = talloc_strdup(tmp, header);
shader_def_opt(&header_osd, "USE_OSD_LINEAR_CONV_APPROX",
use_cms && p->opts.approx_gamma);
use_cms && gamma_fun == MP_CSP_TRC_BT_2020_APPROX);
shader_def_opt(&header_osd, "USE_OSD_LINEAR_CONV_BT2020",
use_cms && !p->opts.approx_gamma);
use_cms && gamma_fun == MP_CSP_TRC_BT_2020_EXACT);
shader_def_opt(&header_osd, "USE_OSD_LINEAR_CONV_SRGB",
use_cms && gamma_fun == MP_CSP_TRC_SRGB);
shader_def_opt(&header_osd, "USE_OSD_CMS_MATRIX", use_cms_matrix);
shader_def_opt(&header_osd, "USE_OSD_3DLUT", p->use_lut_3d);
// 3DLUT overrides SRGB
@@ -980,9 +997,11 @@ static void compile_shaders(struct gl_video *p)
shader_def_opt(&header_conv, "USE_CONV_GAMMA", use_conv_gamma);
shader_def_opt(&header_conv, "USE_CONST_LUMA", use_const_luma);
shader_def_opt(&header_conv, "USE_LINEAR_LIGHT_APPROX",
convert_to_linear_gamma && p->opts.approx_gamma);
gamma_fun == MP_CSP_TRC_BT_2020_APPROX);
shader_def_opt(&header_conv, "USE_LINEAR_LIGHT_BT2020",
convert_to_linear_gamma && !p->opts.approx_gamma);
gamma_fun == MP_CSP_TRC_BT_2020_EXACT);
shader_def_opt(&header_conv, "USE_LINEAR_LIGHT_SRGB",
gamma_fun == MP_CSP_TRC_SRGB);
if (p->opts.alpha_mode > 0 && p->has_alpha && p->plane_count > 3)
shader_def(&header_conv, "USE_ALPHA_PLANE", "3");
if (p->opts.alpha_mode == 2 && p->has_alpha)
@@ -1018,7 +1037,7 @@ static void compile_shaders(struct gl_video *p)
// Don't sample from input video textures before converting the input to
// linear light.
if (use_input_gamma || use_conv_gamma)
if (use_input_gamma || use_conv_gamma || gamma_fun != MP_CSP_TRC_NONE)
use_indirect = true;
// It doesn't make sense to scale the chroma with cscale in the 1. scale
@@ -1409,7 +1428,7 @@ static void init_video(struct gl_video *p, const struct mp_image_params *params)
p->image_dh = params->d_h;
p->image_params = *params;
if (p->is_rgb && (p->opts.srgb || p->use_lut_3d)) {
if (p->is_rgb && (p->opts.srgb || p->use_lut_3d) && !p->hwdec_active) {
// If we're opening an RGB source like a png file or similar,
// we just sample it using GL_SRGB which treats it as an sRGB source
// and pretend it's linear as far as CMS is concerned
+19 -2
View File
@@ -43,6 +43,12 @@
// Earlier GLSL doesn't support mix() with bvec
#if __VERSION__ >= 130
vec3 srgb_expand(vec3 v)
{
return mix(v / 12.92, pow((v + vec3(0.055))/1.055, vec3(2.4)),
lessThanEqual(vec3(0.04045), v));
}
vec3 srgb_compand(vec3 v)
{
return mix(v * 12.92, 1.055 * pow(v, vec3(1.0/2.4)) - 0.055,
@@ -98,6 +104,9 @@ void main() {
#ifdef USE_OSD_LINEAR_CONV_BT2020
color.rgb = bt2020_expand(color.rgb);
#endif
#ifdef USE_OSD_LINEAR_CONV_SRGB
color.rgb = srgb_expand(color.rgb);
#endif
#ifdef USE_OSD_CMS_MATRIX
// Convert to the right target gamut first (to BT.709 for sRGB,
// and to BT.2020 for 3DLUT). Normal clamping here as perceptually
@@ -419,8 +428,9 @@ void main() {
lessThanEqual(color.br, vec2(0))) + color.gg;
#endif
#ifdef USE_COLORMATRIX
// Clamp down here to avoid clipping CbCr details before CONST_LUMA
// has a chance to convert them.
// CONST_LUMA involves numbers outside the [0,1] range so we make sure
// to clip here, after the (possible) USE_CONST_LUMA calculations are done,
// instead of immediately after the colormatrix conversion.
color = clamp(color, 0, 1);
#endif
// If we are scaling in linear light (SRGB or 3DLUT option enabled), we
@@ -438,6 +448,13 @@ void main() {
// ... and actual BT.2020 (two-part function)
color = bt2020_expand(color);
#endif
#ifdef USE_LINEAR_LIGHT_SRGB
// This is not needed for most sRGB content since we can use GL_SRGB to
// directly sample RGB texture in linear light, but for things which are
// also sRGB but in a different format (such as JPEG's YUV), we need
// to convert to linear light manually.
color = srgb_expand(color);
#endif
#ifdef USE_CONST_LUMA
// Calculate the green channel from the expanded RYcB
// The BT.2020 specification says Yc = 0.2627*R + 0.6780*G + 0.0593*B
+2 -2
View File
@@ -904,8 +904,8 @@ static int reinit_window_state(struct vo_w32_state *w32)
// Center the final window
n_w = r.right - r.left;
n_h = r.bottom - r.top;
r.left = screen_w / 2 - n_w / 2;
r.top = screen_h / 2 - n_h / 2;
r.left = w32->screenrc.x0 + screen_w / 2 - n_w / 2;
r.top = w32->screenrc.y0 + screen_h / 2 - n_h / 2;
r.right = r.left + n_w;
r.bottom = r.top + n_h;
}
+2 -2
View File
@@ -825,14 +825,14 @@ def options(opt):
opt.parse_features('build and install options', build_options)
optional_features = main_dependencies + libav_dependencies
opt.parse_features('optional feaures', optional_features)
opt.parse_features('optional features', optional_features)
opt.parse_features('audio outputs', audio_output_features)
opt.parse_features('video outputs', video_output_features)
opt.parse_features('hwaccels', hwaccel_features)
opt.parse_features('tv features', radio_and_tv_features)
opt.parse_features('standalone app', standalone_features)
group = opt.get_option_group("optional feaures")
group = opt.get_option_group("optional features")
group.add_option('--lua',
type = 'string',
dest = 'LUA_VER',