From 642e963c86040350ac8f06b9731e6126f4d55316 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 18 Jun 2017 18:27:48 +0200 Subject: [PATCH] dec_video: change license to LGPL (almost) "Almost" because this might contain copyright by michael, who agreed with LGPL, but only once the core is LGPL. This is preparation for that to happen. Apart from that, the usual remarks apply. In particular, dec_video.c started out quite chaotic with no modularization, but was later basically gutted, and in general rewritten a bunch of times. Not going to give a history lesson. Special attention needs to be given to 3 patches by cehosos, who did not agree to the relicensing: 240b743ebdf: --field-dominance e32cbbf7dc3: reinit VO if aspect ratio changes 306f6243fdf: use container aspect if codec aspect unset (?) The first patch is pretty clearly still in the current code, and needs to be disabled for LGPL. The functionality of the second patch is still active, but implemented completely different, and as part of general frame parameter changes (at the time of the patch, MPlayer already reinitialized the VO on frame size and pixel format changes - all this was merged into a single check for changing image parameters). The third patch makes me a bit more uncomfortable. It appears the code was moved to dec_video.c in de68b8f23c8c, and further changed in 82f0d373, 0a0bb905, and bf13bd0d. You could claim that cehoyos' copyright still sticks. Fortunately, we implement alternative aspect detection, which is simpler and probably preferable, and which arguably contains none of the original code and logic, and thus should be fully safe. While I don't know if cehoyos' copyright actually still applies, I'm more comfortable with making the code GPL-only for now. Also change the default to use the (in future) plain LGPL code, and deprecate the one associated with the GPL code, so we can eventually remove the GPL code. But it's also possible we decide that the copyright doesn't apply, and undo the deprecation and GPL guards. I expect that users won't notice anything. If you ask me, the old aspect method was probably an accidental bug instead of intentional behavior. Although, the new aspect method was broken too, so I had to fix it. --- Copyright | 2 +- DOCS/interface-changes.rst | 2 ++ DOCS/man/options.rst | 5 +++-- options/options.c | 1 + video/decode/dec_video.c | 18 +++++++++++++++++- video/decode/dec_video.h | 2 ++ 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Copyright b/Copyright index d92f323a82..5dfd6a8a01 100644 --- a/Copyright +++ b/Copyright @@ -267,7 +267,7 @@ x stream/stream.h hard sub/* LGPL ta/* LGPL (ISC) video/decode/d3d.* LGPL -x video/decode/dec_video.* hard + video/decode/dec_video.* almost LGPL video/decode/hw_cuda.c LGPL video/decode/hw_d3d11va.c LGPL video/decode/hw_dxva2.c LGPL diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst index 38776b32b9..a8340dc409 100644 --- a/DOCS/interface-changes.rst +++ b/DOCS/interface-changes.rst @@ -27,6 +27,8 @@ Interface changes - drop the internal "mp-rawvideo" codec (used by --demuxer=rawvideo) - rename --sub-ass-style-override to --sub-ass-override, and rename the `--sub-ass-override=signfs` setting to `--sub-ass-override=scale`. + - change default of --video-aspect-method to "bitstream". The "hybrid" + method (old default) is deprecated. --- mpv 0.25.0 --- - remove opengl-cb dxva2 dummy hwdec interop (see git "vo_opengl: remove dxva2 dummy hwdec backend") diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index 4d2be6ad66..080bf73582 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -823,12 +823,13 @@ Video :hybrid: Prefer the container aspect ratio. If the bitstream aspect switches mid-stream, switch to preferring the bitstream aspect. - This is the default behavior in mpv and mplayer2. + This was the default in older mpv and mplayer2. Deprecated. :container: Strictly prefer the container aspect ratio. This is apparently the default behavior with VLC, at least with Matroska. :bitstream: Strictly prefer the bitstream aspect ratio, unless the bitstream aspect ratio is not set. This is apparently the default behavior - with XBMC/kodi, at least with Matroska. + with XBMC/kodi, at least with Matroska, and the current default + for mpv. Normally you should not set this. Try the ``container`` and ``bitstream`` choices if you encounter video that has the wrong aspect ratio in mpv, diff --git a/options/options.c b/options/options.c index 90cbe61d6f..38af34219b 100644 --- a/options/options.c +++ b/options/options.c @@ -943,6 +943,7 @@ const struct MPOpts mp_default_opts = { .playback_speed = 1., .pitch_correction = 1, .movie_aspect = -1., + .aspect_method = 1, .field_dominance = -1, .sub_auto = 0, .audiofile_auto = -1, diff --git a/video/decode/dec_video.c b/video/decode/dec_video.c index 5231fad240..bd20dbe312 100644 --- a/video/decode/dec_video.c +++ b/video/decode/dec_video.c @@ -13,6 +13,10 @@ * * You should have received a copy of the GNU General Public License along * with mpv. If not, see . + * + * Almost LGPL. + * + * Parts under HAVE_GPL are licensed under GNU General Public License forever. */ #include @@ -197,12 +201,16 @@ static void fix_image_params(struct dec_video *d_video, // While mp_image_params normally always have to have d_w/d_h set, the // decoder signals unknown bitstream aspect ratio with both set to 0. float dec_aspect = p.p_w > 0 && p.p_h > 0 ? p.p_w / (float)p.p_h : 0; + +#if HAVE_GPL if (d_video->initial_decoder_aspect == 0) d_video->initial_decoder_aspect = dec_aspect; +#endif bool use_container = true; switch (opts->aspect_method) { case 0: +#if HAVE_GPL // We normally prefer the container aspect, unless the decoder aspect // changes at least once. if (dec_aspect > 0 && d_video->initial_decoder_aspect != dec_aspect) { @@ -212,8 +220,14 @@ static void fix_image_params(struct dec_video *d_video, use_container = false; } break; +#else + /* fall through, behave as "bitstream" */ +#endif case 1: - use_container = false; + if (dec_aspect) { + MP_VERBOSE(d_video, "Using bitstream aspect ratio.\n"); + use_container = false; + } break; } @@ -300,12 +314,14 @@ static bool receive_frame(struct dec_video *d_video, struct mp_image **out_image if (!mpi) return progress; +#if HAVE_GPL if (opts->field_dominance == 0) { mpi->fields |= MP_IMGFIELD_TOP_FIRST | MP_IMGFIELD_INTERLACED; } else if (opts->field_dominance == 1) { mpi->fields &= ~MP_IMGFIELD_TOP_FIRST; mpi->fields |= MP_IMGFIELD_INTERLACED; } +#endif // Note: the PTS is reordered, but the DTS is not. Both should be monotonic. double pts = mpi->pts; diff --git a/video/decode/dec_video.h b/video/decode/dec_video.h index 5ef1f9252a..8d1936e016 100644 --- a/video/decode/dec_video.h +++ b/video/decode/dec_video.h @@ -13,6 +13,8 @@ * * You should have received a copy of the GNU General Public License along * with mpv. If not, see . + * + * Almost LGPL. */ #ifndef MPLAYER_DEC_VIDEO_H