Commit Graph

34716 Commits

Author SHA1 Message Date
wm4 6ef06aa145 vo_opengl: split into multiple files, convert to new option API
gl_video.c contains all rendering code, gl_lcms.c the .icc loader and
creation of 3D LUT (and all LittleCMS specific code). vo_opengl.c is
reduced to interfacing between the various parts.
2013-03-28 21:46:17 +01:00
wm4 16e951c2cd gl_common: split into platform specific files
Do this instead of stuffing all x11/cocoa/win32/wayland specific code
into gl_common.c. The cocoa specific parts could probably go directly
into cocoa_common.m, possibly same with wayland.

Also redo how the list of backends is managed. Get rid of the GLTYPE_
constants. Instead of having a big switch() on GLTYPE_, each backend
entry has a function pointer to setup the MPGLContext callback (e.g.
mpgl_set_backend_x11()).
2013-03-28 21:46:17 +01:00
wm4 3374a43998 core: always pass data via packet fields to video decoders
Makes the code a bit simpler to follow, at least in the "modern"
decoding path (update_video_nocorrect_pts() is used with old demuxers,
which don't return proper packets and need further parsing, so this code
looks less simple now).
2013-03-28 21:46:17 +01:00
wm4 ac1c5e6e18 demux_mkv: improve robustness against broken files
Fixes test7.mkv from the Matroska test file collection, as well as some
real broken files I've found in the wild. (Unfortunately, true recovery
requires resetting the decoders and playback state with a manual seek,
but it's still better than just exiting.)

If there are broken EBML elements, try harder to skip them correctly.
Do this by searching for the next cluster element. The cluster element
intentionally has a long ID, so it's a suitable element for
resynchronizing (mkvmerge does something similar).

We know that data is corrupt if the ID or length fields of an element
are malformed. Additionally, if skipping an unknown element goes past
the end of the file, we assume it's corrupt and undo the seek. Do this
because it often happens that corrupt data is interpreted as correct
EBML elements. Since these elements will have a ridiculous values in
their length fields due to the large value range that is possible
(0-2^56-2), they will go past the end of the file. So instead of
skipping them (which would result in playback termination), try to
find the next cluster instead. (We still skip unknown elements that
are within the file, as this is needed for correct operation. Also, we
first execute the seek, because we don't really know where the file
ends. Doing it this way is better for unseekable streams too, because
it will still work in the non-error case.)

This is done as special case in the packet reading function only. On
the other hand, that's the only part of the file that's read after
initialization is done.
2013-03-28 21:45:16 +01:00
wm4 3533ee3ae4 demux_mkv: fix skipping broken header elements
Fixes test4.mkv from the Matroska test file collection.

demux_mkv_open() contains a loop that reads header elements. It starts
by reading the EBML element ID with ebml_read_id(). If there is broken
data in the header, ebml_read_id() might return EBML_ID_INVALID.
However, that is not handled specially, and the code for handling
unknown tags is invoked. This reads the EBML element length in order to
skip data, which, if the EBML ID is broken, is entirely random. This
caused a seek beyond the end of the file, making the demuxer fail.

So don't skip any data if the EBML ID was invalid, and simply try to
read the next element. ebml_read_id() reads at least one byte, so the
parsing loop won't get stuck.

All in all this is rather questionable, but since this affects error
situations only, makes behavior a bit more robust (no random seeks), and
actually fixes at least one sample, it's ok.

libavformat's demuxer handled this.
2013-03-28 00:00:39 +01:00
wm4 546ae23a0c demux_mkv: set correct aspect ratio even if DisplayHeight is unset
Fixes the file test2.mkv from the official Matroska test file
collection.

libavformat does the same thing.
2013-03-28 00:00:04 +01:00
wm4 2182c3ffd5 m_option: pretty-print floats with 3 pre-decimal digits instead of 2
There were complaints that ${fps} was printed as e.g. "23.98" instead of
"23.976". Since there's no way to format floats exactly _and_ in a user-
friendly way, just change the default precision for printing floats.
2013-03-26 01:29:54 +01:00
wm4 d48c855669 mpv_identify: add --quiet to mpv command line
Prevents the status line from being printed. Otherwise, the status line
is always printed due to --frames=1, and it's visible on the terminal
because it's printed to stderr.
2013-03-26 01:29:53 +01:00
wm4 90118a3810 mpv_identify: allow specifying mpv binary via MPV
Useful for testing.
2013-03-26 01:29:53 +01:00
wm4 790df511c4 core: output --playing-msg message only after at least one frame is shown
This way it's possible to retrieve correct information about video, like
actual width/height, which in general are available only after at least
one frame has been sent to the video output, such as dwidth/dheight.

mpv_identify.sh becomes a bit slower, because we let it decode enough
audio and video to fill the audio buffers and to send one frame to the
video output. Also, --playing-msg isn't shown anymore with --frames=0
(could be fixed by special-casing it, should this break any use cases).

Note that in some corner cases, like when the demuxer for some reason
returns lots of audio packets but no video packets at the start, but
video actually starts later, the --playing-msg will still be output
before video starts.
2013-03-26 01:29:53 +01:00
wm4 54e8e0a502 mplayer: make --frames=1 work for audio
This has the same (useless) definition as frame stepping in audio-only
mode: one frame means one playloop iteration. (It's relatively useless,
because one playloop iteration has a random duration. But it makes
--frames=1 work, which is useful again.)
2013-03-26 01:29:53 +01:00
wm4 140636c407 mplayer: cosmetics: make some code more readable 2013-03-26 01:29:53 +01:00
wm4 d080d1d39a command: export VO video width/height as properties
Add new properties "dwidth" and "dheight", which contain the video
size as known by the VO (not necessarily what the VO makes out of them,
i.e. without window scaling and panscan).
2013-03-26 01:29:53 +01:00
wm4 05e918be02 input: make input command deprecation warnings visible
Some time ago, all old special-cased commands (like "volume 1" to change
volume by one) have been removed. These commands are still emulated
using simple text replacement. This emulation is done to not break
everyone's input.conf, especially because the input.conf provided by
standard mplayer* still uses the old commands.

Every use of a deprecated command prints a replacement warning, which
was visible only with -v. Make these warnings visible by default.

There's actually not much reason to do this, but since commands like
"volume 5 1" don't work anymore, it's better to be verbose about this.

Also simplify the replacement for "vo_fullscreen".
2013-03-26 01:29:38 +01:00
wm4 1d530f0e31 mp_msg: don't change text color for normal output
Normal text was set to gray foreground color. This didn't work for
terminals with white background.

Instead of setting a color for normal text, reset the color attributes.
This way, only errors and warnings are formatted differently.

Also change the default color for MSGL_HINT from bold white to yellow.
2013-03-26 01:17:38 +01:00
Stefano Pigozzi 840c98d190 configure: fix OpenGL autodetection on OS X
Was broken from 746b5e6 since the OpenGL headers are under OpenGL/ and not GL/
on OS X. Thanks to @Kovensky for the initial patch.
2013-03-24 20:00:22 +01:00
Kovensky 4be6ff5ee3 w32_common: Cygwin64 fixes
Good news: MPV worked fine even without the fixes, but pointer size
mismatch warnings aren't the nicest things to leave lying around.

Fix macro that assumed HWND is uint32_t-sized.

Win64 is also a special butterfly and is an LLP64 platform on amd64
CPUs, while all the other amd64 platforms are LP64. Cygwin decided to go
with the other platforms, and thus sizeof(long) != sizeof(int), and in
cygwin's windows headers LONG is int-sized. Fix an mp_msg that assumed
LONG is long.
2013-03-23 21:04:59 +01:00
Kovensky 746b5e6027 configure: check for presence of glext.h
vo_opengl depends on glext.h to build. Also link to Khronos' copy, which
should work on all compilers and is kept up-to-date with newer
extensions.
2013-03-23 21:04:39 +01:00
Kovensky 16b15885ff ao_dsound: add missing include
libavutil/common.h is needed for FF_ARRAY_ELEMS.
2013-03-23 21:04:27 +01:00
Alexander Preisinger 1fc58386d1 wayland: fully support cursor autohide options
I missed the special cases in the previous commits.
2013-03-23 12:58:34 +01:00
wm4 d22a3fdb09 sub: print messages before and after font setup
Helps on Windows, where fontconfig may take some time to finish.

Print it with -v only, because that message would be annoying anywhere
else.
2013-03-20 19:55:11 +01:00
Rudolf Polzer 5d5c5e31e1 encoding-examples-profiles: fix N900 profile
In some cases (when using tune=animation as an additional option), the
N900 profile caused use of 6 reference frames, where Level 3.0 only
allows 5 reference frames. This prevented playback on the Nokia N900.
This has been fixed by always specifying refs=5.
2013-03-20 16:16:16 +01:00
wm4 e4be357bce w32_common: reset internal display size to the window size
vo->dwidth/dheight are overwritten by vo.c at this point (which is not
nice, but it's how things are currently).
2013-03-19 23:36:43 +01:00
wm4 594ad5acc2 video: deal with 0x0 window size
If this happens, don't set a NaN aspect ratio.
2013-03-19 23:34:50 +01:00
wm4 ef7975e91b input: fix crash due to dangling pointer
Wrong API usage, has been in the code since 2011. Rarely triggered (if
at all in the current setup).
2013-03-19 13:10:19 +01:00
wm4 9a731a9b0d demux: fix regressions by restricting cover art hack further
The code modified by this commit is supposed to prevent demuxing the
whole file when cover art is present. (The problem with cover art is
that the ffmpeg libavformat API doesn't signal video EOF correctly - so
we try to read more packets to find the next video frame, which results
in demuxing and queuing the whole audio stream.)

This caused regressions for files with extremely high audio offset (see
github issue #46). MY conclusion is that this cover art crap doesn't
work, and this is just another case of completely insane ffmpeg/libav
API.

Disable the hack in all cases, unless a cover art video track is
selected. Maybe I'll handle cover art directly in the frontend later, so
that we don't have to rely on whatever libavformat does.

Unfortunately, this also makes behavior with equally insane mp4 files
with sparse video tracks worse, but this issue takes priority.
2013-03-19 02:27:47 +01:00
wm4 be7e04f719 demux_mf: fix crashes when '*' matches directories
Doing 'mpv mf://*' in a file with directories would crash, because even
though directories are skipped, the corresponding file entry is just
left at NULL, leading to a segfault on access. So explicitly skip NULL
entries.
2013-03-19 01:54:45 +01:00
wm4 b242aa366b stream: silence clang empty statement warnings
clang printed warnings like:

stream/stream.c:692:65: warning: if statement has empty body [-Wempty-body]
            GET_UTF16(c, src < end - 1 ? get_le16_inc(&src) : 0,;

This macro expands to "if(cond) ;". Replace it with an empty statement
that doesn't lead to a clang warning.
2013-03-19 01:27:48 +01:00
wm4 7ba6675847 input/ar: remove unused variable 2013-03-19 00:59:55 +01:00
Rudolf Polzer 3091394edc mp_msg: print MSGL_STATUS to stderr if stderr is redirected
Of course, status output is still hidden when stderr is a tty which is
not the foreground tty.
2013-03-18 20:42:01 +01:00
Rudolf Polzer b1ae33a355 mp_msg: fix status output disappearing when redirecting INPUT.
Instead, we now check stderr's destination against the foreground tty
for deciding whether we want status output or not.
2013-03-18 20:33:29 +01:00
Rudolf Polzer 3ef58d85ba encoding-example-profiles: for Nokia N900, avoid upscaling
This yields generally smaller files, by avoiding upscaling at all times.
This method may or may not be useful for iOS, needs testing there.

Note: this uses three instances of vf_scale:

1. Scale to target dimensions, ONLY if both are <= original video
   dimensions.
2. Failing that, scale to width*<calculated height by display aspect>,
   ONLY if <calculated height by display aspect> <= original video
   height.
3. Failing that, scale to <calculated width by display aspect>*height.
   When the test before failed, we KNOW that <calculated width by
   display aspect> <= original video width.

So basically, only one of the three scalers should ever be active, as
the last two scalers only can ever have an effect if the aspect ratio
mismatches the video.

As for danger of roundoff errors:

If scaler 1 succeeded, we have won. Scalers 2 and 3 will never do
anything, because display resolution == video resolution. Here it is
crucial that no rounding of video size to display size takes place; in
other words, the target display size already MUST be even, which it is
because we pass 2 to the rounding parameter of the dsize filter.

Scaler 2 and 3 are obviously mutually exclusive, as they depend on
opposite aspect ratio conditions.

We later should put this functionality directly into vf_scale...
2013-03-18 13:27:52 +01:00
wm4 d17e0977ea options: fix --wid
A recent change accidentally set the flags options to -1 (probably
confusing it with the defasult value?), which mistakenly set all flags
and rejected all option values (except 0).
2013-03-18 03:13:28 +01:00
wm4 ea03cc6712 x11_common: remove assumption that video is always centered
The vo_x11_clearwindow_part() function assumed that the video is always
centered. Replace it with a new vo_x11_clear_background() function
instead, which essentially does the same as the old function. It takes
the video rectangle instead of just the video size, and doesn't have to
make the assumption that the video rectangle is centered.

Also make vo_x11 use it (seems advantageous).
2013-03-17 23:01:33 +01:00
wm4 79d35b8f01 video: enable panscan calculations even in windowed mode
This was probably enabled to guarantee that panscan is always reset in
windowed mode. However, the window size should be exactly the video size
in windowed mode, unless in cases where the user forcibly changed the
window size (e.g. --geometry). In the former case, panscan will have no
influence at all, and in the latter case we want it to have influence.
2013-03-17 22:12:16 +01:00
wm4 f86deec58b video: apply --no-keepaspect even on fullscreen
If that's what the user asked for, there's no reason to introduce
special cases to ignore it on fullscreen.

The old behavior is perhaps accidentally due to the fact that aspect
calculations used to be disabled in windowed mode, rather than a
deliberate decision.
2013-03-17 22:07:13 +01:00
wm4 b049ffb330 video: remove rounding of display size to multiples of 2
The code that is changed is responsible for scaling the video size to
display size, so that the resulting video rectangle is letter-boxed
inside the display window. This is before panscan calculations, which
can actually enlarge the video and make it larger than the display size
again. (src_dst_split_scaling() in vo.c takes cares of clipping the
video size to window size.)

I'm not sure why this rounding is done, as using panscan controls can
introduce odd sizes again. The rounding has been part of the code since
the initial commit. On the other hand, this rounding can slightly
influence the aspect ratio of the displayed image to the worse. It
forces the image to be scaled by an additional pixel, without actually
correcting the display size into the other direction.

Although video sizes are usually at least aligned on 2 (and often more),
odd sizes can still happen when playing e.g. anamorphic DVDs.

Remove the additional rounding.

(Note that we still round the _source_ image position and size when the
displayed image is larger than the screen, e.g. when panscan is used.
This is needed by some VOs so that the image source rectangle starts on
full chroma pixels. Maybe this rounding should be moved to the
respective VOs, which includes at least vo_direct3d.)
2013-03-17 22:07:13 +01:00
wm4 1ae1939742 video: remove aspect.h includes from files which don't need it 2013-03-17 22:07:13 +01:00
wm4 4b87cb39a3 video: simplify aspect calculation stuff
Remove lots of weird logic and dead code.

The only difference is that when specifying a monitor aspect ratio, it
will always upscale and never downscale.
2013-03-17 22:07:13 +01:00
wm4 59960baa7f vo_xv: minor simplifications
The draw_osd change is a bit tricky: I guess originally, there was some
intention not to second-guess the generic aspect code, but the result is
the same and the code is more confusing.
2013-03-17 19:07:30 +01:00
wm4 36f5d800d5 vo_x11: accept all swscale formats
There's no reason why there should be a separate vf_scale stage.
2013-03-17 19:07:29 +01:00
wm4 5b6da6e286 vo_corevideo: use generic aspect ratio code
The rescaling is rather silly. vo_get_src_dst_rects() doesn't return an
uncropped image, so the texture coordinates have to be recalculated,
which looks more complicated, but is actually what the other OpenGL VOs
also do.

Tested and fixed by Stefano Pigozzi.
2013-03-17 19:07:29 +01:00
wm4 b424dacbe5 vo_opengl_old: use generic aspect ratio code
Make sure scaled_osd still works. Although this is a completely
worthless feature for a deprecated VO.
2013-03-17 18:51:32 +01:00
wm4 b1b982941d vo_x11: use generic aspect ratio code, refactor
Instead of manually calculating aspect ratio etc., use
vo_get_src_dst_rects(). This has the advantage that we can drop some
special cases in aspect.c later.

Simplify the code, and move resizing the X images from draw_image() to a
new resize() function.

Do some other simplifications. The gXErrorFlag check was actually dead
code, even in mplayer-svn. Special-casing on WinID is not needed
anymore (we created an embedded window, and its size is updated by
x11_common.c).
2013-03-17 18:46:03 +01:00
Stefano Pigozzi ad000fb916 cocoa_common: fix regression when changing videos in fullscreen
I introuced this regression in 8fc0b618d5. The backend would go into
incosistent state caused by calling `vo_cocoa_fullscreen` where it wasn't
needed.

Fixes #44
2013-03-15 22:48:57 +01:00
wm4 a9c9999973 video: use new method to get QP table
This only matters for those who want to use vf_pp. The old API is marked
as deprecated, and doesn't work on Libav. It was broken on FFmpeg, but
has recently started working again - the fields in question were not un-
deprecated though. Instead you're supposed to use a new API, which does
exactly the same thing (what...?).

Also don't pass the QP table with mp_image_copy_attributes() - it
probably does more harm than it's useful.

By the way, with -vf=dlopen=TOOLS/vf_dlopen/showqscale.so, it appears
the table as output by recent FFmpeg is offset by 1 macroblock in X
direction and 2 macroblocks in Y direction, which most likely will
interfere with normal vf_pp operation. However, this is not my problem.

The only real reason for this commit is that we can finally get rid of
all libav* related deprecation warnings. (Though they are constantly
deprecating APIs, so this will not last long.)
2013-03-15 14:21:42 +01:00
wm4 e837d8ddac demux_mkv: support ALAC
Test sample was produced with ffmpeg. Extradata handling closely follows
libavformat/matroskadec.c.
2013-03-15 12:17:39 +01:00
wm4 df4b31c869 input: ignore normal mouse click by default
Apparently this annoyed some users.
2013-03-14 00:10:15 +01:00
Stephen Hutchinson 1877d7933e demux_mkv: Support playing Opus streams in Matroska
FFmpeg recently changed how it writes Opus-in-Matroska to match
the A_OPUS/EXPERIMENTAL name that mkvmerge uses, with the caveat
that things will change and compatibility with old files can get
worked out when the spec is finalized.

This adds both A_OPUS and A_OPUS/EXPERIMENTAL so that *hopefully*
it can play both the newer files that use A_OPUS/EXPERIMENTAL, and
older ones muxed by FFmpeg that were simply A_OPUS, since this is
also what FFmpeg seems to be doing to handle the situation.
2013-03-14 00:07:28 +01:00
wm4 21e4f1680c configure: bump minimum FFmpeg/Libav versions, remove compat hacks
We consider FFmpeg 1.x and Libav 0.9.x releases compatible. Support
for FFmpeg 0.9.x and Libav 0.8.x is considered infeasible and has been
dropped in the previous commits. The bits that break compatibility are
mainly the CodecID renaming (trivial, but would require nasty hacks
everywhere), the avcodec_encode_video2() function (missing in older
releases, mandatory in newer ones), and the resampler changes (older
releases miss lib{av,sw}resample, newer versions removed the
libavcodec resampler).

Remove some other compatibility bits that were needed to for releases
for which we drop support.

The comment about Libav 0.9 in compat/libav.h is incorrect and should
have been 0.8 (the symbol is present in Libav 0.9).
2013-03-13 23:52:04 +01:00