2013-10-29 21:38:29 +00:00
|
|
|
/*
|
2015-04-13 07:36:54 +00:00
|
|
|
* This file is part of mpv.
|
2013-10-29 21:38:29 +00:00
|
|
|
*
|
player: change license of most core files to LGPL
These files have all in common that they were fully or mostly taken from
mplayer.c. (mplayer.c was a huge file that contains almost all of the
playback core, until it was split into multiple parts.) This was
probably the hardest part to relicense, because so much code was moved
around all the time.
player/audio.c still does not compile. We'll have to redo audio
filtering. Once that is done, we can probably actually provide an
actual LGPL configure switch.
Here is a relatively detailed list of potential issues:
8d190244: author did not reply, parts were made GPL-only in a previous
commit.
7882ea9b: author could not be reached, but the code is gone. wscript
still has --datadir switch, but I don't think this is relevant to
copyright.
f197efd5: unclear origin, but I consider the code gone anyway (replaced
with generic OSD mechanisms).
8337d9c2: author did not reply, but only the option still exists (under
a different name), other code was removed.
d8fd7131: did not reply. Disabled in a previous commit.
05258251: same author as above. Both fields actually seem to have
vanished (even when tracking renames), so no action taken.
d459e644, 268b2c1a: author did not reply, but we reuse only the options
(with different names and slightly or fully different semantics, and
completely different implementations), so I don't think this is relevant
for copyright.
09e742fe, 17c39c4e: same as above.
e8a173de, bff4b3ee: author could not be reached. The commands were
reworked to properties, and the code outside of the TV code were moved
back to the TV code. So I don't think copyright applies to the current
command.c parts (mp_property_tv_color, mp_property_tv_freq,
mp_property_tv_scan). The TV parts remain GPL.
0810e427: could not be reached. Disabled in a previous commit.
43744a2d: unknown author, but this was replaced by dynamic alloc (if the
change is even copyrightable).
116ca0c7: unknown author; reasoning see input.c relicensing commit.
e7e4d1d8: these semantics still exist, but as generic code, and this
code was fully removed.
f1175cd9: the author of the cited patch is unknown, and upon inspection
it turns out that I was only using the idea to pause the player on EOF,
so I claim it's not copyright relevant.
25affdcc: author could not be reached (yet) - but it's only a function
rename, not copyrightable.
5728504c was committed by Arpi (who agreed), but hints that it might be
by a different author. In fact it seems to be mostly this patch:
http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2001-November/002041.html
The author did not respond, but it all seems to have been removed later.
It's a terrible mess though. Arpi reverted the A-V sync code at first,
but left the RTC code for a while. The following commits remove these
changes 100%: 14b35442, 7181a091, 31482783, 614f8475, df58e822.
cehoyos did explicitly not agree to LGPL, but was involved in the
following changes:
c99d8fc8: applied a patch and didn't modify it, the original author
agreed.
40ac0d31: author could not be reached, but all code is gone anyway. The
"af" command has a similar function, but works completely different and
actually reuses a mechanism older than this patch.
54350436: applied a patch, but didn't modify it, except for adding a
German translation, which was removed later.
a2dda036: same situation as above
240b743e: this was made GPL-only in a previous commit
7b25afd7: same as above (for now)
kirijua could not be reached, but was a regular patch contributor:
c2c997fd: video equalizer code move; probably not copyrightable. Is GPL
due to Nick anyway.
be54f481: technically, this became the audio track property later. But
all what is left is the fact that you pass a track ID to it, so consider
the original coypright non-relevant.
2f376d1b: this was rewritten in b7052b43, but for now we can afford to
be careful, so this was marked as GPL only in a previous commit.
43844d09: remaining parts in main.c were reverted in a previous commit.
anders has mostly disagreed with the LGPL relicensing. Does not want
libaf to become LGPL, but made some concessions. In particular, he
granted us permission to relicense 4943e9c52c and 242aa6ebd4. We also
consider some of his changes remaining in mpv not relevant for copyright
(such as 735de602 - we won't remove the this option completely). We will
completely remove his other contributions, including the entire audio
filter chain. For now, this stuff is marked as GPL only. The remaining
question is how much code in player/audio.c (based on the former
mplayer.c and dec_audio.c) is under his copyright. I made claims about
this in a previous commit.
Nick(ols) Kurshev, svn username "nick" and "nickols_k", could not be
reached. He had a lot of changes in early MPlayer. It seems all of that
was removed, at least in mpv. His main work, like VIDIX or libswscale
work, does not exist in mpv anymore, but the changes to mplayer.c and
other core parts still deserve attention:
a4119f6b, fb927549, ad3529b8, e11b23dc, 5f2178be, 93c371d5: removed in
b43d67e0, d1628d12, 24ed01fe, df58e822.
0a83c6ec, 104c125e, 4e067f62, aec5dcc8, b587a3d6, f3de6e6b: DR, VAA, and
"tune" stuff was fully removed later on or replaced with other
mechanisms.
340183b0: screenshots were redone later (the VOCTRL was even removed,
with an independent implementation using the same VOCTRL a few years
later), so not relevant anymore. Basically only the 's' shortcut remains
(but not its implementation).
92c5c274, bffd4007, 555c6766: for now marked as GPL only in a previous
commit.
Might contain some trace amounts of "michael"'s copyright, who agreed to
LGPL only once the core is relicensed. This will still be respected, but
I don't think it matters at this in this case. (Some code touched by him
was merged into mplayer.c, and then disappeared after heavy
refactoring.)
I tried to be as careful and as complete as possible. It can't be
excluded that amends to this will be made later.
This does not make the player LGPL yet.
2017-06-23 13:53:41 +00:00
|
|
|
* mpv is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2013-10-29 21:38:29 +00:00
|
|
|
*
|
2015-04-13 07:36:54 +00:00
|
|
|
* mpv is distributed in the hope that it will be useful,
|
2013-10-29 21:38:29 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
player: change license of most core files to LGPL
These files have all in common that they were fully or mostly taken from
mplayer.c. (mplayer.c was a huge file that contains almost all of the
playback core, until it was split into multiple parts.) This was
probably the hardest part to relicense, because so much code was moved
around all the time.
player/audio.c still does not compile. We'll have to redo audio
filtering. Once that is done, we can probably actually provide an
actual LGPL configure switch.
Here is a relatively detailed list of potential issues:
8d190244: author did not reply, parts were made GPL-only in a previous
commit.
7882ea9b: author could not be reached, but the code is gone. wscript
still has --datadir switch, but I don't think this is relevant to
copyright.
f197efd5: unclear origin, but I consider the code gone anyway (replaced
with generic OSD mechanisms).
8337d9c2: author did not reply, but only the option still exists (under
a different name), other code was removed.
d8fd7131: did not reply. Disabled in a previous commit.
05258251: same author as above. Both fields actually seem to have
vanished (even when tracking renames), so no action taken.
d459e644, 268b2c1a: author did not reply, but we reuse only the options
(with different names and slightly or fully different semantics, and
completely different implementations), so I don't think this is relevant
for copyright.
09e742fe, 17c39c4e: same as above.
e8a173de, bff4b3ee: author could not be reached. The commands were
reworked to properties, and the code outside of the TV code were moved
back to the TV code. So I don't think copyright applies to the current
command.c parts (mp_property_tv_color, mp_property_tv_freq,
mp_property_tv_scan). The TV parts remain GPL.
0810e427: could not be reached. Disabled in a previous commit.
43744a2d: unknown author, but this was replaced by dynamic alloc (if the
change is even copyrightable).
116ca0c7: unknown author; reasoning see input.c relicensing commit.
e7e4d1d8: these semantics still exist, but as generic code, and this
code was fully removed.
f1175cd9: the author of the cited patch is unknown, and upon inspection
it turns out that I was only using the idea to pause the player on EOF,
so I claim it's not copyright relevant.
25affdcc: author could not be reached (yet) - but it's only a function
rename, not copyrightable.
5728504c was committed by Arpi (who agreed), but hints that it might be
by a different author. In fact it seems to be mostly this patch:
http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2001-November/002041.html
The author did not respond, but it all seems to have been removed later.
It's a terrible mess though. Arpi reverted the A-V sync code at first,
but left the RTC code for a while. The following commits remove these
changes 100%: 14b35442, 7181a091, 31482783, 614f8475, df58e822.
cehoyos did explicitly not agree to LGPL, but was involved in the
following changes:
c99d8fc8: applied a patch and didn't modify it, the original author
agreed.
40ac0d31: author could not be reached, but all code is gone anyway. The
"af" command has a similar function, but works completely different and
actually reuses a mechanism older than this patch.
54350436: applied a patch, but didn't modify it, except for adding a
German translation, which was removed later.
a2dda036: same situation as above
240b743e: this was made GPL-only in a previous commit
7b25afd7: same as above (for now)
kirijua could not be reached, but was a regular patch contributor:
c2c997fd: video equalizer code move; probably not copyrightable. Is GPL
due to Nick anyway.
be54f481: technically, this became the audio track property later. But
all what is left is the fact that you pass a track ID to it, so consider
the original coypright non-relevant.
2f376d1b: this was rewritten in b7052b43, but for now we can afford to
be careful, so this was marked as GPL only in a previous commit.
43844d09: remaining parts in main.c were reverted in a previous commit.
anders has mostly disagreed with the LGPL relicensing. Does not want
libaf to become LGPL, but made some concessions. In particular, he
granted us permission to relicense 4943e9c52c and 242aa6ebd4. We also
consider some of his changes remaining in mpv not relevant for copyright
(such as 735de602 - we won't remove the this option completely). We will
completely remove his other contributions, including the entire audio
filter chain. For now, this stuff is marked as GPL only. The remaining
question is how much code in player/audio.c (based on the former
mplayer.c and dec_audio.c) is under his copyright. I made claims about
this in a previous commit.
Nick(ols) Kurshev, svn username "nick" and "nickols_k", could not be
reached. He had a lot of changes in early MPlayer. It seems all of that
was removed, at least in mpv. His main work, like VIDIX or libswscale
work, does not exist in mpv anymore, but the changes to mplayer.c and
other core parts still deserve attention:
a4119f6b, fb927549, ad3529b8, e11b23dc, 5f2178be, 93c371d5: removed in
b43d67e0, d1628d12, 24ed01fe, df58e822.
0a83c6ec, 104c125e, 4e067f62, aec5dcc8, b587a3d6, f3de6e6b: DR, VAA, and
"tune" stuff was fully removed later on or replaced with other
mechanisms.
340183b0: screenshots were redone later (the VOCTRL was even removed,
with an independent implementation using the same VOCTRL a few years
later), so not relevant anymore. Basically only the 's' shortcut remains
(but not its implementation).
92c5c274, bffd4007, 555c6766: for now marked as GPL only in a previous
commit.
Might contain some trace amounts of "michael"'s copyright, who agreed to
LGPL only once the core is relicensed. This will still be respected, but
I don't think it matters at this in this case. (Some code touched by him
was merged into mplayer.c, and then disappeared after heavy
refactoring.)
I tried to be as careful and as complete as possible. It can't be
excluded that amends to this will be made later.
This does not make the player LGPL yet.
2017-06-23 13:53:41 +00:00
|
|
|
* GNU Lesser General Public License for more details.
|
2013-10-29 21:38:29 +00:00
|
|
|
*
|
player: change license of most core files to LGPL
These files have all in common that they were fully or mostly taken from
mplayer.c. (mplayer.c was a huge file that contains almost all of the
playback core, until it was split into multiple parts.) This was
probably the hardest part to relicense, because so much code was moved
around all the time.
player/audio.c still does not compile. We'll have to redo audio
filtering. Once that is done, we can probably actually provide an
actual LGPL configure switch.
Here is a relatively detailed list of potential issues:
8d190244: author did not reply, parts were made GPL-only in a previous
commit.
7882ea9b: author could not be reached, but the code is gone. wscript
still has --datadir switch, but I don't think this is relevant to
copyright.
f197efd5: unclear origin, but I consider the code gone anyway (replaced
with generic OSD mechanisms).
8337d9c2: author did not reply, but only the option still exists (under
a different name), other code was removed.
d8fd7131: did not reply. Disabled in a previous commit.
05258251: same author as above. Both fields actually seem to have
vanished (even when tracking renames), so no action taken.
d459e644, 268b2c1a: author did not reply, but we reuse only the options
(with different names and slightly or fully different semantics, and
completely different implementations), so I don't think this is relevant
for copyright.
09e742fe, 17c39c4e: same as above.
e8a173de, bff4b3ee: author could not be reached. The commands were
reworked to properties, and the code outside of the TV code were moved
back to the TV code. So I don't think copyright applies to the current
command.c parts (mp_property_tv_color, mp_property_tv_freq,
mp_property_tv_scan). The TV parts remain GPL.
0810e427: could not be reached. Disabled in a previous commit.
43744a2d: unknown author, but this was replaced by dynamic alloc (if the
change is even copyrightable).
116ca0c7: unknown author; reasoning see input.c relicensing commit.
e7e4d1d8: these semantics still exist, but as generic code, and this
code was fully removed.
f1175cd9: the author of the cited patch is unknown, and upon inspection
it turns out that I was only using the idea to pause the player on EOF,
so I claim it's not copyright relevant.
25affdcc: author could not be reached (yet) - but it's only a function
rename, not copyrightable.
5728504c was committed by Arpi (who agreed), but hints that it might be
by a different author. In fact it seems to be mostly this patch:
http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2001-November/002041.html
The author did not respond, but it all seems to have been removed later.
It's a terrible mess though. Arpi reverted the A-V sync code at first,
but left the RTC code for a while. The following commits remove these
changes 100%: 14b35442, 7181a091, 31482783, 614f8475, df58e822.
cehoyos did explicitly not agree to LGPL, but was involved in the
following changes:
c99d8fc8: applied a patch and didn't modify it, the original author
agreed.
40ac0d31: author could not be reached, but all code is gone anyway. The
"af" command has a similar function, but works completely different and
actually reuses a mechanism older than this patch.
54350436: applied a patch, but didn't modify it, except for adding a
German translation, which was removed later.
a2dda036: same situation as above
240b743e: this was made GPL-only in a previous commit
7b25afd7: same as above (for now)
kirijua could not be reached, but was a regular patch contributor:
c2c997fd: video equalizer code move; probably not copyrightable. Is GPL
due to Nick anyway.
be54f481: technically, this became the audio track property later. But
all what is left is the fact that you pass a track ID to it, so consider
the original coypright non-relevant.
2f376d1b: this was rewritten in b7052b43, but for now we can afford to
be careful, so this was marked as GPL only in a previous commit.
43844d09: remaining parts in main.c were reverted in a previous commit.
anders has mostly disagreed with the LGPL relicensing. Does not want
libaf to become LGPL, but made some concessions. In particular, he
granted us permission to relicense 4943e9c52c and 242aa6ebd4. We also
consider some of his changes remaining in mpv not relevant for copyright
(such as 735de602 - we won't remove the this option completely). We will
completely remove his other contributions, including the entire audio
filter chain. For now, this stuff is marked as GPL only. The remaining
question is how much code in player/audio.c (based on the former
mplayer.c and dec_audio.c) is under his copyright. I made claims about
this in a previous commit.
Nick(ols) Kurshev, svn username "nick" and "nickols_k", could not be
reached. He had a lot of changes in early MPlayer. It seems all of that
was removed, at least in mpv. His main work, like VIDIX or libswscale
work, does not exist in mpv anymore, but the changes to mplayer.c and
other core parts still deserve attention:
a4119f6b, fb927549, ad3529b8, e11b23dc, 5f2178be, 93c371d5: removed in
b43d67e0, d1628d12, 24ed01fe, df58e822.
0a83c6ec, 104c125e, 4e067f62, aec5dcc8, b587a3d6, f3de6e6b: DR, VAA, and
"tune" stuff was fully removed later on or replaced with other
mechanisms.
340183b0: screenshots were redone later (the VOCTRL was even removed,
with an independent implementation using the same VOCTRL a few years
later), so not relevant anymore. Basically only the 's' shortcut remains
(but not its implementation).
92c5c274, bffd4007, 555c6766: for now marked as GPL only in a previous
commit.
Might contain some trace amounts of "michael"'s copyright, who agreed to
LGPL only once the core is relicensed. This will still be respected, but
I don't think it matters at this in this case. (Some code touched by him
was merged into mplayer.c, and then disappeared after heavy
refactoring.)
I tried to be as careful and as complete as possible. It can't be
excluded that amends to this will be made later.
This does not make the player LGPL yet.
2017-06-23 13:53:41 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
2013-10-29 21:38:29 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include "config.h"
|
2016-01-11 18:03:40 +00:00
|
|
|
#include "mpv_talloc.h"
|
2013-10-29 21:38:29 +00:00
|
|
|
|
2013-12-17 01:39:45 +00:00
|
|
|
#include "common/msg.h"
|
2013-12-17 01:02:25 +00:00
|
|
|
#include "options/options.h"
|
2013-12-17 01:39:45 +00:00
|
|
|
#include "common/common.h"
|
2014-10-03 20:32:16 +00:00
|
|
|
#include "common/global.h"
|
2013-10-29 21:38:29 +00:00
|
|
|
|
|
|
|
#include "stream/stream.h"
|
|
|
|
#include "sub/dec_sub.h"
|
|
|
|
#include "demux/demux.h"
|
|
|
|
#include "video/mp_image.h"
|
|
|
|
|
2013-12-17 00:08:53 +00:00
|
|
|
#include "core.h"
|
2013-10-29 21:38:29 +00:00
|
|
|
|
2016-01-17 15:56:32 +00:00
|
|
|
// 0: primary sub, 1: secondary sub, -1: not selected
|
|
|
|
static int get_order(struct MPContext *mpctx, struct track *track)
|
2014-12-21 22:47:00 +00:00
|
|
|
{
|
2016-01-17 15:56:32 +00:00
|
|
|
for (int n = 0; n < NUM_PTRACKS; n++) {
|
|
|
|
if (mpctx->current_track[n][STREAM_SUB] == track)
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void reset_subtitles(struct MPContext *mpctx, struct track *track)
|
|
|
|
{
|
|
|
|
if (track->d_sub)
|
|
|
|
sub_reset(track->d_sub);
|
2015-11-17 00:54:02 +00:00
|
|
|
term_osd_set_subs(mpctx, NULL);
|
2014-12-21 22:47:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void reset_subtitle_state(struct MPContext *mpctx)
|
|
|
|
{
|
2016-01-17 15:56:32 +00:00
|
|
|
for (int n = 0; n < mpctx->num_tracks; n++) {
|
|
|
|
struct dec_sub *d_sub = mpctx->tracks[n]->d_sub;
|
|
|
|
if (d_sub)
|
|
|
|
sub_reset(d_sub);
|
|
|
|
}
|
|
|
|
term_osd_set_subs(mpctx, NULL);
|
2014-12-21 22:47:00 +00:00
|
|
|
}
|
|
|
|
|
2016-01-17 15:56:32 +00:00
|
|
|
void uninit_sub(struct MPContext *mpctx, struct track *track)
|
2014-10-03 17:57:49 +00:00
|
|
|
{
|
2016-01-17 15:56:32 +00:00
|
|
|
if (track && track->d_sub) {
|
|
|
|
reset_subtitles(mpctx, track);
|
|
|
|
sub_select(track->d_sub, false);
|
|
|
|
int order = get_order(mpctx, track);
|
2016-03-08 20:54:17 +00:00
|
|
|
osd_set_sub(mpctx->osd, order, NULL);
|
2014-10-03 17:57:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void uninit_sub_all(struct MPContext *mpctx)
|
|
|
|
{
|
2016-01-17 15:56:32 +00:00
|
|
|
for (int n = 0; n < mpctx->num_tracks; n++)
|
|
|
|
uninit_sub(mpctx, mpctx->tracks[n]);
|
2014-10-03 17:57:49 +00:00
|
|
|
}
|
|
|
|
|
2016-01-17 15:56:32 +00:00
|
|
|
static bool update_subtitle(struct MPContext *mpctx, double video_pts,
|
|
|
|
struct track *track)
|
2013-10-29 21:38:29 +00:00
|
|
|
{
|
2016-01-17 15:56:32 +00:00
|
|
|
struct dec_sub *dec_sub = track ? track->d_sub : NULL;
|
2014-10-03 17:57:49 +00:00
|
|
|
|
2016-01-17 15:56:32 +00:00
|
|
|
if (!dec_sub || video_pts == MP_NOPTS_VALUE)
|
2015-12-29 00:35:52 +00:00
|
|
|
return true;
|
2014-10-03 17:57:49 +00:00
|
|
|
|
2016-01-13 23:18:48 +00:00
|
|
|
if (mpctx->vo_chain) {
|
video: rewrite filtering glue code
Get rid of the old vf.c code. Replace it with a generic filtering
framework, which can potentially handle more than just --vf. At least
reimplementing --af with this code is planned.
This changes some --vf semantics (including runtime behavior and the
"vf" command). The most important ones are listed in interface-changes.
vf_convert.c is renamed to f_swscale.c. It is now an internal filter
that can not be inserted by the user manually.
f_lavfi.c is a refactor of player/lavfi.c. The latter will be removed
once --lavfi-complex is reimplemented on top of f_lavfi.c. (which is
conceptually easy, but a big mess due to the data flow changes).
The existing filters are all changed heavily. The data flow of the new
filter framework is different. Especially EOF handling changes - EOF is
now a "frame" rather than a state, and must be passed through exactly
once.
Another major thing is that all filters must support dynamic format
changes. The filter reconfig() function goes away. (This sounds complex,
but since all filters need to handle EOF draining anyway, they can use
the same code, and it removes the mess with reconfig() having to predict
the output format, which completely breaks with libavfilter anyway.)
In addition, there is no automatic format negotiation or conversion.
libavfilter's primitive and insufficient API simply doesn't allow us to
do this in a reasonable way. Instead, filters can use f_autoconvert as
sub-filter, and tell it which formats they support. This filter will in
turn add actual conversion filters, such as f_swscale, to perform
necessary format changes.
vf_vapoursynth.c uses the same basic principle of operation as before,
but with worryingly different details in data flow. Still appears to
work.
The hardware deint filters (vf_vavpp.c, vf_d3d11vpp.c, vf_vdpaupp.c) are
heavily changed. Fortunately, they all used refqueue.c, which is for
sharing the data flow logic (especially for managing future/past
surfaces and such). It turns out it can be used to factor out most of
the data flow. Some of these filters accepted software input. Instead of
having ad-hoc upload code in each filter, surface upload is now
delegated to f_autoconvert, which can use f_hwupload to perform this.
Exporting VO capabilities is still a big mess (mp_stream_info stuff).
The D3D11 code drops the redundant image formats, and all code uses the
hw_subfmt (sw_format in FFmpeg) instead. Although that too seems to be a
big mess for now.
f_async_queue is unused.
2018-01-16 10:53:44 +00:00
|
|
|
struct mp_image_params params = mpctx->vo_chain->filter->input_params;
|
2013-11-23 20:39:07 +00:00
|
|
|
if (params.imgfmt)
|
|
|
|
sub_control(dec_sub, SD_CTRL_SET_VIDEO_PARAMS, ¶ms);
|
2013-10-29 21:38:29 +00:00
|
|
|
}
|
|
|
|
|
sub: make preloading more robust
Subtitles can be preloaded, which means they're fully read and copied
into ASS_Track. This in turn is mainly for the sake of being able to do
subtitle seeking (when it comes down to it, subtitle seeking is the
cause for most trouble here).
Commit a714f8e92 broke preloaded subtitles which have events with
unknown duration, such as some MicroDVD samples. The event list gets
cleared on every seek, so the property of being preloaded obviously gets
lost.
Fix this by moving most of the preloading logic to dec_sub.c. If the
subtitle list gets cleared, they are not considered preloaded anymore,
and the logic for demuxed subtitles is used.
As another minor thing, preloadeding subtitles did neither disable the
demux stream, nor did it discard packets. Thus you could get queue
overflows in theory (harmless, but annoying). Fix this by explicitly
discarding packets in preloaded mode.
In summary, now the only difference between preloaded and normal
demuxing are:
1. a seek is issued, and all packets are read on start
2. during playback, discard the packets instead of feeding them to the
subtitle decoder
This is still petty annoying. It would be nice if maintaining the
subtitle index (and maybe a subtitle packet cache for instant subtitle
presentation when seeking back) could be maintained in the demuxer
instead. Half of all file formats with interleaved subtitles have
this anyway (mp4, mkv muxed with newer mkvmerge).
2016-03-06 13:50:36 +00:00
|
|
|
if (track->demuxer->fully_read && sub_can_preload(dec_sub)) {
|
2016-01-21 22:49:25 +00:00
|
|
|
// Assume fully_read implies no interleaved audio/video streams.
|
|
|
|
// (Reading packets will change the demuxer position.)
|
2016-02-28 18:14:23 +00:00
|
|
|
demux_seek(track->demuxer, 0, 0);
|
sub: make preloading more robust
Subtitles can be preloaded, which means they're fully read and copied
into ASS_Track. This in turn is mainly for the sake of being able to do
subtitle seeking (when it comes down to it, subtitle seeking is the
cause for most trouble here).
Commit a714f8e92 broke preloaded subtitles which have events with
unknown duration, such as some MicroDVD samples. The event list gets
cleared on every seek, so the property of being preloaded obviously gets
lost.
Fix this by moving most of the preloading logic to dec_sub.c. If the
subtitle list gets cleared, they are not considered preloaded anymore,
and the logic for demuxed subtitles is used.
As another minor thing, preloadeding subtitles did neither disable the
demux stream, nor did it discard packets. Thus you could get queue
overflows in theory (harmless, but annoying). Fix this by explicitly
discarding packets in preloaded mode.
In summary, now the only difference between preloaded and normal
demuxing are:
1. a seek is issued, and all packets are read on start
2. during playback, discard the packets instead of feeding them to the
subtitle decoder
This is still petty annoying. It would be nice if maintaining the
subtitle index (and maybe a subtitle packet cache for instant subtitle
presentation when seeking back) could be maintained in the demuxer
instead. Half of all file formats with interleaved subtitles have
this anyway (mp4, mkv muxed with newer mkvmerge).
2016-03-06 13:50:36 +00:00
|
|
|
sub_preload(dec_sub);
|
2016-01-21 22:49:25 +00:00
|
|
|
}
|
|
|
|
|
sub: make preloading more robust
Subtitles can be preloaded, which means they're fully read and copied
into ASS_Track. This in turn is mainly for the sake of being able to do
subtitle seeking (when it comes down to it, subtitle seeking is the
cause for most trouble here).
Commit a714f8e92 broke preloaded subtitles which have events with
unknown duration, such as some MicroDVD samples. The event list gets
cleared on every seek, so the property of being preloaded obviously gets
lost.
Fix this by moving most of the preloading logic to dec_sub.c. If the
subtitle list gets cleared, they are not considered preloaded anymore,
and the logic for demuxed subtitles is used.
As another minor thing, preloadeding subtitles did neither disable the
demux stream, nor did it discard packets. Thus you could get queue
overflows in theory (harmless, but annoying). Fix this by explicitly
discarding packets in preloaded mode.
In summary, now the only difference between preloaded and normal
demuxing are:
1. a seek is issued, and all packets are read on start
2. during playback, discard the packets instead of feeding them to the
subtitle decoder
This is still petty annoying. It would be nice if maintaining the
subtitle index (and maybe a subtitle packet cache for instant subtitle
presentation when seeking back) could be maintained in the demuxer
instead. Half of all file formats with interleaved subtitles have
this anyway (mp4, mkv muxed with newer mkvmerge).
2016-03-06 13:50:36 +00:00
|
|
|
if (!sub_read_packets(dec_sub, video_pts))
|
|
|
|
return false;
|
2013-10-29 21:38:29 +00:00
|
|
|
|
2013-12-24 16:46:14 +00:00
|
|
|
// Handle displaying subtitles on terminal; never done for secondary subs
|
2016-01-17 15:56:32 +00:00
|
|
|
if (mpctx->current_track[0][STREAM_SUB] == track && !mpctx->video_out)
|
2015-12-29 00:35:52 +00:00
|
|
|
term_osd_set_subs(mpctx, sub_get_text(dec_sub, video_pts));
|
|
|
|
|
2016-10-26 18:43:03 +00:00
|
|
|
// Handle displaying subtitles on VO with no video being played. This is
|
|
|
|
// quite differently, because normally subtitles are redrawn on new video
|
|
|
|
// frames, using the video frames' timestamps.
|
2016-10-31 12:55:32 +00:00
|
|
|
if (mpctx->video_out && mpctx->video_status == STATUS_EOF) {
|
2016-10-26 18:43:03 +00:00
|
|
|
if (osd_get_force_video_pts(mpctx->osd) != video_pts) {
|
|
|
|
osd_set_force_video_pts(mpctx->osd, video_pts);
|
|
|
|
osd_query_and_reset_want_redraw(mpctx->osd);
|
|
|
|
vo_redraw(mpctx->video_out);
|
2016-10-30 11:03:46 +00:00
|
|
|
// Force an arbitrary minimum FPS
|
|
|
|
mp_set_timeout(mpctx, 0.1);
|
2016-10-26 18:43:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-29 00:35:52 +00:00
|
|
|
return true;
|
2013-12-24 16:46:14 +00:00
|
|
|
}
|
|
|
|
|
2015-12-29 00:35:52 +00:00
|
|
|
// Return true if the subtitles for the given PTS are ready; false if the player
|
|
|
|
// should wait for new demuxer data, and then should retry.
|
|
|
|
bool update_subtitles(struct MPContext *mpctx, double video_pts)
|
2013-12-24 16:46:14 +00:00
|
|
|
{
|
2016-01-17 15:56:32 +00:00
|
|
|
bool ok = true;
|
|
|
|
for (int n = 0; n < NUM_PTRACKS; n++)
|
|
|
|
ok &= update_subtitle(mpctx, video_pts, mpctx->current_track[n][STREAM_SUB]);
|
|
|
|
return ok;
|
2013-10-29 21:38:29 +00:00
|
|
|
}
|
|
|
|
|
2016-03-03 17:48:56 +00:00
|
|
|
static struct attachment_list *get_all_attachments(struct MPContext *mpctx)
|
|
|
|
{
|
|
|
|
struct attachment_list *list = talloc_zero(NULL, struct attachment_list);
|
|
|
|
struct demuxer *prev_demuxer = NULL;
|
|
|
|
for (int n = 0; n < mpctx->num_tracks; n++) {
|
|
|
|
struct track *t = mpctx->tracks[n];
|
|
|
|
if (!t->demuxer || prev_demuxer == t->demuxer)
|
|
|
|
continue;
|
|
|
|
prev_demuxer = t->demuxer;
|
|
|
|
for (int i = 0; i < t->demuxer->num_attachments; i++) {
|
|
|
|
struct demux_attachment *att = &t->demuxer->attachments[i];
|
|
|
|
struct demux_attachment copy = {
|
|
|
|
.name = talloc_strdup(list, att->name),
|
|
|
|
.type = talloc_strdup(list, att->type),
|
|
|
|
.data = talloc_memdup(list, att->data, att->data_size),
|
|
|
|
.data_size = att->data_size,
|
|
|
|
};
|
|
|
|
MP_TARRAY_APPEND(list, list->entries, list->num_entries, copy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2015-12-27 01:07:01 +00:00
|
|
|
static bool init_subdec(struct MPContext *mpctx, struct track *track)
|
2013-12-24 16:46:14 +00:00
|
|
|
{
|
2016-01-17 15:56:32 +00:00
|
|
|
assert(!track->d_sub);
|
2015-12-26 17:32:27 +00:00
|
|
|
|
2015-12-27 01:07:01 +00:00
|
|
|
if (!track->demuxer || !track->stream)
|
|
|
|
return false;
|
2013-12-24 16:46:14 +00:00
|
|
|
|
2016-03-03 17:48:56 +00:00
|
|
|
track->d_sub = sub_create(mpctx->global, track->stream,
|
|
|
|
get_all_attachments(mpctx));
|
2016-01-17 15:56:32 +00:00
|
|
|
if (!track->d_sub)
|
2015-12-27 01:07:01 +00:00
|
|
|
return false;
|
2015-12-27 00:25:32 +00:00
|
|
|
|
2016-01-17 17:07:50 +00:00
|
|
|
struct track *vtrack = mpctx->current_track[0][STREAM_VIDEO];
|
2016-01-12 22:48:19 +00:00
|
|
|
struct mp_codec_params *v_c =
|
2016-01-17 17:07:50 +00:00
|
|
|
vtrack && vtrack->stream ? vtrack->stream->codec : NULL;
|
2016-01-12 22:48:19 +00:00
|
|
|
double fps = v_c ? v_c->fps : 25;
|
2016-01-17 15:56:32 +00:00
|
|
|
sub_control(track->d_sub, SD_CTRL_SET_VIDEO_DEF_FPS, &fps);
|
2013-12-24 16:46:14 +00:00
|
|
|
|
2015-12-27 01:07:01 +00:00
|
|
|
return true;
|
2013-12-24 16:46:14 +00:00
|
|
|
}
|
|
|
|
|
2016-01-17 15:56:32 +00:00
|
|
|
void reinit_sub(struct MPContext *mpctx, struct track *track)
|
2013-10-29 21:38:29 +00:00
|
|
|
{
|
2016-01-17 15:56:32 +00:00
|
|
|
if (!track || !track->stream || track->stream->type != STREAM_SUB)
|
2013-10-29 21:38:29 +00:00
|
|
|
return;
|
|
|
|
|
2016-01-17 15:56:32 +00:00
|
|
|
if (!track->d_sub && !init_subdec(mpctx, track)) {
|
2015-12-27 01:07:01 +00:00
|
|
|
error_on_track(mpctx, track);
|
|
|
|
return;
|
|
|
|
}
|
2013-10-29 21:38:29 +00:00
|
|
|
|
2016-01-17 15:56:32 +00:00
|
|
|
sub_select(track->d_sub, true);
|
|
|
|
int order = get_order(mpctx, track);
|
2016-03-08 20:54:17 +00:00
|
|
|
osd_set_sub(mpctx->osd, order, track->d_sub);
|
2016-01-17 15:56:32 +00:00
|
|
|
sub_control(track->d_sub, SD_CTRL_SET_TOP, &(bool){!!order});
|
player: fix instant subtitle refresh on track switches
When switching a subtitle track, the subtitle wasn't necessarily
updated, especially when playback was paused.
Some awfully subtle and complex interactions here.
First off (and not so subtle), the subtitle decoder will read packets
only on explicit update_subtitles() calls, which, if video is active, is
called only when a new video frame is shown. (A simply video frame
redraw doesn't trigger this.) So call it explicitly. But only if
playback is "initialized", i.e. not when it does initial track selection
and decoder init, during which no packets should be read.
The second issue is that the demuxer thread simply will not read new
packets just because a track was switched, especially if playback is
paused. That's fine, but if a refresh seek is to be done, it really
should do this. So if there's either 1. a refresh seek requested, or 2.
a refresh seek ongoing, then read more packets.
Note that it's entirely possible that we overflow the packet queue with
this in unpredicated weird corner cases, but the queue limit will still
be enforced, so this shouldn't make the situation worse.
2016-09-24 17:56:13 +00:00
|
|
|
|
|
|
|
if (mpctx->playback_initialized)
|
|
|
|
update_subtitles(mpctx, mpctx->playback_pts);
|
2016-01-17 15:56:32 +00:00
|
|
|
}
|
2015-12-27 01:07:01 +00:00
|
|
|
|
2016-01-17 15:56:32 +00:00
|
|
|
void reinit_sub_all(struct MPContext *mpctx)
|
|
|
|
{
|
|
|
|
for (int n = 0; n < NUM_PTRACKS; n++)
|
|
|
|
reinit_sub(mpctx, mpctx->current_track[n][STREAM_SUB]);
|
2013-10-29 21:38:29 +00:00
|
|
|
}
|