Commit Graph

3823 Commits

Author SHA1 Message Date
wm4 a1244111a7 windows support: unicode filenames
Windows uses a legacy codepage for char* / runtime functions accepting
char *. Using UTF-8 as the codepage with setlocale() is explicitly
forbidden.

Work this around by overriding the MSVCRT functions with wrapper
macros, that assume UTF-8 and use "proper" API calls like _wopen etc.
to deal with unicode filenames. All code that uses standard functions
that take or return filenames must now include osdep/io.h. stat()
can't be overridden, because MinGW-w64 itself defines "stat" as a
macro. Change code to use use mp_stat() instead.

This is not perfectly clean, but still somewhat sane, and much better
than littering the rest of the mplayer code with MinGW specific hacks.
It's also a bit fragile, but that's actually little different from the
previous situation. Also, MinGW is unlikely to ever include a nice way
of dealing with this.
2012-03-09 20:48:54 +02:00
wm4 24be34f1e9 cleanup: Silence compilation warnings on MinGW-w64
Some of the code, especially the dshow and windows codec loader parts,
are extremely hacky and likely full of bugs. The goal is merely getting
rid of warnings that could obscure more important warnings and actual
bugs, instead of fixing actual problems. This reduces the number of
warnings from over 500 to almost the same as when compiling on Linux.

Note that many problems stem from using the ancient wine-derived
windows headers. There are some differences to the "proper" windows
header. Changing the code to compile with the proper headers would be
too much trouble, and it still has to work on Unix.

Some of the changes might actually break compilation on legacy MinGW,
but we don't support that anymore. Always use MinGW-w64, even when
compiling to 32 bit.

Fixes some warnings in the win32 loader code on Linux too.
2012-03-01 00:22:30 +02:00
Uoti Urpala afecdb681b aviheader.c: silence a warning
libmpdemux/aviheader.c:235:7: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
2012-02-29 02:49:48 +02:00
Uoti Urpala 9f9bbb3c8b demux_lavf: update growing file size info for AVSEEK_SIZE
demux_lavf was returning a static size value when libavformat queried
file size with AVSEEK_SIZE. Add code to query the stream for possibly
changed value first. This at least improves seeking with growing MPEG
files; before seeks would never go beyond the part of the file that
existed when the stream was first opened.
2012-02-26 05:53:13 +02:00
Uoti Urpala fc6a9e4a3e build: switch to libavutil bswap.h and intreadwrite.h
Remove the private bswap and intreadwrite.h implementations and use
libavutil headers instead.

Originally these headers weren't publicly installed by libavutil at
all. That already changed in 2010, but the pure C bswap version in
installed headers was very inefficient. That was recently (2011-12)
improved and now using the public bswap version probably shouldn't
cause noticeable performance problems, at least if using a new enough
compiler.
2012-02-01 22:46:27 +02:00
Uoti Urpala cdb6d157cc demux_lavf: use Libav RIFF tag lists directly
Change demux_lavf to use CodecID -> RIFF tag mappings that are now
available through the public Libav API. Previously it used a copy in
ffmpeg_files/taglists.c. That can now be deleted.
2012-02-01 22:46:27 +02:00
Uoti Urpala db8cdc73e3 Update Libav API uses
Change various code to use the latest Libav API. The libavcodec
error_recognition setting has been removed and replaced with different
semantics. I removed the "--lavdopts=er=<value>" option accordingly,
as I don't think it's widely enough used to be worth attempting to
emulate the old option semantics using the new API. A new option with
the new semantics can be added later if needed.

Libav dropped APIs that were necessary with all Libav versions
until quite recently (like setting avctx->age), and it would thus not
be possible to keep compatibility with previous Libav versions without
adding workarounds. The new APIs also had some bugs/limitations in the
recent Libav release 0.8, and it would not work fully (at least some
avcodec options would not be set correctly). Because of those issues,
this commit makes no attempt to maintain compatibility with anything
but the latest Libav git head. Hopefully the required fixes and
improvements will be included in a following Libav point release.
2012-02-01 22:46:27 +02:00
Uoti Urpala 62e3877417 ad_ffmpeg: pass packet side data from libavformat
Pass avpacket->side_data when using a libavcodec audio decoder
together with libavformat demuxer (this was already done for video).
2012-01-08 23:32:40 +02:00
Uoti Urpala 1bd5871762 Libav API updates (remove most deprecated-in-0.7 uses)
Update various code using Libav libraries to remove use of API
features that were deprecated at Libav release 0.7. I think this
removes them all with the exception of URLContext functions still used
in stream_ffmpeg.c (at least other uses that generated deprecation
warnings with libraries from 0.7 are removed).
2011-12-22 04:43:02 +02:00
Uoti Urpala 37e4a928ca configure, build: require at least Libav 0.7
Require versions of the Libav libraries corresponding to Libav release
0.7. These are:
libavutil   51.7.0
libavcodec  53.5.0
libavformat 53.2.0
libswscale   2.0.0
libpostproc 52.0.0

Also disable the fallback to simple header check if these libraries
could not be found with pkg-config; now compiling without pkg-config
support for these always requires explicitly setting --enable-libav
and any needed compiler/linker flags. The simple check would have let
compilation proceed even if a version mismatch was detected.
2011-12-22 01:27:45 +02:00
Uoti Urpala 2e1cdcb9e6 configure, build: remove --disable-libav support
Remove support for building the player without libavcodec and
libavformat. These libraries are now always required.
2011-12-11 07:48:26 +02:00
wm4 e3f5043233 core, demux: fix --identify chapter output with ordered chapters
Information about individual chapters was printed during demuxer
opening phase, and total chapter count (ID_CHAPTERS) was printed
according to mpctx->demuxer->num_chapters. When playing a file with
ordered chapters, this meant that chapter information about every
source file was printed individually (even though only the chapters
from the first file would be used for playback) and the total chapter
count could be wrong. Remove the printing of chapter information from
the demuxer layer and print the chapter information and count actually
used for playback in core print_file_properties().

Also somewhat simplify the internal chapters API and remove possible
inconsistencies.
2011-10-25 22:09:33 +03:00
Uoti Urpala 07b7503200 demux_demuxers: fix seeking bug (--audiofile)
Demux_demuxers checked a pts value against 0 to see if it was unset,
but other code uses MP_NOPTS_VALUE for that now. As a result audio and
subtitle streams could seek to a large negative position (effectively
to 0) instead of the correct target position. This broke --audiofile;
the --initial-audio-sync code could compensate for wrong demuxer seek
up to 5 minutes from the start of the file, masking the bug, but
seeking further than that audio would seek to 0 instead.

Note that the current --audiofile implementation using the
demux_demuxers wrapper is a fundamentally unsound design and still not
expected to generally work properly even after fixing this particular
problem.
2011-10-23 03:29:42 +03:00
Uoti Urpala 3595dcc089 audio/video: delete buggy "dynamic plugin" code
Codec selection for audio and video decoding had a "dynamic plugin"
feature that tried to load a shared library for any codec that had not
been enabled at compilation (disabled by default, but could be enabled
with --enable-dynamic-plugins configure switch; for unknown reasons
some distro packages have enabled it). The implementation was buggy
and could cause normal codec selection fallback to fail if the feature
was enabled. I'm not aware of any real uses of such dynamic plugins
and the feature seems questionable anyway (there are no ABI guarantees
that would make it safe to use). Remove the buggy feature.
2011-10-20 02:16:35 +03:00
Uoti Urpala 49b2bc5947 demux_lavf: set rawvideo codec_tag based on pix_fmt
Libav stopped automatically filling missing codec_tag field for raw
codecs based on pix_fmt in libav commit bb416bd68c ("lavf: do not set
codec_tag for rawvideo"). This broke demux_lavf for raw video in
formats like YUV4MPEG, as the video format was not exported from
demux_lavf in any form (the information only existed in the pix_fmt
field of the struct AVCodecContext from libavformat, and that is not
exported). Add an explicit call to avcodec_pix_fmt_to_codec_tag() to
set the codec tag again so that selecting the correct raw decoder
based on the tag works.
2011-10-18 06:49:56 +03:00
Uoti Urpala c9e681fca3 demux_mkv: avoid hang with some broken files
Return failure to open file in one case that could lead to an infinite
loop with broken Matroska files before.
2011-09-25 18:35:09 +03:00
Uoti Urpala 5a13d47b97 demux_mf: fix option value allocated with strdup
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.
2011-09-02 08:04:52 +03:00
Uoti Urpala 506ab685d4 demuxer.h: raise pad amount to allow compiling against FFmpeg
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).
2011-08-26 06:29:36 +03:00
Uoti Urpala 2c5285c151 demux_lavf: Adding av_dup_packet() missing from recent 6e8d420a41
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).
2011-08-21 21:55:32 +03:00
Uoti Urpala c9c6b878be demux_mkv: fix failure to open some files from 0ece360eea
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.
2011-08-20 21:45:42 +03:00
Uoti Urpala 9c7c4e5b7d core, demux, vd_ffmpeg: pass side data from demux_lavf to vd_ffmpeg
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.
2011-08-20 20:25:43 +03:00
Uoti Urpala e2ca8853a6 demux_mkv: support extradata for wavpack audio tracks
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.
2011-08-20 06:06:12 +03:00
Uoti Urpala 46d90010ba demux_mkv: clean up audio codec handling somewhat 2011-08-20 05:54:27 +03:00
Uoti Urpala 01fa34d537 demux_mkv: check for valid track in video/audio switching
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.
2011-08-20 02:43:51 +03:00
Uoti Urpala f253de24af demux_mkv: remove bad mkv_free() from 0ece360eea
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.
2011-08-19 21:37:16 +03:00
Uoti Urpala 3043beffab demuxer.h: avoid including stream.h
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.
2011-08-19 21:37:16 +03:00
Uoti Urpala b2e213d889 aviheader.h: avoid including demuxer.h
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).
2011-08-19 21:37:16 +03:00
Uoti Urpala 6e8d420a41 demux: avoid a copy of demux packets with lavf, reduce padding
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).
2011-08-19 21:32:47 +03:00
Uoti Urpala ca9065b93f demux_lavf: don't interpret MPEG codec tags as generic tags
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.
2011-08-10 22:52:35 +03:00
Uoti Urpala 0ece360eea demux_mkv: skip files faster in ordered chapter file search
Ordered chapter code tries opening files to find those matching the
SegmentUID values specified in the timeline. Previously this scan did
a full initialization of the Matroska demuxer for each file, then
checked whether the UID value in the demuxer was a match. Make the
scan code instead provide a list of searched-for UIDs to the demuxer
open code, and make that do a comparison against the list as soon as
it sees the UID in the file, aborting if there is no match.

Also fix units used in "Merging timeline part" verbose message.
2011-08-04 08:38:39 +03:00
Uoti Urpala f1bb6fde32 core: audio: if audio pts is missing return MP_NOPTS_VALUE
Change written_audio_pts() and playing_audio_pts() to return
MP_NOPTS_VALUE if no reasonable pts estimate is available. Before they
returned some incorrect value typically around zero (but not
necessarily exactly that).
2011-07-30 21:05:59 +03:00
Uoti Urpala b33bb28ea3 build: fix --enable-debug, remove some "#ifdef MP_DEBUG"
Recent commit 5d5ca22a6d ("options: commandline: accept --foo=xyz
style options") left some bad code under "#ifdef MP_DEBUG" in
playtree.c, which caused a compilation failure if configured with
"--enable-debug". Fix this. Having the "#ifdef MP_DEBUG" there was
completely unnecessary; it only increased the risk for this kind of
problems for no real benefit - executing the asserts under it would
have no noticeable performance or other penalty in default builds
either. Remove several cases of such harmful "#ifdef MP_DEBUG".
2011-07-30 19:03:20 +03:00
Uoti Urpala 0958620591 bstr: rename BSTR() -> bstr()
Rename the BSTR() function to bstr(). The former caused a conflict
with some Windows OS name, and it's no longer a macro so uppercase
naming is less appropriate.
2011-07-27 08:38:12 +03:00
Uoti Urpala a4f4130819 cleanup: do libav* initialization on startup
Do the global initialization of libavcodec and libavformat
(avcodec_register_all(), av_register_all()) immediately on program
startup and remove the initialization calls from various individual
modules that use libavcodec/libavformat functionality.
2011-07-18 00:57:05 +03:00
Clément Bœsch 2174cbfa2f cleanup: silence most of the clang warnings 2011-07-09 04:23:24 +03:00
Anton Khirnov 00ec1a40f1 demux/mp_taglists: Move Bink audio tags to override list
Some versions of lavf abuse codec_tag for passing Bink version
information to the decoder, which broke detection based on codec tag
(though this has already stopped again in latest Libav). Move bink
audio codec IDs from mp_wav_tags to mp_codecid_override_tags so that
codec tags are completely ignored for them.
2011-07-06 20:27:45 +03:00
Uoti Urpala 2670ceeb81 Merge branch 'mplayer1_changes' 2011-07-06 13:07:37 +03:00
reimar 684e54587e demux_rtp.cpp: Add a hack to receive audio while probing video FPS
Otherwise newer live555 versions would just hang.
Fixes http://bugzilla.mplayerhq.hu/show_bug.cgi?id=1874

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33793 b3059339-0415-0410-9bf9-f77b7e298cf2
2011-07-06 13:01:08 +03:00
diego 4e89bae12c cleanup: demux_vqf: typo/wording fixes
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33762 b3059339-0415-0410-9bf9-f77b7e298cf2
2011-07-06 13:01:08 +03:00
reimar b327f6fcb6 demux_lavf: Do not set AVIOContext for AVFMT_NOFILE formats
Setting AVIOContext for AVFMT_NOFILE formats now triggers a warning
from libavformat (and triggered an error for a while), so add a check
to avoid setting AVIOContext when not necessary.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33695 b3059339-0415-0410-9bf9-f77b7e298cf2
2011-07-06 13:01:07 +03:00
reimar 681133d10d demux_lavf: fix code printing subtitle type
Fix printing of subtitle type, the wrong index was used to look up the
type.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33664 b3059339-0415-0410-9bf9-f77b7e298cf2
2011-07-06 13:01:07 +03:00
Uoti Urpala 6075b4d4b2 demux_lavf: add missing #include <libavutil/mathematics.h>
Not included by avutil.h any more in recent Libav versions.
2011-07-06 10:53:08 +03:00
cehoyos 55d4f6528c cosmetics: Fix typos
Patch by Mike Castle, dalgoda+mplayer gmail

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33575 b3059339-0415-0410-9bf9-f77b7e298cf2
2011-07-06 09:46:17 +03:00
ib f52b41600d demux_asf: Fix play duration calculation error
Acording to the ASF documentation, the play duration is zero
if the preroll value is greater than the play duration.

The new way of determining it (suggested by reimar) prevents
overflows as well.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33492 b3059339-0415-0410-9bf9-f77b7e298cf2
2011-07-06 07:23:26 +03:00
ib 30d81cf726 cosmetics: asf.h: Fix comment error
According to the ASF documentation,
MF_PD_ASF_FILEPROPERTIES_PREROLL (preroll) is UINT64. Fix type
mentioned in comment.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33484 b3059339-0415-0410-9bf9-f77b7e298cf2
2011-07-06 06:52:22 +03:00
Uoti Urpala 8ff5b2b889 OSD: when switching sub/audio tracks show title of new track
If the played file has per-track titles for audio and subtitles show
those on the OSD when switching tracks. This changes the OSD message
from 'Audio: (2) eng' to 'Audio: (2) eng ("Director's commentary")'.
2011-07-03 20:41:46 +03:00
Uoti Urpala c5364305be commands: change property mechanism to use talloc strings 2011-07-03 20:04:21 +03:00
Uoti Urpala 774bb252aa cosmetics: reformat demux_lavf.c, m_option.[ch] and m_property.c 2011-07-03 18:39:26 +03:00
Uoti Urpala 1a8384401b demux: use talloc for sh_* structs and "lang" field 2011-07-03 15:01:24 +03:00
Uoti Urpala eb61456065 cleanup: reindent stheader.h
Also improve some comments and change two fields from int to bool.
2011-07-03 13:26:39 +03:00