2013-10-29 22:38:29 +01:00
|
|
|
/*
|
2015-04-13 09:36:54 +02:00
|
|
|
* This file is part of mpv.
|
2013-10-29 22:38:29 +01: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 15:53:41 +02: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 22:38:29 +01:00
|
|
|
*
|
2015-04-13 09:36:54 +02:00
|
|
|
* mpv is distributed in the hope that it will be useful,
|
2013-10-29 22:38:29 +01: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 15:53:41 +02:00
|
|
|
* GNU Lesser General Public License for more details.
|
2013-10-29 22:38:29 +01: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 15:53:41 +02: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 22:38:29 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
2016-01-11 19:03:40 +01:00
|
|
|
#include "mpv_talloc.h"
|
2013-10-29 22:38:29 +01:00
|
|
|
|
2013-12-17 02:39:45 +01:00
|
|
|
#include "common/msg.h"
|
2013-12-17 02:02:25 +01:00
|
|
|
#include "options/options.h"
|
2013-12-17 02:39:45 +01:00
|
|
|
#include "common/common.h"
|
2014-10-03 22:32:16 +02:00
|
|
|
#include "common/global.h"
|
2013-10-29 22:38:29 +01:00
|
|
|
|
|
|
|
#include "stream/stream.h"
|
|
|
|
#include "sub/dec_sub.h"
|
|
|
|
#include "demux/demux.h"
|
|
|
|
#include "video/mp_image.h"
|
|
|
|
|
2013-12-17 01:08:53 +01:00
|
|
|
#include "core.h"
|
2013-10-29 22:38:29 +01:00
|
|
|
|
2016-01-17 16:56:32 +01:00
|
|
|
// 0: primary sub, 1: secondary sub, -1: not selected
|
|
|
|
static int get_order(struct MPContext *mpctx, struct track *track)
|
2014-12-21 23:47:00 +01:00
|
|
|
{
|
2020-04-15 17:03:37 +02:00
|
|
|
for (int n = 0; n < num_ptracks[STREAM_SUB]; n++) {
|
2016-01-17 16:56:32 +01:00
|
|
|
if (mpctx->current_track[n][STREAM_SUB] == track)
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void reset_subtitles(struct MPContext *mpctx, struct track *track)
|
|
|
|
{
|
2019-06-03 02:05:52 +02:00
|
|
|
if (track->d_sub) {
|
2016-01-17 16:56:32 +01:00
|
|
|
sub_reset(track->d_sub);
|
2019-06-03 02:05:52 +02:00
|
|
|
sub_set_play_dir(track->d_sub, mpctx->play_dir);
|
|
|
|
}
|
2015-11-17 01:54:02 +01:00
|
|
|
term_osd_set_subs(mpctx, NULL);
|
2014-12-21 23:47:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void reset_subtitle_state(struct MPContext *mpctx)
|
|
|
|
{
|
2020-02-04 20:26:35 +01:00
|
|
|
for (int n = 0; n < mpctx->num_tracks; n++)
|
|
|
|
reset_subtitles(mpctx, mpctx->tracks[n]);
|
2016-01-17 16:56:32 +01:00
|
|
|
term_osd_set_subs(mpctx, NULL);
|
2014-12-21 23:47:00 +01:00
|
|
|
}
|
|
|
|
|
2016-01-17 16:56:32 +01:00
|
|
|
void uninit_sub(struct MPContext *mpctx, struct track *track)
|
2014-10-03 19:57:49 +02:00
|
|
|
{
|
2016-01-17 16:56:32 +01: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 21:54:17 +01:00
|
|
|
osd_set_sub(mpctx->osd, order, NULL);
|
2018-06-30 17:15:29 +02:00
|
|
|
sub_destroy(track->d_sub);
|
|
|
|
track->d_sub = NULL;
|
2014-10-03 19:57:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void uninit_sub_all(struct MPContext *mpctx)
|
|
|
|
{
|
2016-01-17 16:56:32 +01:00
|
|
|
for (int n = 0; n < mpctx->num_tracks; n++)
|
|
|
|
uninit_sub(mpctx, mpctx->tracks[n]);
|
2014-10-03 19:57:49 +02:00
|
|
|
}
|
|
|
|
|
2016-01-17 16:56:32 +01:00
|
|
|
static bool update_subtitle(struct MPContext *mpctx, double video_pts,
|
|
|
|
struct track *track)
|
2013-10-29 22:38:29 +01:00
|
|
|
{
|
2016-01-17 16:56:32 +01:00
|
|
|
struct dec_sub *dec_sub = track ? track->d_sub : NULL;
|
2014-10-03 19:57:49 +02:00
|
|
|
|
2016-01-17 16:56:32 +01:00
|
|
|
if (!dec_sub || video_pts == MP_NOPTS_VALUE)
|
2015-12-29 01:35:52 +01:00
|
|
|
return true;
|
2014-10-03 19:57:49 +02:00
|
|
|
|
2016-01-14 00:18:48 +01: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 11:53:44 +01:00
|
|
|
struct mp_image_params params = mpctx->vo_chain->filter->input_params;
|
2013-11-23 21:39:07 +01:00
|
|
|
if (params.imgfmt)
|
|
|
|
sub_control(dec_sub, SD_CTRL_SET_VIDEO_PARAMS, ¶ms);
|
2013-10-29 22:38:29 +01: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 14:50:36 +01:00
|
|
|
if (track->demuxer->fully_read && sub_can_preload(dec_sub)) {
|
2016-01-21 23:49:25 +01:00
|
|
|
// Assume fully_read implies no interleaved audio/video streams.
|
|
|
|
// (Reading packets will change the demuxer position.)
|
2016-02-28 19:14:23 +01: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 14:50:36 +01:00
|
|
|
sub_preload(dec_sub);
|
2016-01-21 23:49:25 +01:00
|
|
|
}
|
|
|
|
|
2023-09-30 15:58:56 +02:00
|
|
|
if (!sub_read_packets(dec_sub, video_pts, mpctx->paused))
|
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 14:50:36 +01:00
|
|
|
return false;
|
2013-10-29 22:38:29 +01:00
|
|
|
|
2013-12-24 17:46:14 +01:00
|
|
|
// Handle displaying subtitles on terminal; never done for secondary subs
|
2020-05-14 22:14:49 +02:00
|
|
|
if (mpctx->current_track[0][STREAM_SUB] == track && !mpctx->video_out) {
|
|
|
|
char *text = sub_get_text(dec_sub, video_pts, SD_TEXT_TYPE_PLAIN);
|
|
|
|
term_osd_set_subs(mpctx, text);
|
|
|
|
talloc_free(text);
|
|
|
|
}
|
2015-12-29 01:35:52 +01:00
|
|
|
|
2016-10-26 20:43:03 +02:00
|
|
|
// Handle displaying subtitles on VO with no video being played. This is
|
2019-05-19 14:54:59 +02:00
|
|
|
// quite different, because normally subtitles are redrawn on new video
|
2016-10-26 20:43:03 +02:00
|
|
|
// frames, using the video frames' timestamps.
|
2020-12-23 07:40:32 +01:00
|
|
|
if (mpctx->video_out && mpctx->video_status == STATUS_EOF &&
|
2021-06-27 08:30:24 +02:00
|
|
|
(mpctx->opts->subs_rend->sub_past_video_end ||
|
|
|
|
!mpctx->current_track[0][STREAM_VIDEO] ||
|
|
|
|
mpctx->current_track[0][STREAM_VIDEO]->attached_picture)) {
|
2016-10-26 20:43:03 +02: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 12:03:46 +01:00
|
|
|
// Force an arbitrary minimum FPS
|
|
|
|
mp_set_timeout(mpctx, 0.1);
|
2016-10-26 20:43:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-29 01:35:52 +01:00
|
|
|
return true;
|
2013-12-24 17:46:14 +01:00
|
|
|
}
|
|
|
|
|
2015-12-29 01:35:52 +01: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 17:46:14 +01:00
|
|
|
{
|
2016-01-17 16:56:32 +01:00
|
|
|
bool ok = true;
|
2020-04-15 17:03:37 +02:00
|
|
|
for (int n = 0; n < num_ptracks[STREAM_SUB]; n++)
|
2016-01-17 16:56:32 +01:00
|
|
|
ok &= update_subtitle(mpctx, video_pts, mpctx->current_track[n][STREAM_SUB]);
|
|
|
|
return ok;
|
2013-10-29 22:38:29 +01:00
|
|
|
}
|
|
|
|
|
2016-03-03 18:48:56 +01: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 02:07:01 +01:00
|
|
|
static bool init_subdec(struct MPContext *mpctx, struct track *track)
|
2013-12-24 17:46:14 +01:00
|
|
|
{
|
2016-01-17 16:56:32 +01:00
|
|
|
assert(!track->d_sub);
|
2015-12-26 18:32:27 +01:00
|
|
|
|
2015-12-27 02:07:01 +01:00
|
|
|
if (!track->demuxer || !track->stream)
|
|
|
|
return false;
|
2013-12-24 17:46:14 +01:00
|
|
|
|
2021-05-27 07:56:41 +02:00
|
|
|
track->d_sub = sub_create(mpctx->global, track,
|
sub: align ytdl-hook secondary subs to the top
29e15e6248 prefixed youtube-dl's subs url with an edl prefix to not
download them until they're selected, which is useful when there are
many sub languages. But this prefix broke the alignment of secondary
subs, which would overlap the primary subs instead of always being
placed at the top. This can be tested with
--sub-file='edl://!no_clip;!delay_open,media_type=sub;secondary_sub.srt'
When a sub is added, sub.c:reinit_sub() is called. This calls in
init_subdec() -> dec_sub.c:sub_create() -> init_decoder() ->
sd_ass:init(). Then reinit_sub() calls
sub_control(track->d_sub, SD_CTRL_SET_TOP, &(bool){!!order}) which sets
sd_ass_priv.on_top = true for secondary subs.
But for EDL subs the real sub is initialized again when in
dec_sub.c:sub_read_packets() is_new_segment() returns true and
update_segment() is called, or when sub_get_bitmaps() calls
update_segment(). update_segment() then calls init_decoder(), which
calls sd_ass:init(), so sd_ass_priv is reinitialized, and its on_top
property is left false. This commit sets it to true again.
For URLs that need to be downloaded it seems that the update_segment()
call that reinitializes sd_ass_priv is always the one in
sub_read_packets(), but with local subs sub_get_bitmaps() is usually
called earlier (though there shouldn't be a reason to use the EDL URL
for local subs), so I added the order parameter to sub_create(), rather
than adding it to all of update_segment(), sub_read_packets() and
sub_get_bitmaps().
Also removes the cast to bool in the other sub_control call, since
sub/sd_ass.c:control already casts arg to bool when cmd is
SD_CTRL_SET_TOP.
2021-08-10 22:11:53 +02:00
|
|
|
get_all_attachments(mpctx),
|
|
|
|
get_order(mpctx, track));
|
2016-01-17 16:56:32 +01:00
|
|
|
if (!track->d_sub)
|
2015-12-27 02:07:01 +01:00
|
|
|
return false;
|
2015-12-27 01:25:32 +01:00
|
|
|
|
2016-01-17 18:07:50 +01:00
|
|
|
struct track *vtrack = mpctx->current_track[0][STREAM_VIDEO];
|
2016-01-12 23:48:19 +01:00
|
|
|
struct mp_codec_params *v_c =
|
2016-01-17 18:07:50 +01:00
|
|
|
vtrack && vtrack->stream ? vtrack->stream->codec : NULL;
|
2016-01-12 23:48:19 +01:00
|
|
|
double fps = v_c ? v_c->fps : 25;
|
2016-01-17 16:56:32 +01:00
|
|
|
sub_control(track->d_sub, SD_CTRL_SET_VIDEO_DEF_FPS, &fps);
|
2013-12-24 17:46:14 +01:00
|
|
|
|
2015-12-27 02:07:01 +01:00
|
|
|
return true;
|
2013-12-24 17:46:14 +01:00
|
|
|
}
|
|
|
|
|
2016-01-17 16:56:32 +01:00
|
|
|
void reinit_sub(struct MPContext *mpctx, struct track *track)
|
2013-10-29 22:38:29 +01:00
|
|
|
{
|
2016-01-17 16:56:32 +01:00
|
|
|
if (!track || !track->stream || track->stream->type != STREAM_SUB)
|
2013-10-29 22:38:29 +01:00
|
|
|
return;
|
|
|
|
|
2018-06-30 17:15:29 +02:00
|
|
|
assert(!track->d_sub);
|
|
|
|
|
|
|
|
if (!init_subdec(mpctx, track)) {
|
2015-12-27 02:07:01 +01:00
|
|
|
error_on_track(mpctx, track);
|
|
|
|
return;
|
|
|
|
}
|
2013-10-29 22:38:29 +01:00
|
|
|
|
2016-01-17 16:56:32 +01:00
|
|
|
sub_select(track->d_sub, true);
|
|
|
|
int order = get_order(mpctx, track);
|
2016-03-08 21:54:17 +01:00
|
|
|
osd_set_sub(mpctx->osd, order, track->d_sub);
|
sub: align ytdl-hook secondary subs to the top
29e15e6248 prefixed youtube-dl's subs url with an edl prefix to not
download them until they're selected, which is useful when there are
many sub languages. But this prefix broke the alignment of secondary
subs, which would overlap the primary subs instead of always being
placed at the top. This can be tested with
--sub-file='edl://!no_clip;!delay_open,media_type=sub;secondary_sub.srt'
When a sub is added, sub.c:reinit_sub() is called. This calls in
init_subdec() -> dec_sub.c:sub_create() -> init_decoder() ->
sd_ass:init(). Then reinit_sub() calls
sub_control(track->d_sub, SD_CTRL_SET_TOP, &(bool){!!order}) which sets
sd_ass_priv.on_top = true for secondary subs.
But for EDL subs the real sub is initialized again when in
dec_sub.c:sub_read_packets() is_new_segment() returns true and
update_segment() is called, or when sub_get_bitmaps() calls
update_segment(). update_segment() then calls init_decoder(), which
calls sd_ass:init(), so sd_ass_priv is reinitialized, and its on_top
property is left false. This commit sets it to true again.
For URLs that need to be downloaded it seems that the update_segment()
call that reinitializes sd_ass_priv is always the one in
sub_read_packets(), but with local subs sub_get_bitmaps() is usually
called earlier (though there shouldn't be a reason to use the EDL URL
for local subs), so I added the order parameter to sub_create(), rather
than adding it to all of update_segment(), sub_read_packets() and
sub_get_bitmaps().
Also removes the cast to bool in the other sub_control call, since
sub/sd_ass.c:control already casts arg to bool when cmd is
SD_CTRL_SET_TOP.
2021-08-10 22:11:53 +02:00
|
|
|
sub_control(track->d_sub, SD_CTRL_SET_TOP, &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 19:56:13 +02:00
|
|
|
|
2023-08-09 23:39:58 +02:00
|
|
|
// When paused we have to wait for packets to be available.
|
|
|
|
// So just retry until we get a packet in this case.
|
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 19:56:13 +02:00
|
|
|
if (mpctx->playback_initialized)
|
2023-08-09 23:39:58 +02:00
|
|
|
while (!update_subtitles(mpctx, mpctx->playback_pts) && mpctx->paused);
|
2016-01-17 16:56:32 +01:00
|
|
|
}
|
2015-12-27 02:07:01 +01:00
|
|
|
|
2016-01-17 16:56:32 +01:00
|
|
|
void reinit_sub_all(struct MPContext *mpctx)
|
|
|
|
{
|
2020-04-15 17:03:37 +02:00
|
|
|
for (int n = 0; n < num_ptracks[STREAM_SUB]; n++)
|
2016-01-17 16:56:32 +01:00
|
|
|
reinit_sub(mpctx, mpctx->current_track[n][STREAM_SUB]);
|
2013-10-29 22:38:29 +01:00
|
|
|
}
|