Commit Graph

76 Commits

Author SHA1 Message Date
Uoti Urpala 43b1de1dd7 core: move most mpcommon.c contents to mplayer.c
The contents of mpcommon.c were quite arbitrary; the most common
reason to place some functions in this file had been "MEncoder happens
to need similar code as MPlayer and we want to share some parts, but
we have no clue whatsoever how to organize things in a sensible way,
so we'll just dump those parts we want to share in mpcommon.c". As a
result of containing an essentially random subset of top-level player
functionality the mpcommon.h header required access to central structs
and was unsuitable for inclusion in lower-level code, but was
nonetheless included there for the mplayer_version symbol.

Move almost all contents from mpcommon.c to mplayer.c. mplayer.c is
already big and should perhaps be split further, but keeping a few
random functions in mpcommon.c would not be an improvement.
2011-01-15 18:45:43 +02:00
Uoti Urpala a1692437d0 core: move global "subdata" and "vo_sub_last" to mpctx 2011-01-11 17:55:05 +02:00
Uoti Urpala 0afb326035 Merge branch 'hr-seek'
* hr-seek:
  input: add default keybindings Shift+[arrow] for small exact seeks
  input: support bindings with modifier keys for X input
  core: audio: make ogg missing audio timing workaround more complex
  core: add support for precise non-keyframe-limited seeks
  core: add struct for queued seek info
  commands: add generic option -> property wrapper
  options: add "choice" option type, use for -pts-association-mode
  core: remove looping in update_video(), modify command handling a bit
  core: seek: use accurate seek mode with audio-only files
  core: avoid using sh_video->pts as "current pts"
  libvo: register X11 connection fd in input event system
  core: timing: add special handling of long frame intervals
  core: move central play loop to a separate function

Conflicts:
	DOCS/tech/slave.txt
2010-12-20 19:17:43 +02:00
Uoti Urpala f0649f13d6 core: add support for precise non-keyframe-limited seeks
Add support for seeking to an arbitrary non-keyframe position by
decoding video starting from the previous keyframe. Whether to use
this functionality when seeking is controlled by the new option
-hr-seek and a new third argument to the "seek" command. The default
is to use it for absolute seeks (like chapter seeks) but not for
relative ones. Because there's currently no support for cutting
encoded audio some desync is expected if encoded audio passthrough is
used. Currently precise seeks always go to the first frame with
timestamp equal to or greater than the target position; there's no
support for "matching or earlier" backwards seeks at frame level.
2010-12-20 19:02:16 +02:00
Uoti Urpala 23f598e0ee core: add struct for queued seek info
To prepare for the addition of exact seek support, add a struct for
queued seek state and a helper function to update its state. It would
have been cumbersome to update additional state (showing whether the
seek is forced to be exact or non-exact) manually at every point that
handles seeks.
2010-12-20 19:02:14 +02:00
Uoti Urpala 00c2bafb0a core: remove looping in update_video(), modify command handling a bit
Let higher-level code call update_video() again instead of looping
inside it until there's a frame ready to show. Change the conditions
for running user commands somewhat. Overall effect shouldn't be that
big. Now other commands can be executed after a seek before a video
frame is decoded; in this case the seek target time may be used as the
"current position".
2010-12-16 20:04:34 +02:00
reimar 21df1d5ec5 core: avoid using build_afilter_chain() directly
build_afilter_chain is not safe to use directly, thus make it
static and instead use reinit_audio_chain which should have
better error handling.
Fixes a crash with -af hrtf and changing speed, audio will
still stop playing though.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32648 b3059339-0415-0410-9bf9-f77b7e298cf2
2010-12-16 04:47:15 +02:00
Uoti Urpala ff706ee86d core: avoid using sh_video->pts as "current pts"
Add a new field "video_pts" to mpctx. It records the time of the last
frame flipped visible on VO. Change various code which used
sh_video->pts to use either the new field or get_current_time(mpctx).
2010-12-14 22:33:12 +02:00
Uoti Urpala a4ce95de81 core: do initial A-V sync by modifying audio stream
Add code to enforce matching pts with video when (re)starting the
audio stream, by either cutting away the first samples or inserting
silence at the beginning. New option -noinitial-audio-sync can be used
to disable this and return to old behavior.
2010-11-13 19:46:02 +02:00
Uoti Urpala 3283ba0ccb core: rename update_video_immediately->restart_playback 2010-11-11 12:29:14 +02:00
Uoti Urpala 9a663ffec6 core: move video pos/length query functions from demux to core
Move functions to query current playback position, percentage position
and total video length from from the demuxer layer to top level. The
functions need access to playback state that doesn't belong on the
demuxing level. Make the new functions more capable and simplify some
code that can now rely on them. This fixes some errors in displayed in
OSD and slave mode information when using timeline (ordered chapters).
2010-11-08 18:05:12 +02:00
reimar 1663d97a11 subs: Change global subtitle numbering scheme
Change numbering so that demuxers can "asynchronously" add subtitles
during playback.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31678 b3059339-0415-0410-9bf9-f77b7e298cf2

Fix calculation of global_sub_size.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31711 b3059339-0415-0410-9bf9-f77b7e298cf2

Update global_sub_pos if we auto-selected a subtitle.
This avoid strange behaviour with subtitle selection in that
case, because the subtitle selection code thinks no subtitle
was displayed while we actually did display one.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31863 b3059339-0415-0410-9bf9-f77b7e298cf2

Move function to avoid a forward declaration.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31864 b3059339-0415-0410-9bf9-f77b7e298cf2

Fix subtitle selection: make selecting -sid 0 work again by replacing the
M_PROPERTY_STEP_UP hack by M_PROPERTY_SET and set the global sub pos also
when we do not yet have a subtitle stream but do know the number of subs
from out-of-band as e.g. for DVD.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31882 b3059339-0415-0410-9bf9-f77b7e298cf2

100l, re-add vobsub_get_id_by_index call accidentally removed in
r31678.
Patch by ubitux [ubitux gmail com].

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31985 b3059339-0415-0410-9bf9-f77b7e298cf2
2010-11-02 04:14:43 +02:00
Uoti Urpala d2e25a90c4 core: track current chapter for relative chapter seeks
Due to inexact seeks, chapter seek commands may result in a playback
position that's inside the previous chapter. This causes problems when
the user does repeated next-chapter/previous-chapter seeks, because
the code will use the wrong base for calculating 'next' or
'previous'. Improve the behavior by adding a heuristic that keeps
track of what chapter the user last wanted to seek to and adjusts the
"current chapter" value based on that.
2010-04-25 23:29:46 +03:00
Uoti Urpala c31aa7b953 Merge svn change r30560 2010-03-09 23:18:19 +02:00
Uoti Urpala 12d3caebc7 Merge svn changes up to r30475 2010-03-09 19:18:43 +02:00
diego 8a67379319 Rename exit_reason_t enum to exit_reason and do not typedef it.
The _t namespace is reserved for POSIX; the typedef is pointless obfuscation.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30560 b3059339-0415-0410-9bf9-f77b7e298cf2
2010-02-14 11:02:05 +00:00
diego 11b55ec7a8 Fix exit_player() usage throughout the codebase.
exit_player() was declared with differing parameter types in mplayer.c and
mplayer.h. Make the declaration in the .h file match the one in the .c file
and adjust all usages of exit_player() throughout the codebase. Also move
the exit_player() declaration into mp_core.h next to exit_player_with_rc().


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30558 b3059339-0415-0410-9bf9-f77b7e298cf2
2010-02-14 10:53:20 +00:00
diego 99c1bbca2a Add license header to all top-level files missing them.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30471 b3059339-0415-0410-9bf9-f77b7e298cf2
2010-01-30 23:24:23 +00:00
reimar 5e1b88a019 At startup and while seeking avoid to introduce pointless sleeps and possibly
desync due to codec delay.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30218 b3059339-0415-0410-9bf9-f77b7e298cf2
2010-01-04 21:38:45 +00:00
reimar e57a8e1040 Also reset time_frame and next_frame_time on reset, it makes no sense to
process the sleep before playing the frame seeked to and can be annoying
when the user tries to escape a series of "stuck" frames with a huge duration.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30217 b3059339-0415-0410-9bf9-f77b7e298cf2
2010-01-04 21:27:08 +00:00
Uoti Urpala 350fc4f5a2 core/VO: Allow VO drivers to add/modify frames
Add interfaces to allow VO drivers to add or remove frames from the
video stream and to alter timestamps. Currently this functionality
only works with in correct-pts mode. Use the new functionality in
vo_vdpau to properly support frame-adding deinterlace modes.

Frames added by the VDPAU deinterlacing code are now properly timed.
Before every second frame was always shown immediately (probably next
monitor refresh) after the previous one, even if you were watching
things in slow motion, and framestepping didn't stop at them at all.
When seeking the deinterlace algorithm is no longer fed a mix of
frames from old and new positions.

As a side effect of the changes a problem with resize events was also
fixed. Resizing calls video_to_output_surface() to render the frame at
the new resolution, but before this function also changed the list of
history frames, so resizing could give an image different from the
original one, and also corrupt next frames due to them seeing the
wrong history. Now the function has no such side effects. There are
more resize-related problems though that will be fixed in a later
commit.

The deint_mpi[] list of reserved frames is increased from 2 to 3
entries for reasons related to the above. Having 2 entries is enough
when you initially get a new frame in draw_image() because then you'll
have those two entries plus the new one for a total of 3 (the code
relied on the oldest mpi implicitly staying reserved for the duration
of the call even after usage count was decreased). However if you want
to be able to reproduce the rendering outside draw_image(), relying on
the explicitly reserved list only, then it needs to store 3 entries.
2009-09-18 17:12:53 +03:00
Uoti Urpala c73217c07a Change libass type names to match upstream renames 2009-07-29 01:11:33 +03:00
Anton Khirnov 87366694d8 Remove the internal GUI
The GUI is badly designed and too closely coupled to the internal
details of other code. The GUI code is in bad shape and unmaintained
for years. There is no indication that anyone would maintain it in the
future either. Even if someone did volunteer to implement a better
integrated GUI having the current code in the tree probably wouldn't
help much. So get rid of it.
2009-07-07 21:49:42 +03:00
Uoti Urpala 0eb321bf2c Remove trailing whitespace from most files 2009-07-07 02:34:35 +03:00
Uoti Urpala 2d91b19956 Support chapter seeking with ordered chapters 2009-04-02 06:51:26 +03:00
Uoti Urpala 58497380e5 Initial ordered chapters support
Add basic support for Matroska ordered chapters. The switching between
segments is implemented as a general edit timeline that could also be
used for other purposes.

Some things still need improvement. In particular the current code
does not try to do any proper mapping between audio/video/subtitle
streams of different files and there should be options for better
control of how MPlayer searches other files for the required content.
2009-04-02 06:51:25 +03:00
Uoti Urpala 0f590fce19 core: Clean up OSD seek info logic
Clean up the code and make the behavior more consistent. Before
bits of the OSD information were triggered in different places, and
various property commands that affect playback position only showed
the seek bar while the main seek command also triggered showing the
percentage in OSD text. Now only the seek and chapter commands trigger
all information and others nothing (which is consistent with most
property behavior).
2009-03-31 19:15:08 +03:00
Uoti Urpala 321c93ee99 core: Rewrite some of the A/V sync related code
Notable functionality changes:
* Timing change between any two frames is now accurately limited to
  1/10 of their nominal distance. Previous code did not always use the
  correct duration.
* The status line now keeps showing the same A-V sync value from one
  video frame change to the next. Previously it kept recalculating
  the value using a new audio position but the same video position
  when the status line was updated between video frames. This
  incorrectly showed the video losing sync with audio.
* The status line now displays actual measured A-V difference in
  autosync mode too. The previous code displayed values that
  completely ignored real timing in autosync mode, showing 0 A-V
  difference even when video was significantly behind audio due to
  inadequate decoding speed. The new behavior can make the shown A-V
  values appear more unstable if the audio out has unreliable delay
  measurements (the most likely reason to use autosync), but this is a
  display change rather than a timing quality change.
* Autosync mode now tries to adjust timing by the amount of time
  vo_flip() calls take, so the calls start earlier and finish at the
  time the frame should be shown. Previously non-autosync mode
  adjusted for this but autosync did not.
* The warning about the system being too slow to decode the video in
  realtime is now displayed in autosync mode too.
2009-01-14 02:06:13 +02:00
Uoti Urpala 02efad79a2 Update OSD while paused
When OSD contents change while paused, try to change the OSD drawn in
the currently visible frame. If such OSD updates are not supported
then advance by one frame and draw the OSD normally. Add some support
for OSD redrawing to vo xv.

The new xv code makes a copy of the original frame contents before
drawing the OSD if MPlayer is already paused when the frame is drawn.
If such a copy of the current frame exists then the frame contents can
be restored and a different OSD drawn on top of the same frame.
2008-12-09 04:31:07 +02:00
Uoti Urpala 77c709ad31 Start pause handling changes
Add separate pause_player() / unpause_player functions(), move some
pausing-related state into explicit variables and make commands while
paused not unpause. Not everything works properly while paused yet (no
screen updates etc).
2008-12-09 04:31:07 +02:00
Uoti Urpala 8c144171bb Merge svn changes up to r28087
Conflicts:
	command.c
	libao2/ao_ivtv.c
	libao2/ao_v4l2.c
	libmpcodecs/dec_video.h
	libvo/aspect.h
	libvo/sub.c
	libvo/sub.h
	libvo/vo_directx.c
	libvo/vo_macosx.m
	libvo/vo_quartz.c
	mp_core.h
	mplayer.c
	mplayer.h
	osdep/getch2.h
	osdep/timer.h
2008-12-04 01:55:52 +02:00
reimar f6b9f42516 Print ID_EXIT and exit reason message in identify mode when exiting.
Patch by rvm [rvm3000 ya com]


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28066 b3059339-0415-0410-9bf9-f77b7e298cf2
2008-12-02 19:53:41 +00:00
Uoti Urpala 8ea7eb77fc core: Clean up move-to-next-file logic
The mpctx->eof field was used to also store other reasons to stop
playing the current file besides EOF, and the code didn't properly
distinguish those from EOF. Rename the field to "stop_play" and clean
up some of the code accessing it. Properly separating EOF from other
reasons allows handling file switching better.

Before this commit buffered audio was always drained before moving to
the next file (the only exception when it was NOT drained when
stopping a file was when quitting the player completely). This added
an extra delay when manually moving to the next file as you had to
wait for the currently buffered audio to finish playing before the
next file would start. After this commit audio is only drained if the
file reaches EOF normally; otherwise audio is cut and the next file
starts immediately.
2008-08-13 08:06:26 +03:00
diego 02135001b4 Change a bunch of video/audio-output-specific preprocessor directives from
a HAVE_ prefix to a CONFIG_ prefix.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27402 b3059339-0415-0410-9bf9-f77b7e298cf2
2008-08-03 15:21:40 +00:00
Uoti Urpala 04f3909a72 Merge svn changes up to r27374
Conflicts:

	cfg-common-opts.h
	cfg-mplayer.h
	command.c
	configure
	libmpcodecs/dec_video.c
	libmpcodecs/vd.c
	libmpcodecs/vf_vo.c
	libmpdemux/demuxer.h
	libmpdemux/stheader.h
	mp_core.h
	mplayer.c
	stream/stream_radio.c
2008-07-30 16:39:24 +03:00
diego 4b141479da Start unifying names of internal preprocessor directives.
Replace all USE_ prefixes by CONFIG_ prefixes to indicate
options which are configurable.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27373 b3059339-0415-0410-9bf9-f77b7e298cf2
2008-07-30 12:01:30 +00:00
Uoti Urpala a232f564d3 Create a context struct for OSD state
This commit creates the struct and passes it to some functions that
needs to access OSD state but does not yet move much data from globals
to it.

vf_expand accesses the OSD state for rendering purposes outside of the
normal OSD draw time. The way this currently works is suboptimal, but
I did not attempt to clean it up now. To keep things working the same
way vf_expand needs to know the address of the state object to be able
to access the data even in the functions that should normally not need
it. For that purpose this commit adds a VFCTRL to tell vf_expand the
address of the object.
2008-06-24 01:53:58 +03:00
Uoti Urpala d5c868325c Merge svn changes up to r26979
Most of the conflicts are trivial.

Conflicts:

	Makefile
	cfg-mplayer.h
	input/input.c
	libmenu/vf_menu.c
	libmpcodecs/dec_video.c
	libmpcodecs/vf_expand.c
	libmpcodecs/vf_vo.c
	libmpdemux/demux_mkv.c
	libmpdemux/demuxer.c
	libmpdemux/demuxer.h
	libvo/vo_directfb2.c
	libvo/vo_gl.c
	libvo/vo_winvidix.c
	libvo/vo_xv.c
	libvo/vo_xvidix.c
	libvo/vo_xvmc.c
	libvo/x11_common.c
	mplayer.c
	osdep/timer-linux.c
	stream/cache2.c
2008-06-04 08:10:48 +03:00
ben bc212e3500 Add a slave command to stop stream playback.
Mostly useful when used with -idle mode.
Patch by Mathieu Schroeter ( mathieu dot schroeter at gamesover dot ch )



git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26909 b3059339-0415-0410-9bf9-f77b7e298cf2
2008-05-27 18:39:57 +00:00
Uoti Urpala 66db9ec7d6 Remove INITIALIZED_INPUT from mpctx->initialized_flags
The input functions are never uninited except at exit. Move the uninit
to player exit function and remove the flag.
2008-04-30 13:24:56 +03:00
Uoti Urpala 9e9932d4d7 Create a context for input.c state
Start moving static variables to a context struct. Only autorepeat
state is moved to the struct in this commit.

mp_input_check_interrupt now requires the context variable. Change
stream functions to pass it. It's still stored in a static variable in
stream/.
2008-04-30 13:24:54 +03:00
Uoti Urpala 77ec83e351 Add a context for mp_fifo
Store data in an allocated context and take it as an argument instead
of using static variables.
2008-04-29 15:36:51 +03:00
Uoti Urpala eaf7857b7f timers: Remove GetRelativeTime()
Move the code calculating time delta since last query out of the
platform-specific drivers and into mplayer.c. The platform-specific
drivers now return absolute values only.

The way the code in timer-darwin.c uses doubles in wrapping arithmetic
looks questionable and this change might make problems in it more
visible.
2008-04-28 12:18:45 +03:00
Uoti Urpala 37e1edee35 Move initialized_flags to mpctx
The function exit_sighandler had a line
  if(initialized_flags==0 && sig_count>1) exit(1);
rather than try to make this work without the variable I just removed
the line as it looks unlikely this condition would occur except very
rarely.
2008-04-26 15:31:39 +03:00
Uoti Urpala 80d43e8632 Move global filename to mpctx 2008-04-26 15:17:51 +03:00
Uoti Urpala fb33e286b5 Move global mconfig to mpctx
The global was used in the function cfg_include which handles the
-include option. Make the address available in that function by
creating a new dynamically allocated option in m_config_new that has
the address in the option's private data.

asxparser.c also used the global. Making it available through all ways
the code could get called required a number of relatively straightforward
changes to playtree and menu code.
2008-04-26 10:44:59 +03:00
Uoti Urpala 0e757bf9da Remove _s/_st suffix from some struct names
Since the names are always used after the keyword "struct" having a
suffix as in "struct demuxer_st" is almost completely pointless.
2008-04-25 03:34:22 +03:00
Uoti Urpala c510959da5 Remove some unnecessary recursive includes
Remove some #include lines from headers, some of those removals made
possible by using incomplete struct types instead of typedefs. Include
mp_osd.h in mplayer.c and command.c after removing it from mp_core.h.
Remove "#ifdef USE_ASS" around some "struct ass_track_s *" fields
which will now compile even without ASS support.
2008-04-23 13:48:38 +03:00
Uoti Urpala d9aa368a6d Move playback_speed to options struct 2008-04-23 13:48:37 +03:00
Uoti Urpala 3ee6503a07 Move global rel_seek_secs and abs_seek_pos to mpctx 2008-04-23 13:48:37 +03:00