Libass has its own BiDi handling now, and preprocessing the subtitles
with FriBiDi before passing them to libass breaks things. Disable our
own FriBiDi code when libass rendering is used. This affects external
subtitle files of other formats parsed with subreader.c and converted
to ASS tracks.
Set the "Style" attribute for subtitle events created in sd_ass to
match the "default_style" attribute of the track. This is required to
make --ass-styles work with recent libass versions (otherwise the
event would use style 0, which is a fallback style added by libass
now).
Commit 378ada847c ("sub/ass: use default
style, not first style unconditionally") fixed the same issue for
external subtitles converted with mp_ass_read_subdata(); this commit
fixes it for muxed ones.
The last libpostproc major version change from 51 to 52 changed the
type of the "pp_help" symbol from a pointer to help text to the help
text itself. This made --pphelp crash. Change the option definition to
match the new type. This probably makes it crash if compiled against
older libpostproc, but the option is not important enough to try
supporting that (I've seen no reports of the crash, probably people
just don't use the option).
Add functionality to mark options that depend on features disabled at
compile time as disabled rather than not compiling the option
definitions at all. This allows printing a warning about the option
not being available because of a disabled feature, instead of just
"unknown option". Because the option definitions are still compiled
fully, this only works for definitions that do not reference symbols
which are not available if the feature is disabled. Use the new
functionality for options depending on libass.
1916b95b8 changed two function types from returning "void" to
returning "int", but was missing changes to add "return 0;" to the
functions. Fix.
The reason for the change in the original commit was that the
functions were called through a function pointer returning int anyway,
so the missing return probably made things no more likely to fail at
runtime than they were before that commit. However, it caused a
compilation failure with clang, which treats non-void function not
returning a value as a fatal error (in GCC it's just a warning).
Previously the code converting text subtitles to ASS format converted
newline characters, and only those, to ASS "new line" markup. If the
subtitles contained "\r\n", the "\r" was thus left in the text. In
previous libass versions the "\r" was not visible, but in the current
one it produces an empty box. Improve the conversion to remove the
"\r" in that case. Also treat a lone "\r" as a newline.
demux_mf allocated the "type" suboption of "--mf" with strdup if it
was not explicitly set. This caused a crash after playing an mf://
entry. Fix to use talloc instead.
When parsing the command line, map "--no-foo" to "--foo=no" if an
option named "foo" exists and is a flag option. Non-empty parameters
are not allowed with this syntax ("--no-foo=no" is invalid).
This implementation is different from the existing "--nofoo" variants
for most flag options. Those are implemented as completely separate
options; there's an option named "fs" and a separate option named
"nofs" (thus "--no-nofs" actually works after this change...). The
reason for adding the new syntax is to support the much more standard
"--no-" prefix and to allow eventually cleaning up the option handling
(though the "nofoo" variants of existing options can't be removed soon
due to backwards compatibility).
Rewrite the csputils.c code generating a conversion matrix for
YUV->RGB conversions (currently used by vo_gl only). Functional
differences:
- The separate "mplayer default" colorspace is removed, and BT.601 is
used instead (the default colorspace was in fact BT.601; see below).
- The old code was missing chroma scaling. As a result the "mplayer
default" colorspace actually mapped to BT.601, and everything else
was buggy (I guess the other colorspaces were added with particular
coefficient semantics, without understanding that the original
"default colorspace" was actually BT.601 and why its coefficients
differed from the added version).
- The old code had a bug in the equalizer hue equations.
- The old code assumed that for specifying whether input and output
were limited-range or full-range YUV or RGB it would make sense to
specify "no conversion" meaning full-range YUV to full-range RGB or
limited-range YUV to limited-range RGB. This isn't true; limited-
range YUV has different ranges for luma and chroma (16-235
vs 16-240) which means you have to scale chroma for limited->limited
conversions. The new code assumes limited->limited conversions for
the levelconv parameter 2. It'd probably make sense to change the
API later to specify the ranges of input and output separately.
- The undocumented EBU and XYZ colorspaces are removed. I doubt any
videos use these. Also the EBU colorspace looks like it'd expect
a different input range - at least no input would map to full RGB
red as it was.
FFmpeg has increased FF_INPUT_BUFFER_PADDING_SIZE to 16 (unlike Libav
which still has it at 8). Raise MP_INPUT_BUFFER_PADDING_SIZE to 16 to
allow compilation against FFmpeg too (demuxer.c checks the padding
size for packets is at least as much as libavcodec wants for its
decoders, and this check failed with the previous value of 8).
Commit dde8b753e4 merged an mplayer1 change (r31328) that set
correct_pts to true if FPS was not set (on the assumption that
correct-pts mode could provide proper timing without FPS). As the
merge commit noted this change was somewhat questionable, as the
option shouldn't really change after things have already been
initialized. After recent changes it can cause an outright crash
(assert in ds_get_packet2() from 9c7c4e5b7d fails). Remove the hack.
Also only print a warning about not having FPS if correct_pts is not
set (in correct_pts mode not having FPS shouldn't be a real problem,
as everything is based on timestamps anyway).
Convert the list of VOCTLR_* defines to an enum, dropping some unused
values. This resolves a collision between VOCTRL_XOVERLAY_SET_COLORKEY
and VOCTRL_REDRAW_OSD, which had the same value (the XOVERLAY one was
only used by vo_xvr100 and vo_tdfx, so this didn't matter much in
practice).
ad_ffmpeg init() function did not free resources if opening failed.
Outside code (dec_audio.c) does not automatically call uninit() if
init() returns failure, and the uninit function would have crashed in
some cases had it been called (it did freed lavc_context->extradata,
but lavc_context could have been NULL after early init failure). Add
explicit calls to uninit() after failure and make uninit function safe
to call at any point.
At least the libavcodec WavPack decoder can return output for an audio
frame in multiple parts and return 0 bytes input consumed for the
initial parts. Timing info was not set correctly in this case:
sh_audio->pts and pts_bytes were reset each time when decoding more
from the packet, as if the packet had been new (ds_get_packet_pts()
has a check to return MP_NOPTS_VALUE if the packet has already been
partially read, but that didn't trigger since libavcodec returned
exactly 0 bytes read so the demuxer-visible packet state didn't
change).
Add a field to keep track of whether a packet has already been decoded
from, and don't reset timing info again if so. Adding the field
requires adding a decoder context to store it (there wasn't one
before).
BTW the WavPack decoder behavior and avcodec_decode_audio3()
documentation don't match - the documentation says the return value is
"zero if no frame data was decompressed (used) from the input
AVPacket", while the decoder DOES return some frame data which comes
from the input packet.
Commit 6e8d420a41 ("demux: avoid a copy of demux packets with lavf,
reduce padding") was missing an av_dup_packet() line. As a result at
least formats that use parsing on the lavf side could fail (with
parsing the packet may contain pointers to temporary fields that
will be overwritten/freed when reading further packets, and
av_dup_packet() is required to allocate permanent storage).
Use the "--print-errors" flag of pkg-config when testing for the
presence of Libav libraries. Even though the error output is a bit
messy (printed on the same "Checking for"... line), it does contain
useful information for this test which checks for several libraries at
once.
Also change the test name from "FFmpeg" to "Libav" and rename the
option from --disable-ffmpeg to --disable-libav. The change should
cause no compatibility problems as the option is very rarely used.
After 0ece360eea ("demux_mkv: skip files faster in ordered chapter
file search") some Matroska files failed to open. The problem was that
demux_mkv_read_info() returned 0 on success, but the opening code
interpreted this as a value to stop parsing further headers. Fix this
and also modify some of the other return value handling.
Pass the libavformat packet side_data field from demux_lavf to
vd_ffmpeg. Libavcodec/libavformat use this field for palette data, and
passing it is required for the playback of some paletted video codecs.
The implementation works by giving vd_ffmpeg a copy of the struct
demux_packet used to store the video packet (from which it can access
the avpacket field). The definition of struct demux_packet is moved to
new file demux_packet.h so that vd_ffmpeg.c can use it without
including all of demuxer.h.
Export the codec private data field for WavPack and TrueHD audio
tracks. At least for WavPack this is necessary to make some samples
work.
Also change some other cases to use the same data-copying code.
When switching audio or video tracks, demux_mkv only checked that the
new index fell in the range corresponding to tracks existing in the
file being played. However, if the demuxer can not recognize the
format of a track or detects an error, some of those tracks in the
file may not be exported from the demuxer and are not visible to the
rest of the player. Selecting such a track would cause a crash. Add
checks skip such tracks when cycling to next track and switch to
nosound instead if given an explicit track number corresponding to
such a track.
demuxer.c calls demuxer->close() even if opening failed. Thus the
mkv_free() call added in 0ece360eea ("demux_mkv: skip files faster
in ordered chapter file search") was wrong, and could cause a crash
from a double free if some data structures were allocated before the
opening attempt was aborted.
Drop the unnecessary include and add a missing direct include in some
files. This also revealed that demux_rtp_internal.h was missing a
config.h include, fix that too.
Remove unnecessary demuxer.h include from aviheader.h. Through
stheader.h aviheader.h is included in a lot of files. Add missing
mp_msg.h includes to av_sub.c and sd_ass.c (previously hidden by
indirect inclusion through demuxer.h and stream.h).
When demux_lavf read a new packet it used to copy the data from
libavformat's struct AVPacket to struct demux_packet and then free the
lavf packet. Change it to instead keep the AVPacket allocated and
point demux_packet fields to the buffer in that.
Also change MP_INPUT_BUFFER_PADDING_SIZE to 8 which matches
FF_INPUT_BUFFER_PADDING SIZE; demux_lavf packets won't have more
padding now anyway (it was increased from 8 earlier when
FF_INPUT_BUFFER_PADDING_SIZE was increased in libavcodec, but that
change was reverted).
The destructors used by talloc take a "void *" first parameter.
However talloc.h had a #define hack that treated the destructor as a
function taking first parameter of type "typeof(ptr)" where ptr is the
pointer the destructor is set for. I suppose this was done to add some
kind of "type safety" against adding a destructor expecting another
type of pointer; however this hack is questionable and violates the
real C level typing. Remove the hack from the header and adjust
talloc.c to avoid a warning about a C type violation that became
visible after removing the hack.
vf_screenshot checked for a list of pixel formats that were known to
work with swscale. However, the list was incomplete. If a pixel format
was used that was not on the vf_screenshot list, but was supported
both by swscale and the VO driver, mplayer2 would insert a useless
scale filter to convert to a format supported by vf_screenshot. Fix
this by making vf_screenshot check directly whether the pixel format
is supported by swscale with sws_isSupportedInput().
At least libavformat mpegts demuxer may give bad parameters with NULL
AVClass to the av_log callback. Check for this and print a warning
instead of crashing.
Add option --ass-vsfilter-aspect-compat and corresponding property
ass_vsfilter_aspect_compat. The setting controls whether to enable the
emulation of traditional VSFilter behavior where subtitles are
stretched if the video is anamorphic (previously always enabled for
native SSA/ASS subtitles). Enabled by default. Add 'V' as a new
default keybinding to toggle the property.
Commit decec7f2a3 ("vo_vdpau: skip resize code if not fully
initialized") broke preemption recovery because the resize code stayed
incorrectly disabled when it would have been used to reinitialize
things during recovery. Revert that commit and add different checks
to avoid running various code when not in a fully functional state.
The variable corresponding to the "fast" suboption of ao_pcm was
uninitialized. Fix. The only effect was possibly printing a warning
about the suboption being deprecated even if it wasn't used.
The committed version of 58834653c0 ("dvdnav: make
mp_dvdnav_save_smpi() more robust") was somehow missing one line which
caused a crash with dvdnav. Add it back.
Don't interpret native MPEG codec tags using our generic
format-agnostic codec tag tables. MPEG may use tag 3 for MP3, whereas
the generic tables map 3 to uncompressed PCM. Make the code ignore the
codec_tag field for the "mpeg" and "mpegts" libavformat demuxers and
rely on the codec_id value provided by lavf only.
The OSD text buffers (mp_osd_msg_t.text and osd_state.text) used to be
static arrays, with the buffer sizes spread all over the code as magic
constants. Make the buffers dynamically allocated and remove the
arbitrary length limits.
Remove several old options that were deprecated and disabled years ago
and whose only effect now was to show a custom error message about the
option in question being deprecated and then exit. Also remove the -vd
option which was just a stupid joke and never had useful functionality.
Remove outdated "!mpctx->sh_video" checks in chapter seeking and
naming functions left over from when timeline functionality did not
support audio-only case.
Libass rendering uses two renderer objects to support both VSFilter
aspect ratio (mis)behavior emulation and correct rendering. When
option values were changed during playback the changes were applied to
the renderer used for the currently active track only, and old values
could be used if the user then switched to a track using the other
renderer object. Fix to update both renderers.
When libass-related options were changed at runtime, the
reinitilization code executed ass_set_margins() with arguments that
were correct for the vf_ass case but wrong for EOSD. This could cause
the subtitles to be displayed incorrectly for one frame (vf_vo would
run ass_set_margins() again with the correct parameters for the next
frame). The call is actually redundant for the vf_ass case too as
it's currently not possible to modify the margins during playback, so
fix the problem by disabling the call.
When using the "old" subtitle renderer (i.e. not libass), changes to this
property were not reflected immediately, and came into effect only when the
next subtitle event was rendered.