diff -Nru mplayer2-2.0-426-gc32b3ed/Makefile mplayer2-2.0-554-gf63dbad/Makefile --- mplayer2-2.0-426-gc32b3ed/Makefile 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/Makefile 2012-05-17 14:38:00.000000000 +0000 @@ -23,8 +23,7 @@ ###### variable declarations ####### -SRCS_AUDIO_INPUT-$(ALSA1X) += stream/ai_alsa1x.c -SRCS_AUDIO_INPUT-$(ALSA9) += stream/ai_alsa.c +SRCS_AUDIO_INPUT-$(ALSA) += stream/ai_alsa1x.c SRCS_AUDIO_INPUT-$(OSS) += stream/ai_oss.c SRCS_COMMON-$(AUDIO_INPUT) += $(SRCS_AUDIO_INPUT-yes) SRCS_COMMON-$(BITMAP_FONT) += sub/font_load.c @@ -93,13 +92,17 @@ SRCS_COMMON-$(LIBNEMESI) += libmpdemux/demux_nemesi.c \ stream/stream_nemesi.c SRCS_COMMON-$(LIBNUT) += libmpdemux/demux_nut.c +SRCS_COMMON-$(LIBPOSTPROC) += libmpcodecs/vf_pp.c SRCS_COMMON-$(LIBSMBCLIENT) += stream/stream_smb.c SRCS_COMMON-$(LIBTHEORA) += libmpcodecs/vd_theora.c SRCS_COMMON-$(LIVE555) += libmpdemux/demux_rtp.cpp \ libmpdemux/demux_rtp_codec.cpp \ stream/stream_live555.c -SRCS_COMMON-$(MACOSX_FINDER) += osdep/macosx_finder_args.c +SRCS_COMMON-$(MACOSX_FINDER) += osdep/macosx_finder_args.m +SRCS_COMMON-$(COCOA) += libvo/osx_common.c \ + libvo/cocoa_common.m \ + osdep/cocoa_events.m SRCS_COMMON-$(MNG) += libmpdemux/demux_mng.c SRCS_COMMON-$(MPG123) += libmpcodecs/ad_mpg123.c @@ -115,7 +118,6 @@ SRCS_COMMON-$(NEED_GETTIMEOFDAY) += osdep/gettimeofday.c SRCS_COMMON-$(NEED_GLOB) += osdep/glob-win.c -SRCS_COMMON-$(NEED_MMAP) += osdep/mmap-os2.c SRCS_COMMON-$(NEED_SETENV) += osdep/setenv.c SRCS_COMMON-$(NEED_SHMEM) += osdep/shmem.c SRCS_COMMON-$(NEED_STRSEP) += osdep/strsep.c @@ -218,7 +220,6 @@ codec-cfg.c \ cpudetect.c \ defaultopts.c \ - edl.c \ fmt-conversion.c \ m_config.c \ m_option.c \ @@ -331,7 +332,6 @@ libmpcodecs/vf_palette.c \ libmpcodecs/vf_perspective.c \ libmpcodecs/vf_phase.c \ - libmpcodecs/vf_pp.c \ libmpcodecs/vf_pp7.c \ libmpcodecs/vf_pullup.c \ libmpcodecs/vf_qp.c \ @@ -404,6 +404,7 @@ libmpdemux/yuv4mpeg_ratio.c \ libvo/osd.c \ osdep/numcores.c \ + osdep/io.c \ osdep/$(GETCH) \ osdep/$(TIMER) \ stream/open.c \ @@ -415,12 +416,12 @@ stream/stream_null.c \ stream/url.c \ sub/av_sub.c \ - sub/sub.c \ - sub/sub_cc.c \ sub/dec_sub.c \ sub/find_sub.c \ sub/find_subfiles.c \ sub/spudec.c \ + sub/sub.c \ + sub/sub_cc.c \ sub/subassconvert.c \ sub/subreader.c \ sub/vobsub.c \ @@ -431,29 +432,24 @@ SRCS_MPLAYER-$(3DFX) += libvo/vo_3dfx.c SRCS_MPLAYER-$(AA) += libvo/vo_aa.c -SRCS_MPLAYER-$(ALSA1X) += libao2/ao_alsa.c -SRCS_MPLAYER-$(ALSA5) += libao2/ao_alsa5.c -SRCS_MPLAYER-$(ALSA9) += libao2/ao_alsa.c +SRCS_MPLAYER-$(ALSA) += libao2/ao_alsa.c SRCS_MPLAYER-$(APPLE_IR) += input/appleir.c SRCS_MPLAYER-$(APPLE_REMOTE) += input/ar.c -SRCS_MPLAYER-$(ARTS) += libao2/ao_arts.c SRCS_MPLAYER-$(BL) += libvo/vo_bl.c SRCS_MPLAYER-$(CACA) += libvo/vo_caca.c SRCS_MPLAYER-$(COREAUDIO) += libao2/ao_coreaudio.c -SRCS_MPLAYER-$(COREVIDEO) += libvo/vo_corevideo.m libvo/osx_common.c -SRCS_MPLAYER-$(DART) += libao2/ao_dart.c +SRCS_MPLAYER-$(COREVIDEO) += libvo/vo_corevideo.m +SRCS_MPLAYER-$(SHAREDBUFFER) += libvo/vo_sharedbuffer.m SRCS_MPLAYER-$(DGA) += libvo/vo_dga.c SRCS_MPLAYER-$(DIRECT3D) += libvo/vo_direct3d.c libvo/w32_common.c SRCS_MPLAYER-$(DIRECTFB) += libvo/vo_directfb2.c libvo/vo_dfbmga.c SRCS_MPLAYER-$(DIRECTX) += libao2/ao_dsound.c libvo/vo_directx.c SRCS_MPLAYER-$(DXR3) += libvo/vo_dxr3.c -SRCS_MPLAYER-$(ESD) += libao2/ao_esd.c SRCS_MPLAYER-$(FBDEV) += libvo/vo_fbdev.c libvo/vo_fbdev2.c SRCS_MPLAYER-$(GGI) += libvo/vo_ggi.c SRCS_MPLAYER-$(GIF) += libvo/vo_gif89a.c SRCS_MPLAYER-$(GL) += libvo/gl_common.c libvo/vo_gl.c \ pnm_loader.c -SRCS_MPLAYER-$(GL_COCOA) += libvo/cocoa_common.m SRCS_MPLAYER-$(GL_SDL) += libvo/sdl_common.c SRCS_MPLAYER-$(GL_WIN32) += libvo/w32_common.c SRCS_MPLAYER-$(GL_X11) += libvo/x11_common.c @@ -462,8 +458,6 @@ SRCS_MPLAYER-$(JACK) += libao2/ao_jack.c SRCS_MPLAYER-$(JOYSTICK) += input/joystick.c SRCS_MPLAYER-$(JPEG) += libvo/vo_jpeg.c -SRCS_MPLAYER-$(KAI) += libao2/ao_kai.c -SRCS_MPLAYER-$(KVA) += libvo/vo_kva.c SRCS_MPLAYER-$(LIRC) += input/lirc.c SRCS_MPLAYER-$(MD5SUM) += libvo/vo_md5sum.c SRCS_MPLAYER-$(MGA) += libvo/vo_mga.c @@ -472,11 +466,10 @@ SRCS_MPLAYER-$(OSS) += libao2/ao_oss.c SRCS_MPLAYER-$(PNM) += libvo/vo_pnm.c SRCS_MPLAYER-$(PULSE) += libao2/ao_pulse.c -SRCS_MPLAYER-$(QUARTZ) += libvo/vo_quartz.c libvo/osx_common.c +SRCS_MPLAYER-$(PORTAUDIO) += libao2/ao_portaudio.c SRCS_MPLAYER-$(RSOUND) += libao2/ao_rsound.c SRCS_MPLAYER-$(S3FB) += libvo/vo_s3fb.c SRCS_MPLAYER-$(SDL) += libao2/ao_sdl.c libvo/vo_sdl.c libvo/sdl_common.c -SRCS_MPLAYER-$(SGIAUDIO) += libao2/ao_sgi.c SRCS_MPLAYER-$(SUNAUDIO) += libao2/ao_sun.c SRCS_MPLAYER-$(SVGA) += libvo/vo_svga.c SRCS_MPLAYER-$(TDFXFB) += libvo/vo_tdfxfb.c @@ -527,7 +520,7 @@ OBJS_MPLAYER += $(OBJS_MPLAYER-yes) MPLAYER_DEPS = $(OBJS_MPLAYER) $(OBJS_COMMON) $(COMMON_LIBS) -DEP_FILES = $(patsubst %.S,%.d,$(patsubst %.cpp,%.d,$(patsubst %.c,%.d,$(SRCS_COMMON) $(SRCS_MPLAYER:.m=.d)))) +DEP_FILES = $(patsubst %.S,%.d,$(patsubst %.cpp,%.d,$(patsubst %.c,%.d,$(SRCS_COMMON:.m=.d) $(SRCS_MPLAYER:.m=.d)))) ALL_PRG-$(MPLAYER) += mplayer$(EXESUF) diff -Nru mplayer2-2.0-426-gc32b3ed/access_mpcontext.h mplayer2-2.0-554-gf63dbad/access_mpcontext.h --- mplayer2-2.0-426-gc32b3ed/access_mpcontext.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/access_mpcontext.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -/* - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPLAYER_ACCESS_MPCONTEXT_H -#define MPLAYER_ACCESS_MPCONTEXT_H - -struct MPContext; -void *mpctx_get_video_out(struct MPContext *mpctx); -void *mpctx_get_demuxer(struct MPContext *mpctx); -void *mpctx_get_playtree_iter(struct MPContext *mpctx); -void *mpctx_get_mixer(struct MPContext *mpctx); -int mpctx_get_global_sub_size(struct MPContext *mpctx); -int mpctx_get_osd_function(struct MPContext *mpctx); - -#endif /* MPLAYER_ACCESS_MPCONTEXT_H */ diff -Nru mplayer2-2.0-426-gc32b3ed/av_log.c mplayer2-2.0-554-gf63dbad/av_log.c --- mplayer2-2.0-426-gc32b3ed/av_log.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/av_log.c 2012-05-17 14:38:00.000000000 +0000 @@ -32,7 +32,6 @@ #include #include #include -#include static int av_log_level_to_mp_level(int av_level) { @@ -111,11 +110,9 @@ void init_libav(void) { av_log_set_callback(mp_msg_av_log_callback); - - avcodec_init(); avcodec_register_all(); - av_register_all(); + avformat_network_init(); } #define V(x) (x)>>16, (x)>>8 & 255, (x) & 255 @@ -137,5 +134,4 @@ print_version("libavcodec", LIBAVCODEC_VERSION_INT, avcodec_version()); print_version("libavformat", LIBAVFORMAT_VERSION_INT, avformat_version()); print_version("libswscale", LIBSWSCALE_VERSION_INT, swscale_version()); - print_version("libpostproc", LIBPOSTPROC_VERSION_INT, postproc_version()); } diff -Nru mplayer2-2.0-426-gc32b3ed/av_opts.c mplayer2-2.0-554-gf63dbad/av_opts.c --- mplayer2-2.0-426-gc32b3ed/av_opts.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/av_opts.c 2012-05-17 14:38:00.000000000 +0000 @@ -21,8 +21,10 @@ #include #include + +#include + #include "av_opts.h" -#include "libavcodec/opt.h" int parse_avopts(void *v, char *str){ char *start; @@ -37,7 +39,7 @@ arg = strchr(str, '='); if(arg) *arg++= 0; - if (av_set_string3(v, str, arg, 0, NULL) < 0) { + if (av_opt_set(v, str, arg, AV_OPT_SEARCH_CHILDREN) < 0) { free(start); return -1; } diff -Nru mplayer2-2.0-426-gc32b3ed/bstr.c mplayer2-2.0-554-gf63dbad/bstr.c --- mplayer2-2.0-426-gc32b3ed/bstr.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/bstr.c 2012-05-17 14:38:00.000000000 +0000 @@ -185,6 +185,14 @@ return r; } +bool bstr_eatstart(struct bstr *s, struct bstr prefix) +{ + if (!bstr_startswith(*s, prefix)) + return false; + *s = bstr_cut(*s, prefix.len); + return true; +} + void bstr_lower(struct bstr str) { for (int i = 0; i < str.len; i++) @@ -201,3 +209,35 @@ talloc_free(ptr); return ret; } + +int bstr_parse_utf8_code_length(unsigned char b) +{ + if (b < 128) + return 1; + int bytes = 7 - av_log2(b ^ 255); + return (bytes >= 2 && bytes <= 4) ? bytes : -1; +} + +int bstr_decode_utf8(struct bstr s, struct bstr *out_next) +{ + if (s.len == 0) + return -1; + unsigned int codepoint = s.start[0]; + s.start++; s.len--; + if (codepoint >= 128) { + int bytes = bstr_parse_utf8_code_length(codepoint); + if (bytes < 0 || s.len < bytes - 1) + return -1; + codepoint &= 127 >> bytes; + for (int n = 1; n < bytes; n++) { + int tmp = s.start[0]; + if ((tmp & 0xC0) != 0x80) + return -1; + codepoint = (codepoint << 6) | (tmp & ~0xC0); + s.start++; s.len--; + } + } + if (out_next) + *out_next = s; + return codepoint; +} diff -Nru mplayer2-2.0-426-gc32b3ed/bstr.h mplayer2-2.0-554-gf63dbad/bstr.h --- mplayer2-2.0-426-gc32b3ed/bstr.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/bstr.h 2012-05-17 14:38:00.000000000 +0000 @@ -69,6 +69,22 @@ void bstr_lower(struct bstr str); int bstr_sscanf(struct bstr str, const char *format, ...); +// Decode the UTF-8 code point at the start of the string,, and return the +// character. +// After calling this function, *out_next will point to the next character. +// out_next can be NULL. +// On error, -1 is returned, and *out_next is not modified. +int bstr_decode_utf8(struct bstr str, struct bstr *out_next); + +// Return the length of the UTF-8 sequence that starts with the given byte. +// Given a string char *s, the next UTF-8 code point is to be expected at +// s + bstr_parse_utf8_code_length(s[0]) +// On error, -1 is returned. On success, it returns a value in the range [1, 4]. +int bstr_parse_utf8_code_length(unsigned char b); + +// If s starts with prefix, return true and return the rest of the string in s. +bool bstr_eatstart(struct bstr *s, struct bstr prefix); + static inline struct bstr bstr_cut(struct bstr str, int n) { if (n > str.len) diff -Nru mplayer2-2.0-426-gc32b3ed/cfg-mplayer.h mplayer2-2.0-554-gf63dbad/cfg-mplayer.h --- mplayer2-2.0-426-gc32b3ed/cfg-mplayer.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/cfg-mplayer.h 2012-05-17 14:38:00.000000000 +0000 @@ -86,7 +86,7 @@ extern off_t ps_probe; extern int sws_flags; -extern char* pp_help; +extern const char pp_help[]; #ifdef CONFIG_RADIO const m_option_t radioopts_conf[]={ @@ -373,7 +373,8 @@ // ------------------------- common options -------------------- OPT_MAKE_FLAGS("quiet", quiet, CONF_GLOBAL), {"really-quiet", &verbose, CONF_TYPE_FLAG, CONF_GLOBAL|CONF_PRE_PARSE, 0, -10, NULL}, - {"v", cfg_inc_verbose, CONF_TYPE_FUNC, CONF_GLOBAL|CONF_NOSAVE, 0, 0, NULL}, + // -v is handled in command line preparser + {"v", NULL, CONF_TYPE_FLAG, CONF_NOCFG, 0, 0, NULL}, {"msglevel", (void *) msgl_config, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL}, {"msgcolor", &mp_msg_color, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL}, {"nomsgcolor", &mp_msg_color, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL}, @@ -488,7 +489,8 @@ // stop at given position {"endpos", &end_at, CONF_TYPE_TIME_SIZE, 0, 0, 0, NULL}, - {"edl", &edl_filename, CONF_TYPE_STRING, 0, 0, 0, NULL}, + OPT_ERRORMESSAGE("edl", "Old EDL functionality using the --edl option is " + "not supported.\n"), // AVI specific: force non-interleaved mode {"ni", &force_ni, CONF_TYPE_FLAG, 0, 0, 1, NULL}, @@ -596,7 +598,9 @@ // postprocessing: {"pp", &divx_quality, CONF_TYPE_INT, 0, 0, 0, NULL}, +#ifdef CONFIG_LIBPOSTPROC {"pphelp", &pp_help, CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL}, +#endif // scaling: {"sws", &sws_flags, CONF_TYPE_INT, 0, 0, 2, NULL}, @@ -725,11 +729,10 @@ {"border", &vo_border, CONF_TYPE_FLAG, 0, 0, 1, NULL}, {"noborder", &vo_border, CONF_TYPE_FLAG, 0, 1, 0, NULL}, - {"mixer", &mixer_device, CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"mixer-channel", &mixer_channel, CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"softvol", &soft_vol, CONF_TYPE_FLAG, 0, 0, 1, NULL}, - {"nosoftvol", &soft_vol, CONF_TYPE_FLAG, 0, 1, 0, NULL}, - {"softvol-max", &soft_vol_max, CONF_TYPE_FLOAT, CONF_RANGE, 10, 10000, NULL}, + OPT_STRING("mixer", mixer_device, 0), + OPT_STRING("mixer-channel", mixer_channel, 0), + OPT_MAKE_FLAGS("softvol", softvol, 0), + OPT_FLOATRANGE("softvol-max", softvol_max, 0, 10, 10000), {"volstep", &volstep, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL}, {"volume", &start_volume, CONF_TYPE_FLOAT, CONF_RANGE, -1, 10000, NULL}, OPT_MAKE_FLAGS("gapless-audio", gapless_audio, 0), @@ -801,6 +804,7 @@ {"grabpointer", &vo_grabpointer, CONF_TYPE_FLAG, 0, 0, 1, NULL}, {"nograbpointer", &vo_grabpointer, CONF_TYPE_FLAG, 0, 1, 0, NULL}, + OPT_INTRANGE("cursor-autohide-delay", cursor_autohide_delay, 0, -2, 30000), {"adapter", &vo_adapter_num, CONF_TYPE_INT, CONF_RANGE, 0, 5, NULL}, {"refreshrate",&vo_refresh_rate,CONF_TYPE_INT,CONF_RANGE, 0,100, NULL}, @@ -926,7 +930,6 @@ OPT_FLAG_ON("list-properties", list_properties, CONF_GLOBAL), {"identify", &mp_msg_levels[MSGT_IDENTIFY], CONF_TYPE_FLAG, CONF_GLOBAL, 0, MSGL_V, NULL}, - {"-help", (void *) help_text, CONF_TYPE_PRINT, CONF_NOCFG|CONF_GLOBAL, 0, 0, NULL}, {"help", (void *) help_text, CONF_TYPE_PRINT, CONF_NOCFG|CONF_GLOBAL, 0, 0, NULL}, {"h", (void *) help_text, CONF_TYPE_PRINT, CONF_NOCFG|CONF_GLOBAL, 0, 0, NULL}, diff -Nru mplayer2-2.0-426-gc32b3ed/command.c mplayer2-2.0-554-gf63dbad/command.c --- mplayer2-2.0-426-gc32b3ed/command.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/command.c 2012-05-17 14:38:00.000000000 +0000 @@ -680,10 +680,8 @@ case M_PROPERTY_STEP_DOWN: if (mpctx->paused) { unpause_player(mpctx); - mpctx->osd_function = OSD_PLAY; } else { pause_player(mpctx); - mpctx->osd_function = OSD_PAUSE; } return M_PROPERTY_OK; default: @@ -721,10 +719,6 @@ return M_PROPERTY_NOT_IMPLEMENTED; } - if (mpctx->edl_muted) - return M_PROPERTY_DISABLED; - mpctx->user_muted = 0; - switch (action) { case M_PROPERTY_SET: if (!arg) @@ -758,31 +752,17 @@ switch (action) { case M_PROPERTY_SET: - if (mpctx->edl_muted) - return M_PROPERTY_DISABLED; if (!arg) return M_PROPERTY_ERROR; - if ((!!*(int *) arg) != mpctx->mixer.muted) - mixer_mute(&mpctx->mixer); - mpctx->user_muted = mpctx->mixer.muted; + mixer_setmute(&mpctx->mixer, *(int *) arg); return M_PROPERTY_OK; case M_PROPERTY_STEP_UP: case M_PROPERTY_STEP_DOWN: - if (mpctx->edl_muted) - return M_PROPERTY_DISABLED; - mixer_mute(&mpctx->mixer); - mpctx->user_muted = mpctx->mixer.muted; + mixer_setmute(&mpctx->mixer, !mixer_getmute(&mpctx->mixer)); return M_PROPERTY_OK; - case M_PROPERTY_PRINT: - if (!arg) - return M_PROPERTY_ERROR; - if (mpctx->edl_muted) { - *(char **) arg = talloc_strdup(NULL, mp_gtext("enabled (EDL)")); - return M_PROPERTY_OK; - } default: - return m_property_flag(prop, action, arg, &mpctx->mixer.muted); - + return m_property_flag_ro(prop, action, arg, + mixer_getmute(&mpctx->mixer)); } } @@ -887,9 +867,6 @@ { float bal; - if (!mpctx->sh_audio || mpctx->sh_audio->channels < 2) - return M_PROPERTY_UNAVAILABLE; - switch (action) { case M_PROPERTY_GET: if (!arg) @@ -1581,7 +1558,7 @@ { struct MPOpts *opts = &mpctx->opts; demux_stream_t *const d_sub = mpctx->d_sub; - int source = -1, reset_spu = 0; + int source = -1, reset_spu av_unused = 0; // used under CONFIG_DVDREAD int source_pos = -1; update_global_sub_size(mpctx); @@ -1782,7 +1759,7 @@ } #endif - update_subtitles(mpctx, 0, 0, true); + update_subtitles(mpctx, 0, true); return M_PROPERTY_OK; } diff -Nru mplayer2-2.0-426-gc32b3ed/configure mplayer2-2.0-554-gf63dbad/configure --- mplayer2-2.0-426-gc32b3ed/configure 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/configure 2012-05-17 14:38:00.000000000 +0000 @@ -165,6 +165,22 @@ return "$TMPRES" } +pkg_config_add() { + unset IFS # shell should not be used for programming + echo >> "$TMPLOG" + echo "$_pkg_config --cflags $@" >> "$TMPLOG" + ctmp=$($_pkg_config --cflags "$@" 2>> "$TMPLOG") || return $? + echo >> "$TMPLOG" + echo "$_pkg_config --libs $@" >> "$TMPLOG" + ltmp=$($_pkg_config --libs "$@" 2>> "$TMPLOG") || return $? + echo >> "$TMPLOG" + echo "cflags: $ctmp" >> "$TMPLOG" + echo "libs: $ltmp" >> "$TMPLOG" + echo >> "$TMPLOG" + extra_cflags="$extra_cflags $ctmp" + extra_ldflags="$extra_ldflags $ltmp" +} + tmp_run() { "$TMPEXE" >> "$TMPLOG" 2>&1 } @@ -193,13 +209,11 @@ freebsd() { issystem "FreeBSD" || issystem "GNU/kFreeBSD"; } gnu() { issystem "GNU"; } hpux() { issystem "HP-UX"; } -irix() { issystem "IRIX"; } linux() { issystem "Linux"; } mingw32() { issystem "MINGW32"; } morphos() { issystem "MorphOS"; } netbsd() { issystem "NetBSD"; } openbsd() { issystem "OpenBSD"; } -os2() { issystem "OS/2"; } qnx() { issystem "QNX"; } sunos() { issystem "SunOS"; } win32() { cygwin || mingw32; } @@ -320,7 +334,7 @@ --disable-networking disable networking [enable] --enable-winsock2_h enable winsock2_h [autodetect] --enable-smb enable Samba (SMB) input [autodetect] - --enable-live enable LIVE555 Streaming Media [autodetect] + --enable-live enable LIVE555 Streaming Media [disable] --enable-nemesi enable Nemesi Streaming Media [autodetect] --disable-vcd disable VCD support [autodetect] --disable-bluray disable Blu-ray support [autodetect] @@ -328,7 +342,6 @@ --disable-dvdread disable libdvdread [autodetect] --disable-dvdread-internal disable internal libdvdread [autodetect] --disable-libdvdcss-internal disable internal libdvdcss [autodetect] - --disable-cdparanoia disable cdparanoia [autodetect] --disable-cddb disable cddb [autodetect] --disable-bitmap-font disable bitmap font support [enable] --disable-freetype disable FreeType 2 font rendering [autodetect] @@ -348,6 +361,7 @@ --disable-w32threads disable Win32 threads support [autodetect] --disable-libass disable subtitle rendering with libass [autodetect] --enable-rpath enable runtime linker path for extra libs [disabled] + --disable-libpostproc disable postprocess filter (vf_pp) [autodetect] Codecs: --enable-gif enable GIF support [autodetect] @@ -385,7 +399,6 @@ --enable-vesa enable VESA video output [autodetect] --enable-svga enable SVGAlib video output [autodetect] --enable-sdl enable SDL video output [autodetect] - --enable-kva enable KVA video output [autodetect] --enable-aa enable AAlib video output [autodetect] --enable-caca enable CACA video output [autodetect] --enable-ggi enable GGI video output [autodetect] @@ -420,22 +433,18 @@ --disable-yuv4mpeg disable yuv4mpeg video output [enable] --disable-corevideo disable CoreVideo video output [autodetect] --disable-cocoa disable Cocoa OpenGL backend [autodetect] - --disable-quartz disable Quartz video output [autodetect] + --disable-sharedbuffer disable OSX shared buffer video output [autodetect] Audio output: --disable-alsa disable ALSA audio output [autodetect] --disable-ossaudio disable OSS audio output [autodetect] - --disable-arts disable aRts audio output [autodetect] - --disable-esd disable esd audio output [autodetect] --disable-rsound disable RSound audio output [autodetect] --disable-pulse disable Pulseaudio audio output [autodetect] + --disable-portaudio disable PortAudio audio output [autodetect] --disable-jack disable JACK audio output [autodetect] --enable-openal enable OpenAL audio output [disable] --disable-nas disable NAS audio output [autodetect] - --disable-sgiaudio disable SGI audio output [autodetect] --disable-sunaudio disable Sun audio output [autodetect] - --disable-kai disable KAI audio output [autodetect] - --disable-dart disable DART audio output [autodetect] --disable-win32waveout disable Windows waveout audio output [autodetect] --disable-coreaudio disable CoreAudio audio output [autodetect] --disable-select disable using select() on the audio device [enable] @@ -460,13 +469,14 @@ Miscellaneous options: --enable-runtime-cpudetection enable runtime CPU detection [disable] - --enable-cross-compile enable cross-compilation [autodetect] + --enable-cross-compile enable cross-compilation [disable] --cc=COMPILER C compiler to build MPlayer [gcc] --host-cc=COMPILER C compiler for tools needed while building [gcc] --as=ASSEMBLER assembler to build MPlayer [as] --nm=NM nm tool to build MPlayer [nm] --yasm=YASM Yasm assembler to build MPlayer [yasm] --ar=AR librarian to build MPlayer [ar] + --pkg-config=PKGCONFIG pkg-config to find some libraries [pkg-config] --ranlib=RANLIB ranlib to build MPlayer [ranlib] --windres=WINDRES windres to build MPlayer [windres] --target=PLATFORM target platform (i386-linux, arm-linux, etc) @@ -502,7 +512,6 @@ --extra-libs=FLAGS extra linker flags --extra-libs-mplayer=FLAGS extra linker flags for MPlayer - --with-freetype-config=PATH path to freetype-config --with-sdl-config=PATH path to sdl*-config --with-dvdnav-config=PATH path to dvdnav-config --with-dvdread-config=PATH path to dvdread-config @@ -534,19 +543,19 @@ _armvfp=auto neon=auto _iwmmxt=auto -_mtrr=auto _altivec=auto _install=install -_ranlib=ranlib -_windres=windres -_cc=cc -_ar=ar +_pkg_config=auto +_ranlib=auto +_windres=auto +_cc=auto +_ar=auto test "$CC" && _cc="$CC" _as=auto _nm=auto -_yasm=yasm +_yasm=auto _runtime_cpudetection=no -_cross_compile=auto +_cross_compile=no _prefix="/usr/local" ffmpeg=auto ffmpeg_internals=no @@ -559,7 +568,6 @@ _xv=auto _vdpau=auto _sdl=auto -_kva=auto _direct3d=auto _directx=auto _win32waveout=auto @@ -587,13 +595,10 @@ _langinfo=auto _rtc=auto _ossaudio=auto -_arts=auto -_esd=auto _rsound=auto _pulse=auto +_portaudio=auto _jack=auto -_kai=auto -_dart=auto _openal=no _libcdio=auto _mad=auto @@ -618,7 +623,7 @@ _libdvdcss_internal=auto _xanim=auto _real=auto -_live=auto +_live=no _nemesi=auto _native_rtsp=yes _xinerama=auto @@ -626,7 +631,6 @@ _xmga=auto _vm=auto _xf86keysym=auto -_sgiaudio=auto _sunaudio=auto _alsa=auto _fastmemcpy=yes @@ -672,7 +676,7 @@ _crash_debug=no _sighandler=yes _libdv=auto -_cdparanoia=auto +_cdda=auto _cddb=auto _big_endian=auto _bitmap_font=yes @@ -682,12 +686,11 @@ _coreaudio=auto _corevideo=auto _cocoa=auto -_quartz=auto +_sharedbuffer=auto quicktime=auto _macosx_finder=no _macosx_bundle=auto _sortsub=yes -_freetypeconfig='freetype-config' _fribidi=auto _enca=auto _inet6=auto @@ -699,6 +702,7 @@ _w32threads=auto _ass=auto _rpath=no +libpostproc=auto _asmalign_pot=auto _stream_cache=yes _priority=no @@ -744,9 +748,6 @@ --with-sdl-config=*) _sdlconfig=$(echo $ac_option | cut -d '=' -f 2) ;; - --with-freetype-config=*) - _freetypeconfig=$(echo $ac_option | cut -d '=' -f 2) - ;; --with-dvdnav-config=*) _dvdnavconfig=$(echo $ac_option | cut -d '=' -f 2) ;; @@ -788,6 +789,9 @@ --ar=*) _ar=$(echo $ac_option | cut -d '=' -f 2) ;; + --pkg-config=*) + _pkg_config=$(echo $ac_option | cut -d '=' -f 2) + ;; --ranlib=*) _ranlib=$(echo $ac_option | cut -d '=' -f 2) ;; @@ -851,8 +855,6 @@ --disable-vdpau) _vdpau=no ;; --enable-sdl) _sdl=yes ;; --disable-sdl) _sdl=no ;; - --enable-kva) _kva=yes ;; - --disable-kva) _kva=no ;; --enable-direct3d) _direct3d=yes ;; --disable-direct3d) _direct3d=no ;; --enable-directx) _directx=yes ;; @@ -909,22 +911,16 @@ --disable-libdv) _libdv=no ;; --enable-ossaudio) _ossaudio=yes ;; --disable-ossaudio) _ossaudio=no ;; - --enable-arts) _arts=yes ;; - --disable-arts) _arts=no ;; - --enable-esd) _esd=yes ;; - --disable-esd) _esd=no ;; --enable-rsound) _rsound=yes ;; --disable-rsound) _rsound=no ;; --enable-pulse) _pulse=yes ;; --disable-pulse) _pulse=no ;; + --enable-portaudio) _portaudio=yes ;; + --disable-portaudio) _portaudio=no ;; --enable-jack) _jack=yes ;; --disable-jack) _jack=no ;; --enable-openal) _openal=yes ;; --disable-openal) _openal=no ;; - --enable-kai) _kai=yes ;; - --disable-kai) _kai=no ;; - --enable-dart) _dart=yes ;; - --disable-dart) _dart=no ;; --enable-mad) _mad=yes ;; --disable-mad) _mad=no ;; --enable-libcdio) _libcdio=yes ;; @@ -985,8 +981,6 @@ --disable-xf86keysym) _xf86keysym=no ;; --enable-sunaudio) _sunaudio=yes ;; --disable-sunaudio) _sunaudio=no ;; - --enable-sgiaudio) _sgiaudio=yes ;; - --disable-sgiaudio) _sgiaudio=no ;; --enable-alsa) _alsa=yes ;; --disable-alsa) _alsa=no ;; --enable-tv) _tv=yes ;; @@ -1059,14 +1053,10 @@ --disable-directfb) _directfb=no ;; --enable-bl) _bl=yes ;; --disable-bl) _bl=no ;; - --enable-mtrr) _mtrr=yes ;; - --disable-mtrr) _mtrr=no ;; --enable-shm) _shm=yes ;; --disable-shm) _shm=no ;; --enable-select) _select=yes ;; --disable-select) _select=no ;; - --enable-cdparanoia) _cdparanoia=yes ;; - --disable-cdparanoia) _cdparanoia=no ;; --enable-cddb) _cddb=yes ;; --disable-cddb) _cddb=no ;; --enable-big-endian) _big_endian=yes ;; @@ -1091,6 +1081,8 @@ --disable-libass) _ass=no ;; --enable-rpath) _rpath=yes ;; --disable-rpath) _rpath=no ;; + --enable-libpostproc) libpostproc=yes ;; + --disable-libpostproc) libpostproc=no ;; --enable-fribidi) _fribidi=yes ;; --disable-fribidi) _fribidi=no ;; @@ -1118,8 +1110,8 @@ --disable-corevideo) _corevideo=no ;; --enable-cocoa) _cocoa=yes ;; --disable-cocoa) _cocoa=no ;; - --enable-quartz) _quartz=yes ;; - --disable-quartz) _quartz=no ;; + --enable-sharedbuffer) _sharedbuffer=yes ;; + --disable-sharedbuffer) _sharedbuffer=no ;; --enable-macosx-finder) _macosx_finder=yes ;; --disable-macosx-finder) _macosx_finder=no ;; --enable-macosx-bundle) _macosx_bundle=yes ;; @@ -1187,6 +1179,58 @@ test -z "$_libdir" && _libdir="$_prefix/lib" test -z "$_localedir" && _localedir="$_prefix/share/locale" +for tmpdir in "$TMPDIR" "$TEMPDIR" "/tmp" ; do + test "$tmpdir" && break +done + +mplayer_tmpdir="$tmpdir/mplayer-configure-$RANDOM-$$" +mkdir $mplayer_tmpdir || die "Unable to create tmpdir." + +TMPLOG="config.log" + +rm -f "$TMPLOG" +echo Parameters configure was run with: > "$TMPLOG" +if test -n "$CFLAGS" ; then + echo ${_echo_n} CFLAGS="'$CFLAGS' ${_echo_c}" >> "$TMPLOG" +fi +if test -n "$PKG_CONFIG_PATH" ; then + echo ${_echo_n} PKG_CONFIG_PATH="'$PKG_CONFIG_PATH' ${_echo_c}" >> "$TMPLOG" +fi +echo ./configure $configuration >> "$TMPLOG" +echo >> "$TMPLOG" + + +echocheck "cross compilation" +echores $_cross_compile + +if test $_cross_compile = yes; then + tmp_run() { + return 0 + } + test "$_host_cc" || _host_cc=cc +fi + +tool_prefix="" + +if test $_cross_compile = yes ; then + # Usually cross-compiler prefixes match with the target triplet + test -n "$_target" && tool_prefix="$_target"- +fi + +test "$_ranlib" = auto && _ranlib="$tool_prefix"ranlib +test "$_windres" = auto && _windres="$tool_prefix"windres +test "$_ar" = auto && _ar="$tool_prefix"ar +test "$_yasm" = auto && _yasm="$tool_prefix"yasm +test "$_pkg_config" = auto && _pkg_config="$tool_prefix"pkg-config + +if test "$_cc" = auto ; then + if test -n "$tool_prefix" ; then + _cc="$tool_prefix"gcc + else + _cc=cc + fi +fi + # Determine our OS name and CPU architecture if test -z "$_target" ; then # OS name @@ -1197,9 +1241,6 @@ Haiku) system_name=BeOS ;; - IRIX*) - system_name=IRIX - ;; GNU/kFreeBSD) system_name=FreeBSD ;; @@ -1257,21 +1298,25 @@ ;; esac else # if test -z "$_target" - system_name=$(echo $_target | cut -d '-' -f 2) - case "$(echo $system_name | tr A-Z a-z)" in - linux) system_name=Linux ;; - freebsd) system_name=FreeBSD ;; - gnu/kfreebsd) system_name=FreeBSD ;; - netbsd) system_name=NetBSD ;; - bsd/os) system_name=BSD/OS ;; - openbsd) system_name=OpenBSD ;; - dragonfly) system_name=DragonFly ;; - sunos) system_name=SunOS ;; - qnx) system_name=QNX ;; - morphos) system_name=MorphOS ;; - amigaos) system_name=AmigaOS ;; - mingw32*) system_name=MINGW32 ;; - esac + for i in 2 3; do + system_name=$(echo $_target | cut -d '-' -f $i) + case "$(echo $system_name | tr A-Z a-z)" in + linux) system_name=Linux ;; + freebsd) system_name=FreeBSD ;; + gnu/kfreebsd) system_name=FreeBSD ;; + netbsd) system_name=NetBSD ;; + bsd/os) system_name=BSD/OS ;; + openbsd) system_name=OpenBSD ;; + dragonfly) system_name=DragonFly ;; + sunos) system_name=SunOS ;; + qnx) system_name=QNX ;; + morphos) system_name=MorphOS ;; + amigaos) system_name=AmigaOS ;; + mingw32*) system_name=MINGW32 ;; + *) continue ;; + esac + break + done # We need to convert underscores so that values like k6-2 and pentium-mmx can be passed host_arch=$(echo $_target | cut -d '-' -f 1) if test $(echo $host_arch) != "x86_64" ; then @@ -1294,9 +1339,6 @@ if darwin; then extra_cflags="-mdynamic-no-pic $extra_cflags" - if test "$(basename $_cc)" != "clang" ; then - extra_cflags="-falign-loops=16 -shared-libgcc $extra_cflags" - fi _timer=timer-darwin.c fi @@ -1304,9 +1346,7 @@ extra_ldflags="$extra_ldflags -lC" fi -if irix ; then - _ranlib='ar -r' -elif linux ; then +if linux ; then _ranlib='true' fi @@ -1325,6 +1365,7 @@ if mingw32 ; then _getch=getch2-win.c need_shmem=no + extra_cflags="$extra_cflags -D__USE_MINGW_ANSI_STDIO=1" fi if amigaos ; then @@ -1339,34 +1380,12 @@ extra_ldflags="$extra_ldflags -lph" fi -if os2 ; then - _exesuf=".exe" - _getch=getch2-os2.c - need_shmem=no - _priority=yes - def_dos_paths="#define HAVE_DOS_PATHS 1" - def_priority="#define CONFIG_PRIORITY 1" -fi - -for tmpdir in "$TMPDIR" "$TEMPDIR" "/tmp" ; do - test "$tmpdir" && break -done - -mplayer_tmpdir="$tmpdir/mplayer-configure-$RANDOM-$$" -mkdir $mplayer_tmpdir || die "Unable to create tmpdir." - -TMPLOG="config.log" TMPC="$mplayer_tmpdir/tmp.c" TMPCPP="$mplayer_tmpdir/tmp.cpp" TMPEXE="$mplayer_tmpdir/tmp$_exesuf" TMPH="$mplayer_tmpdir/tmp.h" TMPS="$mplayer_tmpdir/tmp.S" -rm -f "$TMPLOG" -echo configuration: $configuration > "$TMPLOG" -echo >> "$TMPLOG" - - if test "$_runtime_cpudetection" = yes && ! x86 && ! ppc; then die "Runtime CPU detection only works for x86, x86-64 and PPC!" fi @@ -1452,27 +1471,13 @@ cc_check && host_arch=x86_64 || host_arch=i386 fi -echo "Detected operating system: $system_name" -echo "Detected host architecture: $host_arch" - -echocheck "cross compilation" -if test $_cross_compile = auto ; then - _cross_compile=yes - cflag_check "" && "$TMPEXE" && _cross_compile=no -fi -echores $_cross_compile - -if test $_cross_compile = yes; then - tmp_run() { - return 0 - } - test "$_host_cc" || _host_cc=cc -fi - echocheck "host cc" test "$_host_cc" || _host_cc=$_cc echores $_host_cc +echo "Detected operating system: $system_name" +echo "Detected host architecture: $host_arch" + # --- # now that we know what compiler should be used for compilation, try to find @@ -1525,8 +1530,7 @@ exts=$($_cpuinfo | egrep 'features|flags' | cut -d ':' -f 2 | head -n 1) - pparam=$(echo $exts | sed -e s/k6_mtrr/mtrr/ -e s/cyrix_arr/mtrr/ -e s/centaur_mcr/mtrr/ \ - -e s/xmm/sse/ -e s/kni/sse/) + pparam=$(echo $exts | sed -e s/xmm/sse/ -e s/kni/sse/) # SSE implies MMX2, but not all SSE processors report the mmxext CPU flag. pparam=$(echo $pparam | sed -e 's/sse/sse mmxext/') @@ -1582,13 +1586,6 @@ extcheck $_ssse3 "ssse3" "pabsd %%xmm0, %%xmm0" extcheck $_cmov "cmov" "cmovb %%eax, %%ebx" - echocheck "mtrr support" - if test "$_mtrr" = kernel_check ; then - _mtrr="yes" - _optimizing="$_optimizing mtrr" - fi - echores "$_mtrr" - if test "$_gcc3_ext" != ""; then # if we had to disable sse/sse2 because the active kernel does not # support this instruction set extension, we also have to tell @@ -2151,24 +2148,6 @@ arch='mips' iproc='mips' - if irix ; then - echocheck "CPU type" - proc=$(hinv -c processor | grep CPU | cut -d " " -f3) - case "$(echo $proc)" in - R3000) _march='-mips1' _mcpu='-mtune=r2000' ;; - R4000) _march='-mips3' _mcpu='-mtune=r4000' ;; - R4400) _march='-mips3' _mcpu='-mtune=r4400' ;; - R4600) _march='-mips3' _mcpu='-mtune=r4600' ;; - R5000) _march='-mips4' _mcpu='-mtune=r5000' ;; - R8000|R10000|R12000|R14000|R16000) _march='-mips4' _mcpu='-mtune=r8000' ;; - esac - # gcc < 3.x does not support -mtune. - if test "$cc_vendor" = "gnu" && test "$_cc_major" -lt 3 ; then - _mcpu='' - fi - echores "$proc" - fi - test $_fast_clz = "auto" && _fast_clz=yes ;; @@ -2220,7 +2199,6 @@ test "$_sse" != no && _sse=yes test "$_sse2" != no && _sse2=yes test "$_ssse3" != no && _ssse3=yes - test "$_mtrr" != no && _mtrr=yes fi if ppc; then _altivec=yes @@ -2298,23 +2276,22 @@ # Checking for CFLAGS _install_strip="-s" if test "$_profile" != "" || test "$_debug" != "" ; then - CFLAGS="-O2 $_march $_mcpu $_pipe $_debug $_profile" - WARNFLAGS="-W -Wall" _install_strip= -elif test -z "$CFLAGS" ; then +fi +if test -z "$CFLAGS" ; then if test "$cc_vendor" = "intel" ; then - CFLAGS="-O2 $_march $_mcpu $_pipe -fomit-frame-pointer" + CFLAGS="-O2 $_debug $_profile $_march $_mcpu $_pipe -fomit-frame-pointer" WARNFLAGS="-wd167 -wd556 -wd144" elif test "$cc_vendor" = "sun" ; then - CFLAGS="-O2 $_march $_mcpu $_pipe -xc99 -xregs=frameptr" + CFLAGS="-O2 $_debug $_profile $_march $_mcpu $_pipe -xc99 -xregs=frameptr" elif test "$cc_vendor" = "clang"; then - CFLAGS="-O2 $_march $_pipe" + CFLAGS="-O2 $_debug $_profile $_march $_pipe" WARNFLAGS="-Wall -Wno-switch-enum -Wno-logical-op-parentheses -Wpointer-arith -Wundef -Wno-pointer-sign -Wmissing-prototypes" ERRORFLAGS="-Werror=implicit-function-declaration" elif test "$cc_vendor" != "gnu" ; then - CFLAGS="-O2 $_march $_mcpu $_pipe" + CFLAGS="-O2 $_debug $_profile $_march $_mcpu $_pipe" else - CFLAGS="-O2 $_march $_mcpu $_pipe -ffast-math -fomit-frame-pointer" + CFLAGS="-O2 $_debug $_profile $_march $_mcpu $_pipe -ffast-math -fomit-frame-pointer" WARNFLAGS="-Wall -Wno-switch -Wno-parentheses -Wpointer-arith -Wredundant-decls" ERRORFLAGS="-Werror-implicit-function-declaration" extra_ldflags="$extra_ldflags -ffast-math" @@ -2323,6 +2300,10 @@ warn_cflags=yes fi +if darwin && test "$cc_vendor" = "gnu" ; then + extra_cflags="-falign-loops=16 -shared-libgcc $extra_cflags" +fi + if test "$cc_vendor" = "gnu" ; then cflag_check -Wundef && WARNFLAGS="-Wundef $WARNFLAGS" # -std=gnu99 is not a warning flag but is placed in WARN_CFLAGS because @@ -3069,7 +3050,6 @@ def_mman_h='#define HAVE_SYS_MMAN_H 1' else def_mman_h='#undef HAVE_SYS_MMAN_H' - os2 && need_mmap=yes fi echores "$_mman" @@ -3446,8 +3426,7 @@ EOF _posix_select=no def_posix_select='#undef HAVE_POSIX_SELECT' -#select() of kLIBC (OS/2) supports socket only -! os2 && cc_check && _posix_select=yes && +cc_check && _posix_select=yes && def_posix_select='#define HAVE_POSIX_SELECT 1' echores "$_posix_select" @@ -3541,7 +3520,7 @@ def_macosx_finder='#undef CONFIG_MACOSX_FINDER' if test "$_macosx_finder" = yes ; then def_macosx_finder='#define CONFIG_MACOSX_FINDER 1' - extra_ldflags="$extra_ldflags -framework Carbon" + extra_ldflags="$extra_ldflags -framework Cocoa" fi echores "$_macosx_finder" @@ -3550,7 +3529,6 @@ test "$_macosx_bundle" = auto && _macosx_bundle=$_macosx_finder if test "$_macosx_bundle" = yes ; then def_macosx_bundle='#define CONFIG_MACOSX_BUNDLE 1' - extra_ldflags="$extra_ldflags -framework Carbon" fi echores "$_macosx_bundle" @@ -3609,7 +3587,6 @@ fi #if linux echocheck "pkg-config" -_pkg_config=pkg-config if $($_pkg_config --version > /dev/null 2>&1); then if test "$_ld_static"; then _pkg_config="$_pkg_config --static" @@ -3785,6 +3762,87 @@ echores "$_directfb" +if darwin; then + +echocheck "QuickTime" +if test "$quicktime" = auto ; then + quicktime=no + statement_check QuickTime/QuickTime.h 'ImageDescription *desc; EnterMovies(); ExitMovies()' -framework QuickTime && quicktime=yes +fi +if test "$quicktime" = yes ; then + extra_ldflags="$extra_ldflags -framework QuickTime" + def_quicktime='#define CONFIG_QUICKTIME 1' +else + def_quicktime='#undef CONFIG_QUICKTIME' +fi +echores $quicktime + +echocheck "Cocoa" +if test "$_cocoa" = auto ; then + cat > $TMPC < +#include +int main(void) { + NSApplicationLoad(); +} +EOF + _cocoa=no + cc_check -framework Cocoa -framework OpenGL && _cocoa=yes +fi +if test "$_cocoa" = yes ; then + libs_mplayer="$libs_mplayer -framework Cocoa -framework OpenGL" + def_cocoa='#define CONFIG_COCOA 1' +else + def_cocoa='#undef CONFIG_COCOA' +fi +echores "$_cocoa" + +echocheck "CoreVideo" +if test "$_cocoa" = yes && test "$_corevideo" = auto ; then + cat > $TMPC < +int main(void) { return 0; } +EOF + _corevideo=no + cc_check -framework Cocoa -framework QuartzCore -framework OpenGL && _corevideo=yes +fi +if test "$_corevideo" = yes ; then + vomodules="corevideo $vomodules" + libs_mplayer="$libs_mplayer -framework QuartzCore" + def_corevideo='#define CONFIG_COREVIDEO 1' +else + novomodules="corevideo $novomodules" + def_corevideo='#undef CONFIG_COREVIDEO' +fi +echores "$_corevideo" + +echocheck "SharedBuffer" +if test "$_sharedbuffer" = auto ; then + cat > $TMPC <= 0.2' && _vdpau=yes fi fi if test "$_vdpau" = yes ; then def_vdpau='#define CONFIG_VDPAU 1' - libs_mplayer="$libs_mplayer -lvdpau" vomodules="vdpau $vomodules" else def_vdpau='#define CONFIG_VDPAU 0' @@ -4165,90 +4235,9 @@ fi -if darwin; then - -echocheck "QuickTime" -if test "$quicktime" = auto ; then - quicktime=no - statement_check QuickTime/QuickTime.h 'ImageDescription *desc; EnterMovies(); ExitMovies()' -framework QuickTime && quicktime=yes -fi -if test "$quicktime" = yes ; then - extra_ldflags="$extra_ldflags -framework QuickTime" - def_quicktime='#define CONFIG_QUICKTIME 1' -else - def_quicktime='#undef CONFIG_QUICKTIME' - _quartz=no -fi -echores $quicktime - -echocheck "Quartz" -if test "$_quartz" = auto ; then - _quartz=no - statement_check Carbon/Carbon.h 'CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, false)' -framework Carbon && _quartz=yes -fi -if test "$_quartz" = yes ; then - libs_mplayer="$libs_mplayer -framework Carbon" - def_quartz='#define CONFIG_QUARTZ 1' - vomodules="quartz $vomodules" -else - def_quartz='#undef CONFIG_QUARTZ' - novomodules="quartz $novomodules" -fi -echores $_quartz - -echocheck "CoreVideo" -if test "$_corevideo" = auto ; then - cat > $TMPC < -#include -#include -#include -int main(void) { return 0; } -EOF - _corevideo=no - cc_check -framework Carbon -framework Cocoa -framework QuartzCore -framework OpenGL && _corevideo=yes -fi -if test "$_corevideo" = yes ; then - vomodules="corevideo $vomodules" - libs_mplayer="$libs_mplayer -framework Carbon -framework Cocoa -framework QuartzCore -framework OpenGL" - def_corevideo='#define CONFIG_COREVIDEO 1' -else - novomodules="corevideo $novomodules" - def_corevideo='#undef CONFIG_COREVIDEO' -fi -echores "$_corevideo" - -echocheck "Cocoa" -if test "$_gl" = no ; then - # if _gl is not enabled there is no point to add potentially unused linker flags - _cocoa=no -fi -if test "$_cocoa" = auto ; then - cat > $TMPC < -#include -#include -int main(void) { return 0; } -EOF - _cocoa=no - cc_check -framework Cocoa -framework QuartzCore -framework OpenGL && _cocoa=yes -fi -if test "$_cocoa" = yes ; then - libs_mplayer="$libs_mplayer -framework Cocoa -framework QuartzCore -framework OpenGL" -fi -echores "$_cocoa" - -fi #if darwin - - echocheck "PNG support" if test "$_png" = auto ; then _png=no - if irix ; then - # Don't check for -lpng on irix since it has its own libpng - # incompatible with the GNU libpng - res_comment="disabled on irix (not GNU libpng)" - else cat > $TMPC << EOF #include #include @@ -4259,8 +4248,7 @@ return strcmp(PNG_LIBPNG_VER_STRING, png_libpng_ver); } EOF - cc_check -lpng -lz $_ld_lm && _png=yes - fi + cc_check -lpng -lz $_ld_lm && _png=yes fi echores "$_png" if test "$_png" = yes ; then @@ -4531,15 +4519,17 @@ } EOF _gl=no - for _ld_tmp in "" -lGL "-lGL -lXdamage" "-lGL $_ld_pthread" ; do - if cc_check $_ld_tmp $_ld_lm ; then - _gl=yes - _gl_x11=yes - libs_mplayer="$libs_mplayer $_ld_tmp $_ld_dl" - break - fi - done - if cc_check -DGL_WIN32 -lopengl32 ; then + if test "$_x11" = yes ; then + for _ld_tmp in "" -lGL "-lGL -lXdamage" "-lGL $_ld_pthread" ; do + if cc_check $_ld_tmp $_ld_lm ; then + _gl=yes + _gl_x11=yes + libs_mplayer="$libs_mplayer $_ld_tmp $_ld_dl" + break + fi + done + fi + if win32 && cc_check -DGL_WIN32 -lopengl32 ; then _gl=yes _gl_win32=yes libs_mplayer="$libs_mplayer -lopengl32 -lgdi32" @@ -4595,24 +4585,6 @@ echores "$_gl" -if os2 ; then -echocheck "KVA (SNAP/WarpOverlay!/DIVE)" -if test "$_kva" = auto; then - _kva=no; - header_check_broken os2.h kva.h -lkva && _kva=yes -fi -if test "$_kva" = yes ; then - def_kva='#define CONFIG_KVA 1' - libs_mplayer="$libs_mplayer -lkva" - vomodules="kva $vomodules" -else - def_kva='#undef CONFIG_KVA' - novomodules="kva $novomodules" -fi -echores "$_kva" -fi #if os2 - - if win32; then echocheck "Windows waveout" @@ -4794,51 +4766,6 @@ echores "$_ossaudio" -echocheck "aRts" -if test "$_arts" = auto ; then - _arts=no - if ( artsc-config --version ) >> "$TMPLOG" 2>&1 ; then - statement_check artsc.h 'arts_init()' $(artsc-config --libs) $(artsc-config --cflags) && - _arts=yes - fi -fi - -if test "$_arts" = yes ; then - def_arts='#define CONFIG_ARTS 1' - aomodules="arts $aomodules" - libs_mplayer="$libs_mplayer $(artsc-config --libs)" - extra_cflags="$extra_cflags $(artsc-config --cflags)" -else - noaomodules="arts $noaomodules" -fi -echores "$_arts" - - -echocheck "EsounD" -if test "$_esd" = auto ; then - _esd=no - if ( esd-config --version ) >> "$TMPLOG" 2>&1 ; then - statement_check esd.h 'esd_open_sound("test")' $(esd-config --libs) $(esd-config --cflags) && _esd=yes - fi -fi -echores "$_esd" - -if test "$_esd" = yes ; then - def_esd='#define CONFIG_ESD 1' - aomodules="esd $aomodules" - libs_mplayer="$libs_mplayer $(esd-config --libs)" - extra_cflags="$extra_cflags $(esd-config --cflags)" - - echocheck "esd_get_latency()" - statement_check esd.h 'esd_get_latency(0)' $(esd-config --libs) $(esd-config --cflags) && - _esd_latency=yes && def_esd_latency='#define CONFIG_ESD_LATENCY 1' - echores "$_esd_latency" -else - def_esd='#undef CONFIG_ESD' - def_esd_latency='#undef CONFIG_ESD_LATENCY' - noaomodules="esd $noaomodules" -fi - echocheck "RSound" if test "$_rsound" = auto ; then _rsound=no @@ -4875,8 +4802,7 @@ echocheck "pulse" if test "$_pulse" = auto ; then _pulse=no - if $_pkg_config --exists 'libpulse >= 0.9' ; then - header_check pulse/pulseaudio.h $($_pkg_config --libs --cflags libpulse) && + if pkg_config_add 'libpulse >= 0.9' ; then _pulse=yes fi fi @@ -4885,24 +4811,39 @@ if test "$_pulse" = yes ; then def_pulse='#define CONFIG_PULSE 1' aomodules="pulse $aomodules" - libs_mplayer="$libs_mplayer $($_pkg_config --libs libpulse)" - extra_cflags="$extra_cflags $($_pkg_config --cflags libpulse)" else def_pulse='#undef CONFIG_PULSE' noaomodules="pulse $noaomodules" fi +echocheck "PortAudio" +if test "$_portaudio" = auto && test "$_pthreads" != yes ; then + _portaudio=no + res_comment="pthreads not enabled" +fi +if test "$_portaudio" = auto ; then + _portaudio=no + if pkg_config_add 'portaudio-2.0 >= 19' ; then + _portaudio=yes + fi +fi +echores "$_portaudio" + +if test "$_portaudio" = yes ; then + def_portaudio='#define CONFIG_PORTAUDIO 1' + aomodules="portaudio $aomodules" +else + def_portaudio='#undef CONFIG_PORTAUDIO' + noaomodules="portaudio $noaomodules" +fi + + echocheck "JACK" if test "$_jack" = auto ; then - _jack=yes - if statement_check jack/jack.h 'jack_client_open("test", JackUseExactName, NULL)' -ljack ; then - libs_mplayer="$libs_mplayer -ljack" - elif statement_check jack/jack.h 'jack_client_open("test", JackUseExactName, NULL)' $($_pkg_config --libs --cflags --silence-errors jack) ; then - libs_mplayer="$libs_mplayer $($_pkg_config --libs jack)" - extra_cflags="$extra_cflags "$($_pkg_config --cflags jack)"" - else - _jack=no + _jack=no + if pkg_config_add jack ; then + _jack=yes fi fi @@ -4948,100 +4889,18 @@ _alsa=no res_comment="alloca missing" fi -if test "$_alsa" != no ; then - _alsa=no - cat > $TMPC << EOF -#include -#if !((SND_LIB_MAJOR == 0) && (SND_LIB_MINOR == 5)) -#error "alsa version != 0.5.x" -#endif -int main(void) { return 0; } -EOF - cc_check -lasound $_ld_dl $_ld_pthread && _alsaver='0.5.x' - - cat > $TMPC << EOF -#include -#if !((SND_LIB_MAJOR == 0) && (SND_LIB_MINOR == 9)) -#error "alsa version != 0.9.x" -#endif -int main(void) { return 0; } -EOF - cc_check -lasound $_ld_dl $_ld_pthread && _alsaver='0.9.x-sys' - cat > $TMPC << EOF -#include -#if !((SND_LIB_MAJOR == 0) && (SND_LIB_MINOR == 9)) -#error "alsa version != 0.9.x" -#endif -int main(void) { return 0; } -EOF - cc_check -lasound $_ld_dl $_ld_pthread && _alsaver='0.9.x-alsa' - - cat > $TMPC << EOF -#include -#if !((SND_LIB_MAJOR == 1) && (SND_LIB_MINOR == 0)) -#error "alsa version != 1.0.x" -#endif -int main(void) { return 0; } -EOF - cc_check -lasound $_ld_dl $_ld_pthread && _alsaver='1.0.x-sys' - cat > $TMPC << EOF -#include -#if !((SND_LIB_MAJOR == 1) && (SND_LIB_MINOR == 0)) -#error "alsa version != 1.0.x" -#endif -int main(void) { return 0; } -EOF - cc_check -lasound $_ld_dl $_ld_pthread && _alsaver='1.0.x-alsa' +if test "$_alsa" = auto ; then + _alsa=no + if pkg_config_add "alsa >= 1.0.9" ; then + _alsa=yes + fi fi def_alsa='#undef CONFIG_ALSA' -def_alsa5='#undef CONFIG_ALSA5' -def_alsa9='#undef CONFIG_ALSA9' -def_alsa1x='#undef CONFIG_ALSA1X' -def_sys_asoundlib_h='#undef HAVE_SYS_ASOUNDLIB_H' -def_alsa_asoundlib_h='#undef HAVE_ALSA_ASOUNDLIB_H' -if test "$_alsaver" ; then - _alsa=yes - if test "$_alsaver" = '0.5.x' ; then - _alsa5=yes - aomodules="alsa5 $aomodules" - def_alsa5='#define CONFIG_ALSA5 1' - def_sys_asoundlib_h='#define HAVE_SYS_ASOUNDLIB_H 1' - res_comment="using alsa 0.5.x and sys/asoundlib.h" - elif test "$_alsaver" = '0.9.x-sys' ; then - _alsa9=yes - aomodules="alsa $aomodules" - def_alsa='#define CONFIG_ALSA 1' - def_alsa9='#define CONFIG_ALSA9 1' - def_sys_asoundlib_h='#define HAVE_SYS_ASOUNDLIB_H 1' - res_comment="using alsa 0.9.x and sys/asoundlib.h" - elif test "$_alsaver" = '0.9.x-alsa' ; then - _alsa9=yes +if test "$_alsa" = yes ; then aomodules="alsa $aomodules" def_alsa='#define CONFIG_ALSA 1' - def_alsa9='#define CONFIG_ALSA9 1' - def_alsa_asoundlib_h='#define HAVE_ALSA_ASOUNDLIB_H 1' - res_comment="using alsa 0.9.x and alsa/asoundlib.h" - elif test "$_alsaver" = '1.0.x-sys' ; then - _alsa1x=yes - aomodules="alsa $aomodules" - def_alsa='#define CONFIG_ALSA 1' - def_alsa1x="#define CONFIG_ALSA1X 1" - def_alsa_asoundlib_h='#define HAVE_SYS_ASOUNDLIB_H 1' - res_comment="using alsa 1.0.x and sys/asoundlib.h" - elif test "$_alsaver" = '1.0.x-alsa' ; then - _alsa1x=yes - aomodules="alsa $aomodules" - def_alsa='#define CONFIG_ALSA 1' - def_alsa1x="#define CONFIG_ALSA1X 1" - def_alsa_asoundlib_h='#define HAVE_ALSA_ASOUNDLIB_H 1' - res_comment="using alsa 1.0.x and alsa/asoundlib.h" - else - _alsa=no - res_comment="unknown version" - fi - extra_ldflags="$extra_ldflags -lasound $_ld_dl $_ld_pthread" else - noaomodules="alsa $noaomodules" + noaomodules="alsa $noaomodules" fi echores "$_alsa" @@ -5090,59 +4949,8 @@ fi #if darwin -if irix; then -echocheck "SGI audio" -if test "$_sgiaudio" = auto ; then - _sgiaudio=no - header_check dmedia/audio.h && _sgiaudio=yes -fi -if test "$_sgiaudio" = "yes" ; then - def_sgiaudio='#define CONFIG_SGI_AUDIO 1' - libs_mplayer="$libs_mplayer -laudio" - aomodules="sgi $aomodules" -else - def_sgiaudio='#undef CONFIG_SGI_AUDIO' - noaomodules="sgi $noaomodules" -fi -echores "$_sgiaudio" -fi #if irix - - -if os2 ; then -echocheck "KAI (UNIAUD/DART)" -if test "$_kai" = auto; then - _kai=no; - header_check_broken os2.h kai.h -lkai && _kai=yes -fi -if test "$_kai" = yes ; then - def_kai='#define CONFIG_KAI 1' - libs_mplayer="$libs_mplayer -lkai" - aomodules="kai $aomodules" -else - def_kai='#undef CONFIG_KAI' - noaomodules="kai $noaomodules" -fi -echores "$_kai" - -echocheck "DART" -if test "$_dart" = auto; then - _dart=no; - header_check_broken os2.h dart.h -ldart && _dart=yes -fi -if test "$_dart" = yes ; then - def_dart='#define CONFIG_DART 1' - libs_mplayer="$libs_mplayer -ldart" - aomodules="dart $aomodules" -else - def_dart='#undef CONFIG_DART' - noaomodules="dart $noaomodules" -fi -echores "$_dart" -fi #if os2 - - # set default CD/DVD devices -if win32 || os2 ; then +if win32 ; then default_cdrom_device="D:" elif darwin ; then default_cdrom_device="/dev/disk1" @@ -5163,7 +4971,7 @@ default_cdrom_device="/dev/cdrom" fi -if win32 || os2 || dragonfly || freebsd || openbsd || sunos || amigaos ; then +if win32 || dragonfly || freebsd || openbsd || sunos || amigaos ; then default_dvd_device=$default_cdrom_device elif darwin ; then default_dvd_device="/dev/rdiskN" @@ -5175,7 +4983,7 @@ echocheck "VCD support" if test "$_vcd" = auto; then _vcd=no - if linux || freebsd || netbsd || openbsd || dragonfly || bsdos || darwin || sunos || os2; then + if linux || freebsd || netbsd || openbsd || dragonfly || bsdos || darwin || sunos; then _vcd=yes elif mingw32; then header_check ddk/ntddcdrm.h && _vcd=yes @@ -5196,11 +5004,10 @@ echocheck "Blu-ray support" if test "$_bluray" = auto ; then _bluray=no - statement_check libbluray/bluray.h 'bd_get_title_info(0, 0, 0)' -lbluray && _bluray=yes + pkg_config_add 'libbluray >= 0.2.1' && _bluray=yes fi if test "$_bluray" = yes ; then def_bluray='#define CONFIG_LIBBLURAY 1' - extra_ldflags="$extra_ldflags -lbluray" inputmodules="bluray $inputmodules" else def_bluray='#undef CONFIG_LIBBLURAY' @@ -5218,7 +5025,7 @@ if (linux || freebsd || netbsd || openbsd || dragonfly || sunos || hpux) && (test "$_dvd" = yes || test "$_cdrom" = yes || test "$_cdio" = yes || test "$_dvdio" = yes || test "$_bsdi_dvd" = yes) || - darwin || win32 || os2; then + darwin || win32; then _dvdread_internal=yes _dvdread=yes extra_cflags="-Ilibdvdread4 $extra_cflags" @@ -5272,8 +5079,6 @@ cflags_libdvdcss="-DSYS_CYGWIN -DWIN32" elif beos ; then cflags_libdvdcss="-DSYS_BEOS" - elif os2 ; then - cflags_libdvdcss="-DSYS_OS2" fi cflags_libdvdcss_dvdread="-Ilibdvdcss" def_dvdcss="#define HAVE_DVDCSS_DVDCSS_H 1" @@ -5284,76 +5089,25 @@ echores "$_libdvdcss_internal" -echocheck "cdparanoia" -if test "$_cdparanoia" = auto ; then - cat > $TMPC < -#include -// This need a better test. How ? -int main(void) { void *test = cdda_verbose_set; return test == (void *)1; } -EOF - _cdparanoia=no - for _inc_tmp in "" "-I/usr/include/cdda" "-I/usr/local/include/cdda" ; do - cc_check $_inc_tmp -lcdda_interface -lcdda_paranoia $_ld_lm && - _cdparanoia=yes && extra_cflags="$extra_cflags $_inc_tmp" && break - done -fi -if test "$_cdparanoia" = yes ; then - _cdda='yes' - extra_ldflags="$extra_ldflags -lcdda_interface -lcdda_paranoia" - openbsd && extra_ldflags="$extra_ldflags -lutil" -fi -echores "$_cdparanoia" - - echocheck "libcdio" -if test "$_libcdio" = auto && test "$_cdparanoia" = no ; then - cat > $TMPC << EOF -#include -#include -#include -#include -int main(void) { - void *test = cdda_verbose_set; - printf("%s\n", CDIO_VERSION); - return test == (void *)1; -} -EOF - _libcdio=no - for _ld_tmp in "" "-lwinmm" ; do - _ld_tmp="-lcdio_cdda -lcdio -lcdio_paranoia $_ld_tmp" - cc_check $_ld_tmp $_ld_lm && _libcdio=yes && - extra_ldflags="$extra_ldflags $_ld_tmp" && break - done - if test "$_libcdio" = no && $_pkg_config --exists libcdio_paranoia ; then - _inc_tmp=$($_pkg_config --cflags libcdio_paranoia) - _ld_tmp=$($_pkg_config --libs libcdio_paranoia) - cc_check $_inc_tmp $_ld_tmp $_ld_lm && _libcdio=yes && - extra_ldflags="$extra_ldflags $_ld_tmp" && extra_cflags="$extra_cflags $_inc_tmp" - fi -fi -if test "$_libcdio" = yes && test "$_cdparanoia" = no ; then - _cdda='yes' - def_libcdio='#define CONFIG_LIBCDIO 1' - def_havelibcdio='yes' -else +if test "$_libcdio" = auto ; then _libcdio=no - if test "$_cdparanoia" = yes ; then - res_comment="using cdparanoia" + if pkg_config_add libcdio_paranoia ; then + _libcdio=yes fi - def_libcdio='#undef CONFIG_LIBCDIO' - def_havelibcdio='no' fi -echores "$_libcdio" - -if test "$_cdda" = yes ; then +if test "$_libcdio" = yes ; then + _cdda='yes' + def_cdda='#define CONFIG_CDDA 1' test $_cddb = auto && test $networking = yes && _cddb=yes - def_cdparanoia='#define CONFIG_CDDA 1' inputmodules="cdda $inputmodules" else - def_cdparanoia='#undef CONFIG_CDDA' + _libcdio=no + _cdda='no' + def_cdda='#undef CONFIG_CDDA' noinputmodules="cdda $noinputmodules" fi +echores "$_libcdio" if test "$_cddb" = yes ; then def_cddb='#define CONFIG_CDDB 1' @@ -5382,33 +5136,14 @@ fi if test "$_freetype" = auto ; then - if ( $_freetypeconfig --version ) >/dev/null 2>&1 ; then - cat > $TMPC << EOF -#include -#include -#include FT_FREETYPE_H -#if ((FREETYPE_MAJOR < 2) || ((FREETYPE_MINOR == 0) && (FREETYPE_PATCH < 9))) -#error "Need FreeType 2.0.9 or newer" -#endif -int main(void) { - FT_Library library; - FT_Init_FreeType(&library); - return 0; -} -EOF - _freetype=no - cc_check $($_freetypeconfig --cflags) $($_freetypeconfig --libs) && _freetype=yes + if pkg_config_add freetype2 ; then + _freetype=yes else - _freetype=no - fi - if test "$_freetype" != yes ; then - die "Unable to find development files for libfreetype. Aborting. If you really mean to compile without FreeType support use --disable-freetype." + die "Unable to find development files for libfreetype. Aborting. If you really mean to compile without FreeType support use --disable-freetype." fi fi if test "$_freetype" = yes ; then def_freetype='#define CONFIG_FREETYPE 1' - extra_cflags="$extra_cflags $($_freetypeconfig --cflags)" - extra_ldflags="$extra_ldflags $($_freetypeconfig --libs)" else def_freetype='#undef CONFIG_FREETYPE' fi @@ -5420,36 +5155,11 @@ fi echocheck "fontconfig" if test "$_fontconfig" = auto ; then - cat > $TMPC << EOF -#include -#include -#include -#if FC_VERSION < 20402 -#error At least version 2.4.2 of fontconfig required -#endif -int main(void) { - int err = FcInit(); - if (err == FcFalse) { - printf("Couldn't initialize fontconfig lib\n"); - exit(err); - } - return 0; -} -EOF - _fontconfig=no - for _ld_tmp in "" "-lexpat -lfreetype" "-lexpat -lfreetype -lz" "-lexpat -lfreetype -lz -liconv" ; do - _ld_tmp="-lfontconfig $_ld_tmp" - cc_check $_ld_tmp && _fontconfig=yes && extra_ldflags="$extra_ldflags $_ld_tmp" && break - done - if test "$_fontconfig" = no && $_pkg_config --exists fontconfig ; then - _inc_tmp=$($_pkg_config --cflags fontconfig) - _ld_tmp=$($_pkg_config --libs fontconfig) - cc_check $_inc_tmp $_ld_tmp && _fontconfig=yes && - extra_ldflags="$extra_ldflags $_ld_tmp" && extra_cflags="$extra_cflags $_inc_tmp" - fi - if test "$_fontconfig" != yes ; then - die "Unable to find development files for libfontconfig. Aborting. If you really mean to compile without fontconfig support use --disable-fontconfig." - fi + if pkg_config_add 'fontconfig >= 2.4.2' ; then + _fontconfig=yes + else + die "Unable to find development files for libfontconfig. Aborting. If you really mean to compile without fontconfig support use --disable-fontconfig." + fi fi if test "$_fontconfig" = yes ; then def_fontconfig='#define CONFIG_FONTCONFIG 1' @@ -5460,15 +5170,13 @@ echocheck "SSA/ASS support" -if test "$_ass" = auto -o "$_ass" = yes ; then - if $_pkg_config libass; then - _ass=yes - def_ass='#define CONFIG_ASS 1' - extra_ldflags="$extra_ldflags $($_pkg_config --libs libass)" - extra_cflags="$extra_cflags $($_pkg_config --cflags libass)" - else - die "Unable to find development files for libass. Aborting. If you really mean to compile without libass support use --disable-libass." - fi +if test "$_ass" = auto ; then + if pkg_config_add libass ; then + _ass=yes + def_ass='#define CONFIG_ASS 1' + else + die "Unable to find development files for libass. Aborting. If you really mean to compile without libass support use --disable-libass." + fi else def_ass='#undef CONFIG_ASS' fi @@ -5476,35 +5184,14 @@ echocheck "fribidi with charsets" -_inc_tmp="" -_ld_tmp="" if test "$_fribidi" = auto ; then - cat > $TMPC << EOF -#include -/* workaround for fribidi 0.10.4 and below */ -#define FRIBIDI_CHARSET_UTF8 FRIBIDI_CHAR_SET_UTF8 -#include -int main(void) { - if (fribidi_parse_charset("UTF-8") != FRIBIDI_CHAR_SET_UTF8) - exit(1); - return 0; -} -EOF _fribidi=no - _inc_tmp="" - _ld_tmp="-lfribidi" - cc_check $_inc_tmp $_ld_tmp && _fribidi=yes - if $_pkg_config --exists fribidi > /dev/null 2>&1 && - test "$_fribidi" = no ; then - _inc_tmp="$($_pkg_config --cflags)" - _ld_tmp="$($_pkg_config --libs)" - cc_check $_inc_tmp $_ld_tmp && _fribidi=yes + if pkg_config_add fribidi ; then + _fribidi=yes fi fi if test "$_fribidi" = yes ; then def_fribidi='#define CONFIG_FRIBIDI 1' - extra_cflags="$extra_cflags $_inc_tmp" - extra_ldflags="$extra_ldflags $_ld_tmp" else def_fribidi='#undef CONFIG_FRIBIDI' fi @@ -5629,65 +5316,26 @@ echocheck "OggTheora support" if test "$_theora" = auto ; then _theora=no - cat > $TMPC << EOF -#include -#include -int main(void) { - /* Theora is in flux, make sure that all interface routines and datatypes - * exist and work the way we expect it, so we don't break MPlayer. */ - ogg_packet op; - theora_comment tc; - theora_info inf; - theora_state st; - yuv_buffer yuv; - int r; - double t; - - theora_info_init(&inf); - theora_comment_init(&tc); - - return 0; - - /* we don't want to execute this kind of nonsense; just for making sure - * that compilation works... */ - memset(&op, 0, sizeof(op)); - r = theora_decode_header(&inf, &tc, &op); - r = theora_decode_init(&st, &inf); - t = theora_granule_time(&st, op.granulepos); - r = theora_decode_packetin(&st, &op); - r = theora_decode_YUVout(&st, &yuv); - theora_clear(&st); - - return 0; -} -EOF - _ld_theora=$($_pkg_config --silence-errors --libs theora) - _inc_theora=$($_pkg_config --silence-errors --cflags theora) - cc_check $_inc_theora $_ld_theora && extra_ldflags="$extra_ldflags $_ld_theora" && - extra_cflags="$extra_cflags $_inc_theora" && _theora=yes - if test _theora = no; then - _ld_theora="-ltheora -logg" - cc_check $_ld_theora && extra_ldflags="$extra_ldflags $_ld_theora" && _theora=yes + if pkg_config_add theora ; then + _theora=yes fi fi if test "$_theora" = yes ; then def_theora='#define CONFIG_OGGTHEORA 1' codecmodules="libtheora $codecmodules" - # when --enable-theora is forced, we'd better provide a probably sane - # $_ld_theora than nothing - test -z "$_ld_theora" && extra_ldflags="$extra_ldflags -ltheora -logg" else def_theora='#undef CONFIG_OGGTHEORA' nocodecmodules="libtheora $nocodecmodules" fi echores "$_theora" -# Any version of libmpg123 shall be fine. +# Any version of libmpg123 that knows MPG123_RESYNC_LIMIT shall be fine. +# That is, 1.2.0 onwards. Recommened is 1.14 onwards, though. echocheck "mpg123 support" def_mpg123='#undef CONFIG_MPG123' if test "$_mpg123" = auto; then _mpg123=no - statement_check mpg123.h 'mpg123_init()' -lmpg123 && _mpg123=yes && extra_ldflags="$extra_ldflags -lmpg123" + pkg_config_add 'libmpg123 >= 1.2.0' && _mpg123=yes fi if test "$_mpg123" = yes ; then def_mpg123='#define CONFIG_MPG123 1' @@ -5800,35 +5448,10 @@ echocheck "libbs2b audio filter support" if test "$_libbs2b" = auto ; then - cat > $TMPC < -#if BS2B_VERSION_MAJOR < 3 -#error Please use libbs2b >= 3.0.0, older versions are not supported. -#endif -int main(void) { - t_bs2bdp filter; - filter=bs2b_open(); - bs2b_close(filter); - return 0; -} -EOF - _libbs2b=no - if $_pkg_config --exists libbs2b ; then - _inc_tmp=$($_pkg_config --cflags libbs2b) - _ld_tmp=$($_pkg_config --libs libbs2b) - cc_check $_inc_tmp $_ld_tmp && extra_ldflags="$extra_ldflags $_ld_tmp" && - extra_cflags="$extra_cflags $_inc_tmp" && _libbs2b=yes - else - for _inc_tmp in "" -I/usr/include/bs2b -I/usr/local/include \ - -I/usr/local/include/bs2b ; do - if cc_check $_inc_tmp $_ld_lm -lbs2b ; then - extra_ldflags="$extra_ldflags -lbs2b" - extra_cflags="$extra_cflags $_inc_tmp" + _libbs2b=no + if pkg_config_add libbs2b ; then _libbs2b=yes - break - fi - done - fi + fi fi def_libbs2b="#undef CONFIG_LIBBS2B" test "$_libbs2b" = yes && def_libbs2b="#define CONFIG_LIBBS2B 1" @@ -5847,7 +5470,7 @@ # Fall back on default directory. if test -z "$_codecsdir" ; then _codecsdir="$_libdir/codecs" - mingw32 || os2 && _codecsdir="codecs" + mingw32 && _codecsdir="codecs" fi @@ -5899,7 +5522,7 @@ _real=no res_comment="dynamic loader support needed" if test "$_dl" = yes || test "$_win32dll" = yes && - (linux || freebsd || netbsd || openbsd || dragonfly || darwin || win32 || os2) ; then + (linux || freebsd || netbsd || openbsd || dragonfly || darwin || win32) ; then _real=yes fi fi @@ -5933,9 +5556,7 @@ echocheck "Nemesi Streaming Media libraries" if test "$_nemesi" = auto && test "$networking" = yes ; then _nemesi=no - if $_pkg_config libnemesi --atleast-version=0.6.3 ; then - extra_cflags="$extra_cflags $($_pkg_config --cflags libnemesi)" - extra_ldflags="$extra_ldflags $($_pkg_config --libs libnemesi)" + if pkg_config_add libnemesi ; then _nemesi=yes fi fi @@ -5952,7 +5573,7 @@ echores "$_nemesi" echocheck "LIVE555 Streaming Media libraries" -if test "$_live" = auto && test "$networking" = yes ; then +if test "$_live" != no && test "$networking" = yes ; then cat > $TMPCPP << EOF #include #if (LIVEMEDIA_LIBRARY_VERSION_INT < 1141257600) @@ -6003,17 +5624,13 @@ -all_libav_libs="libavutil >= 51.7.0:libavcodec >= 53.5.0:libavformat >= 53.2.0:libswscale >= 2.0.0:libpostproc >= 52.0.0" +# Test with > against Libav 0.8 versions which will NOT work rather than +# specify minimum version, to allow (future) point releases to possibly work. +all_libav_libs="libavutil > 51.21.0:libavcodec > 53.34.0:libavformat > 53.20.0:libswscale >= 2.0.0" echocheck "Libav ($all_libav_libs)" if test "$ffmpeg" = auto ; then IFS=":" # shell should not be used for programming - if $_pkg_config --exists --print-errors $all_libav_libs ; then - inc_ffmpeg=$($_pkg_config --cflags $all_libav_libs) - _ld_tmp=$($_pkg_config --libs $all_libav_libs) - extra_ldflags="$extra_ldflags $_ld_tmp" - extra_cflags="$extra_cflags $inc_ffmpeg" - unset IFS - else + if ! pkg_config_add $all_libav_libs ; then die "Unable to find development files for some of the required Libav libraries above. Aborting." fi fi @@ -6024,6 +5641,19 @@ def_ffmpeg_internals="#define CONFIG_FFMPEG_INTERNALS 1" && ffmpeg_internals=yes fi +echocheck "libpostproc >= 52.0.0" +if test "$libpostproc" = auto ; then + libpostproc=no + if pkg_config_add "libpostproc >= 52.0.0" ; then + libpostproc=yes + fi +fi +if test "$libpostproc" = yes ; then + def_libpostproc='#define CONFIG_LIBPOSTPROC 1' +else + def_libpostproc='#undef CONFIG_LIBPOSTPROC' +fi +echores "$libpostproc" echocheck "libdv-0.9.5+" @@ -6268,7 +5898,7 @@ if test "$_radio" = yes ; then def_radio='#define CONFIG_RADIO 1' inputmodules="radio $inputmodules" - if test "$_alsa9" != yes -a "$_alsa1x" != yes -a "$_ossaudio" != yes ; then + if test "$_alsa" != yes -a "$_ossaudio" != yes ; then _radio_capture=no fi if test "$_radio_capture" = yes ; then @@ -6467,7 +6097,7 @@ # (FIXME: 'echocheck "dynamic linking"' above and modify here accordingly) _ld_dl_dynamic='' freebsd || netbsd || openbsd || dragonfly || bsdos && _ld_dl_dynamic='-rdynamic' -if test "$_real" = yes || test "$_xanim" = yes && ! win32 && ! qnx && ! darwin && ! os2 && ! sunos; then +if test "$_real" = yes || test "$_xanim" = yes && ! win32 && ! qnx && ! darwin && ! sunos; then _ld_dl_dynamic='-rdynamic' fi @@ -6520,15 +6150,6 @@ ############################################################################# -# On OS/2 nm supports only a.out. So the -Zomf compiler option to generate -# the OMF format needs to come after the 'extern symbol prefix' check, which -# uses nm. -if os2 ; then - extra_ldflags="$extra_ldflags -Zomf -Zstack 16384 -Zbin-files -Zargs-wild" -fi - -############################################################################# - CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE" CXXFLAGS=" $CFLAGS -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS" @@ -6651,7 +6272,6 @@ NEED_GETTIMEOFDAY = $need_gettimeofday NEED_GLOB = $need_glob -NEED_MMAP = $need_mmap NEED_SETENV = $need_setenv NEED_SHMEM = $need_shmem NEED_STRSEP = $need_strsep @@ -6661,21 +6281,19 @@ # features 3DFX = $_3dfx AA = $_aa -ALSA1X = $_alsa1x -ALSA9 = $_alsa9 -ALSA5 = $_alsa5 +ALSA = $_alsa APPLE_IR = $_apple_ir APPLE_REMOTE = $_apple_remote -ARTS = $_arts AUDIO_INPUT = $_audio_input BITMAP_FONT = $_bitmap_font BL = $_bl CACA = $_caca CDDA = $_cdda CDDB = $_cddb +COCOA = $_cocoa COREAUDIO = $_coreaudio COREVIDEO = $_corevideo -DART = $_dart +SHAREDBUFFER = $_sharedbuffer DGA = $_dga DIRECT3D = $_direct3d DIRECTFB = $_directfb @@ -6686,7 +6304,6 @@ DVDREAD = $_dvdread DVDREAD_INTERNAL = $_dvdread_internal DXR3 = $_dxr3 -ESD = $_esd FAAD = $_faad FASTMEMCPY = $_fastmemcpy FBDEV = $_fbdev @@ -6705,8 +6322,6 @@ JACK = $_jack JOYSTICK = $_joystick JPEG = $_jpeg -KAI = $_kai -KVA = $_kva LADSPA = $_ladspa LIBA52 = $_liba52 LIBASS = $_ass @@ -6718,6 +6333,7 @@ LIBMAD = $_mad LIBNEMESI = $_nemesi LIBNUT = $_libnut +LIBPOSTPROC = $libpostproc LIBSMBCLIENT = $_smb LIBTHEORA = $_theora LIRC = $_lirc @@ -6738,11 +6354,11 @@ PNM = $_pnm PRIORITY = $_priority PULSE = $_pulse +PORTAUDIO = $_portaudio PVR = $_pvr QTX_CODECS = $_qtx QTX_CODECS_WIN32 = $_qtx_codecs_win32 QTX_EMULATION = $_qtx_emulation -QUARTZ = $_quartz RADIO=$_radio RADIO_CAPTURE=$_radio_capture REAL_CODECS = $_real @@ -6751,7 +6367,6 @@ SDL = $_sdl SPEEX = $_speex STREAM_CACHE = $_stream_cache -SGIAUDIO = $_sgiaudio SUNAUDIO = $_sunaudio SVGA = $_svga TDFXFB = $_tdfxfb @@ -6873,13 +6488,11 @@ /* system headers */ $def_alloca_h -$def_alsa_asoundlib_h $def_altivec_h $def_malloc_h $def_mman_h $def_mman_has_map_failed $def_soundcard_h -$def_sys_asoundlib_h $def_sys_soundcard_h $def_sys_sysinfo_h $def_sys_videoio_h @@ -6956,9 +6569,9 @@ #define DEFAULT_DVD_DEVICE "$default_dvd_device" $def_bluray $def_bsdi_dvd +$def_cdda $def_cddb $def_cdio -$def_cdparanoia $def_cdrom $def_dvd $def_dvd_bsd @@ -6969,7 +6582,6 @@ $def_dvdnav $def_dvdread $def_hpux_scsi_h -$def_libcdio $def_sol_scsi_h $def_vcd @@ -6989,6 +6601,7 @@ $def_xvid $def_zlib +$def_libpostproc $def_libnut @@ -7006,16 +6619,8 @@ /* Audio output drivers */ $def_alsa -$def_alsa1x -$def_alsa5 -$def_alsa9 -$def_arts $def_coreaudio -$def_dart -$def_esd -$def_esd_latency $def_jack -$def_kai $def_nas $def_openal $def_openal_h @@ -7023,8 +6628,8 @@ $def_ossaudio_devdsp $def_ossaudio_devmixer $def_pulse +$def_portaudio $def_rsound -$def_sgiaudio $def_sunaudio $def_win32waveout @@ -7083,6 +6688,8 @@ $def_bl $def_caca $def_corevideo +$def_cocoa +$def_sharedbuffer $def_dga $def_dga1 $def_dga2 @@ -7105,13 +6712,11 @@ $def_gl_sdl $def_ivtv $def_jpeg -$def_kva $def_md5sum $def_mga $def_mng $def_png $def_pnm -$def_quartz $def_s3fb $def_sdl $def_sdl_sdl_h @@ -7162,12 +6767,8 @@ #define HAVE_INLINE_ASM 1 -/* Use these registers in FFmpeg x86 inline asm. No proper detection yet. */ -#ifndef MP_DEBUG +/* Use these registers in x86 inline asm. No proper detection yet. */ #define HAVE_EBP_AVAILABLE 1 -#else -#define HAVE_EBP_AVAILABLE 0 -#endif #endif /* MPLAYER_CONFIG_H */ EOF @@ -7215,21 +6816,6 @@ EOF -if test "$_mtrr" = yes ; then - echo "Please check mtrr settings at /proc/mtrr (see DOCS/HTML/$language_doc/video.html#mtrr)" - echo -fi - -if ! x86_32; then - cat < #elif defined(__MINGW32__) || defined(__CYGWIN__) #include -#elif defined(__OS2__) -#define INCL_DOS -#include #elif defined(__AMIGAOS4__) #include #endif @@ -89,24 +86,6 @@ } #endif /* defined(__MINGW32__) || defined(__CYGWIN__) */ -#ifdef __OS2__ -ULONG _System os2_sig_handler_sse(PEXCEPTIONREPORTRECORD p1, - PEXCEPTIONREGISTRATIONRECORD p2, - PCONTEXTRECORD p3, - PVOID p4) -{ - if(p1->ExceptionNum == XCPT_ILLEGAL_INSTRUCTION){ - mp_msg(MSGT_CPUDETECT, MSGL_V, "SIGILL, "); - - p3->ctx_RegEip += 3; - gCpuCaps.hasSSE = 0; - - return XCPT_CONTINUE_EXECUTION; - } - return XCPT_CONTINUE_SEARCH; -} -#endif - /* If we're running on a processor that can do SSE, let's see if we * are allowed to or not. This will catch 2.4.0 or later kernels that * haven't been configured for a Pentium III but are running on one, @@ -166,15 +145,6 @@ SetUnhandledExceptionFilter(exc_fil); mp_msg(MSGT_CPUDETECT,MSGL_V, gCpuCaps.hasSSE ? "yes.\n" : "no!\n" ); } -#elif defined(__OS2__) - EXCEPTIONREGISTRATIONRECORD RegRec = { 0, &os2_sig_handler_sse }; - if ( gCpuCaps.hasSSE ) { - mp_msg(MSGT_CPUDETECT,MSGL_V, "Testing OS support for SSE... " ); - DosSetExceptionHandler( &RegRec ); - __asm__ volatile ("xorps %xmm0, %xmm0"); - DosUnsetExceptionHandler( &RegRec ); - mp_msg(MSGT_CPUDETECT,MSGL_V, gCpuCaps.hasSSE ? "yes.\n" : "no!\n" ); - } #elif defined(__linux__) #if defined(_POSIX_SOURCE) struct sigaction saved_sigill; diff -Nru mplayer2-2.0-426-gc32b3ed/debian/changelog mplayer2-2.0-554-gf63dbad/debian/changelog --- mplayer2-2.0-426-gc32b3ed/debian/changelog 2012-01-12 21:59:30.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/debian/changelog 2012-10-15 17:16:46.000000000 +0000 @@ -1,3 +1,46 @@ +mplayer2 (2.0-554-gf63dbad-1ubuntu1~ppa3) precise; urgency=low + + * Test to fix P3 bug. + + -- Julien Lavergne Mon, 15 Oct 2012 19:16:37 +0200 + +mplayer2 (2.0-554-gf63dbad-1) unstable; urgency=low + + * New upstream snapshot: + - Pass a dummy address instead of NULL pointer as third argument to + FcFontMatch() to fix an assertion failure with the latest 2.9.0 + version of fontconfig (Closes: #672947). + + -- Alessio Treglia Sat, 19 May 2012 20:07:25 +0200 + +mplayer2 (2.0-542-gbb90802-1) unstable; urgency=low + + * New upstream snapshot: + - ao_pulse: fix specifying host/sink (Closes: #671362) + * Drop support for cdparanoia. + * Build-Depends on libcdio-{cdda,paranoia}-dev. + + -- Alessio Treglia Sat, 05 May 2012 01:37:30 +0200 + +mplayer2 (2.0-518-gb711624-2) unstable; urgency=low + + * Upload to unstable. + * Merge 2.0-518-gb711624 from experimental. + + -- Alessio Treglia Tue, 01 May 2012 03:32:15 +0200 + +mplayer2 (2.0-518-gb711624-1) experimental; urgency=low + + * New upstream snapshot. + * Enable harden'd flags, thanks to Moritz Muehlenhoff + for the patch. (Closes: #658034) + * Build-depend on libpng-dev only. (Closes: #662435) + * Drop esound support as it's obsolete. + * Update debian/copyright. + * Bump Standards. + + -- Alessio Treglia Thu, 26 Apr 2012 12:33:29 +0200 + mplayer2 (2.0-426-gc32b3ed-2) unstable; urgency=low * Upload to unstable diff -Nru mplayer2-2.0-426-gc32b3ed/debian/control mplayer2-2.0-554-gf63dbad/debian/control --- mplayer2-2.0-426-gc32b3ed/debian/control 2012-01-12 21:58:55.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/debian/control 2012-10-14 19:46:25.000000000 +0000 @@ -1,8 +1,10 @@ Source: mplayer2 Section: video Priority: extra -Maintainer: Debian Multimedia Maintainers -Uploaders: Reinhard Tartler , +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Debian Multimedia Maintainers +Uploaders: + Reinhard Tartler , Alessio Treglia Build-Depends: autoconf, @@ -20,13 +22,13 @@ libavutil-dev (>= 4:0.8~), libbluray-dev, libcaca-dev, - libcdparanoia-dev [!hurd-i386] | libcdparanoia0-dev [!hurd-i386], + libcdio-cdda-dev, + libcdio-paranoia-dev, libdirectfb-dev, libdts-dev, libdvdnav-dev, libdvdread-dev, libenca-dev, - libesd0-dev, libfaad-dev, libfontconfig1-dev, libfreetype6-dev, @@ -41,7 +43,7 @@ libmpcdec-dev, libncurses5-dev, libopenal-dev, - libpng12-dev | libpng-dev, + libpng-dev, libpostproc-dev (>= 4:0.8~), libpulse-dev, libschroedinger-dev, @@ -69,7 +71,7 @@ xsltproc, yasm, zlib1g-dev -Standards-Version: 3.9.2 +Standards-Version: 3.9.3 Homepage: http://mplayer2.org Vcs-Git: git://git.debian.org/pkg-multimedia/mplayer2.git Vcs-Browser: http://git.debian.org/?p=pkg-multimedia/mplayer2.git;a=summary @@ -79,9 +81,12 @@ Depends: ${misc:Depends}, ${shlibs:Depends} -Replaces: mplayer -Conflicts: mplayer -Provides: mplayer +Replaces: + mplayer +Conflicts: + mplayer +Provides: + mplayer Description: next generation movie player for Unix-like systems MPlayer plays most MPEG, VOB, AVI, Ogg/OGM, VIVO, ASF/WMA/WMV, QT/MOV/MP4, FLI, RM, NuppelVideo, yuv4mpeg, FILM, RoQ, PVA files, @@ -99,11 +104,15 @@ Package: mplayer2-dbg Section: debug Architecture: any -Depends: mplayer2 (= ${binary:Version}), +Depends: + mplayer2 (= ${binary:Version}), ${misc:Depends} -Replaces: mplayer-dbg -Conflicts: mplayer-dbg -Provides: mplayer-dbg +Replaces: + mplayer-dbg +Conflicts: + mplayer-dbg +Provides: + mplayer-dbg Description: Debugging symbols for mplayer2 MPlayer plays most MPEG, VOB, AVI, Ogg/OGM, VIVO, ASF/WMA/WMV, QT/MOV/MP4, FLI, RM, NuppelVideo, yuv4mpeg, FILM, RoQ, PVA files, diff -Nru mplayer2-2.0-426-gc32b3ed/debian/copyright mplayer2-2.0-554-gf63dbad/debian/copyright --- mplayer2-2.0-426-gc32b3ed/debian/copyright 2012-01-05 17:00:37.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/debian/copyright 2012-05-19 18:06:35.000000000 +0000 @@ -1,4 +1,4 @@ -Format: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=173 +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: mplayer2 Upstream-Contact: The mplayer and mplayer2 Developers Source: http://mplayer2.org @@ -273,12 +273,12 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - . +Comment: You should have received a copy of the GNU General Public License along with this program. If not, see . - On Debian systems, the complete text of the GNU General - Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". + On Debian systems, the complete text of the GNU General Public + License can be found in "/usr/share/common-licenses/GPL-2". License: GPL-3+ This program is free software: you can redistribute it and/or modify @@ -290,9 +290,12 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - . +Comment: You should have received a copy of the GNU General Public License along with this program. If not, see . + . + On Debian systems, the complete text of the GNU General Public + License can be found in "/usr/share/common-licenses/GPL-3". License: LGPL-2.1+ This library is free software; you can redistribute it and/or @@ -304,10 +307,12 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +Comment: + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . . - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + On Debian systems, the complete text of the GNU Lesser General Public + License version can be found in "/usr/share/common-licenses/LGPL-2.1". License: LGPL-3+ This library is free software; you can redistribute it and/or @@ -319,9 +324,12 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +Comment: + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . . - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see . + On Debian systems, the complete text of the GNU Lesser General Public + License version can be found in "/usr/share/common-licenses/LGPL-3". License: Expat Permission is hereby granted, free of charge, to any person @@ -349,7 +357,7 @@ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. - . + . THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR diff -Nru mplayer2-2.0-426-gc32b3ed/debian/rules mplayer2-2.0-554-gf63dbad/debian/rules --- mplayer2-2.0-426-gc32b3ed/debian/rules 2012-01-05 17:00:37.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/debian/rules 2012-10-14 21:06:07.000000000 +0000 @@ -1,5 +1,7 @@ #!/usr/bin/make -f +DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH) + # Support multiple makes at once ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) NUMJOBS = -j$(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) @@ -12,25 +14,41 @@ endif endif +DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +ifeq ($(DEB_HOST_GNU_CPU),i686) + CFLAGS += -march=i686 +endif + +CFLAGS = `dpkg-buildflags --get CFLAGS` +CFLAGS += `dpkg-buildflags --get CPPFLAGS` +LDFLAGS = `dpkg-buildflags --get LDFLAGS` + confflags := --prefix=/usr \ --confdir=/etc/mplayer \ --enable-translation \ --disable-svga \ - --enable-debug=3 - -# runtime cpu detection works on x86 and ppc only. These checks also work on kfreebsd! -DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) -ifeq ($(DEB_HOST_GNU_CPU),i486) - confflags += --enable-runtime-cpudetection + --extra-cflags="${CFLAGS}" \ + --extra-ldflags="${LDFLAGS}" \ + --enable-debug=3 \ + $(archconf) + +ifeq ($(DEB_HOST_ARCH),i386) +#configure optimizes for the cpu detected at ./configure time +#in order to build a generic binary, avoid non-standard opcodes through gcc + archconf += --target=i586-linux + confflags += --enable-runtime-cpudetection +endif +ifeq ($(DEB_HOST_ARCH),amd64) + confflags += --enable-runtime-cpudetection endif -ifeq ($(DEB_HOST_GNU_CPU),x86_64) - confflags += --enable-runtime-cpudetection +ifeq ($(DEB_HOST_ARCH),kfreebsd-i386) + confflags += --enable-runtime-cpudetection endif -ifeq ($(DEB_HOST_GNU_CPU),powerpc) - confflags += --enable-runtime-cpudetection +ifeq ($(DEB_HOST_ARCH),kfreebsd-amd64) + confflags += --enable-runtime-cpudetection endif -ifeq ($(DEB_HOST_GNU_CPU),sparc) - confflags += --target=generic +ifeq ($(DEB_HOST_ARCH),powerpc) + confflags += --enable-runtime-cpudetection endif %: diff -Nru mplayer2-2.0-426-gc32b3ed/defaultopts.c mplayer2-2.0-554-gf63dbad/defaultopts.c --- mplayer2-2.0-426-gc32b3ed/defaultopts.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/defaultopts.c 2012-05-17 14:38:00.000000000 +0000 @@ -10,9 +10,11 @@ .audio_driver_list = NULL, .video_driver_list = NULL, .fixed_vo = 1, + .softvol_max = 110, .ao_buffersize = -1, .monitor_pixel_aspect = 1.0, .vo_panscanrange = 1.0, + .cursor_autohide_delay = 1000, .vo_gamma_gamma = 1000, .vo_gamma_brightness = 1000, .vo_gamma_contrast = 1000, @@ -55,7 +57,6 @@ .lavc_param = { .workaround_bugs = 1, // autodetect - .error_resilience = 2, .error_concealment = 3, }, .input = { diff -Nru mplayer2-2.0-426-gc32b3ed/edl.c mplayer2-2.0-554-gf63dbad/edl.c --- mplayer2-2.0-426-gc32b3ed/edl.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/edl.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,158 +0,0 @@ -/* - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include "config.h" -#include "mp_msg.h" -#include "edl.h" - -char *edl_filename; // file to extract EDL entries from (-edl) -char *edl_output_filename; // file to put EDL entries in (-edlout) - -/** - * Allocates a new EDL record and makes sure allocation was successful. - * - * \return New allocated EDL record. - * \brief Allocate new EDL record - */ - -static edl_record_ptr edl_alloc_new(edl_record_ptr next_edl_record) -{ - edl_record_ptr new_record = calloc(1, sizeof(struct edl_record)); - if (!new_record) { - mp_tmsg(MSGT_CPLAYER, MSGL_FATAL, "Can't allocate enough memory to hold EDL data.\n"); - exit(1); - } - - if (next_edl_record) // if this isn't the first record, tell the previous one what the new one is. - next_edl_record->next = new_record; - new_record->prev = next_edl_record; - new_record->next = NULL; - - return new_record; -} - -/** - * Goes through entire EDL records and frees all memory. - * Assumes next_edl_record is valid or NULL. - * - * \brief Free EDL memory - */ - -void free_edl(edl_record_ptr next_edl_record) -{ - edl_record_ptr tmp; - while (next_edl_record) { - tmp = next_edl_record->next; - free(next_edl_record); - next_edl_record = tmp; - } -} - -/** Parses edl_filename to fill EDL operations queue. - * Prints out how many EDL operations recorded total. - * \brief Fills EDL operations queue. - */ - -edl_record_ptr edl_parse_file(void) -{ - FILE *fd; - char line[100]; - float start, stop; - int action; - int record_count = 0; - int lineCount = 0; - edl_record_ptr edl_records = NULL; - edl_record_ptr next_edl_record = NULL; - - if (edl_filename) - { - if ((fd = fopen(edl_filename, "r")) == NULL) - { - return NULL; - } - - while (fgets(line, 99, fd) != NULL) - { - lineCount++; - - if ((sscanf(line, "%f %f %d", &start, &stop, &action)) - != 3) - { - mp_tmsg(MSGT_CPLAYER, MSGL_WARN, "Badly formatted EDL line [%d], discarding.\n", - lineCount); - continue; - } - - if (next_edl_record && start <= next_edl_record->stop_sec) - { - mp_tmsg(MSGT_CPLAYER, MSGL_WARN, "Invalid EDL line: %s\n", line); - mp_tmsg(MSGT_CPLAYER, MSGL_WARN, - "Last stop position was [%f]; next start is [%f].\n"\ - "Entries must be in chronological order, cannot overlap. Discarding.\n", - next_edl_record->stop_sec, start); - continue; - } - - if (stop <= start) - { - mp_tmsg(MSGT_CPLAYER, MSGL_WARN, "Invalid EDL line: %s\n", - line); - mp_tmsg(MSGT_CPLAYER, MSGL_WARN, "Stop time has to be after start time.\n"); - continue; - } - - next_edl_record = edl_alloc_new(next_edl_record); - - if (!edl_records) edl_records = next_edl_record; - - next_edl_record->action = action; - - if (action == EDL_MUTE) - { - next_edl_record->length_sec = 0; - next_edl_record->start_sec = start; - next_edl_record->stop_sec = start; - - next_edl_record = edl_alloc_new(next_edl_record); - - next_edl_record->action = action; - next_edl_record->length_sec = 0; - next_edl_record->start_sec = stop; - next_edl_record->stop_sec = stop; - } else - { - next_edl_record->length_sec = stop - start; - next_edl_record->start_sec = start; - next_edl_record->stop_sec = stop; - } - - record_count++; - } - - fclose(fd); - } - - if (edl_records) - mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Read %d EDL actions.\n", record_count); - else - mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "There are no EDL actions to take care of.\n"); - - return edl_records; -} diff -Nru mplayer2-2.0-426-gc32b3ed/edl.h mplayer2-2.0-554-gf63dbad/edl.h --- mplayer2-2.0-426-gc32b3ed/edl.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/edl.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -/* - * EDL version 0.6 - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPLAYER_EDL_H -#define MPLAYER_EDL_H - -#define EDL_SKIP 0 -#define EDL_MUTE 1 - -#define EDL_MUTE_START 1 -#define EDL_MUTE_END 0 - -struct edl_record { - float start_sec; - float stop_sec; - float length_sec; - short action; - struct edl_record* next; - struct edl_record* prev; -}; - -typedef struct edl_record* edl_record_ptr; - -extern char *edl_filename; // file to extract EDL entries from (-edl) -extern char *edl_output_filename; // file to put EDL entries in (-edlout) - -void free_edl(edl_record_ptr next_edl_record); // free's entire EDL list. -edl_record_ptr edl_parse_file(void); // fills EDL stack - -#endif /* MPLAYER_EDL_H */ diff -Nru mplayer2-2.0-426-gc32b3ed/etc/input.conf mplayer2-2.0-554-gf63dbad/etc/input.conf --- mplayer2-2.0-426-gc32b3ed/etc/input.conf 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/etc/input.conf 2012-05-17 14:38:00.000000000 +0000 @@ -1,62 +1,83 @@ -## -## MPlayer input control file -## -## You are able to redefine default keyboard/joystick/mouse/LIRC bindings, or -## add new ones here. -## See DOCS/tech/slave.txt for possible commands that can be bound. -## Also see mplayer -input cmdlist for other possible options. -## The file should be placed in the $HOME/.mplayer directory. -## -## If you wish to unbind a key, use key ignore. -## e.g. ENTER ignore -## -## You can use modifier-key combinations like Shift+Left or Ctrl+Alt+x with -## modifiers Shift, Ctrl, Alt and Meta, but note that currently reading -## key combinations is only supported through the video windows of X-based -## output drivers (not in output windows of other drivers or in a terminal). - -RIGHT seek +10 -LEFT seek -10 -DOWN seek -60 -UP seek +60 +# MPlayer input control file +# +# You are able to redefine default keyboard/joystick/mouse/LIRC bindings, or +# add new ones here. +# See DOCS/tech/slave.txt for possible commands that can be bound. +# Also see mplayer -input cmdlist for other possible options. +# The file should be placed in the $HOME/.mplayer directory. +# +# If you wish to unbind a key, use key ignore. +# e.g. ENTER ignore +# +# Note that merely removing default key bindings from this file won't remove +# the default bindings mplayer was compiled with, unless +# --input=nodefault-bindings +# is specified. +# +# Lines starting with # are comments. Use SHARP to assign the # key. +# +# Some characters need to be escaped. In particular, if you want to display +# a '\' character as part of an osd_show_property_text OSD message, you have to +# escape 2 times: +# key osd_show_property_text "This is a single backslash: \\\\!" +# +# You can use modifier-key combinations like Shift+Left or Ctrl+Alt+x with +# modifiers Shift, Ctrl, Alt and Meta, but note that currently reading +# key combinations is only supported through the video windows of X-based +# output drivers (not in output windows of other drivers or in a terminal). + +MOUSE_BTN0_DBL vo_fullscreen # toggle fullscreen on/off +MOUSE_BTN2 pause # toggle pause on/off +MOUSE_BTN3 seek 10 +MOUSE_BTN4 seek -10 +MOUSE_BTN5 volume 1 +MOUSE_BTN6 volume -1 + +# Seek units are in seconds, but note that these are limited by keyframes +RIGHT seek 10 +LEFT seek -10 +UP seek 60 +DOWN seek -60 # Do smaller, always exact (non-keyframe-limited), seeks with shift. -Shift+Right seek +1 0 1 -Shift+Left seek -1 0 1 -Shift+Down seek -5 0 1 -Shift+Up seek +5 0 1 +Shift+RIGHT seek 1 0 1 +Shift+LEFT seek -1 0 1 +Shift+UP seek 5 0 1 +Shift+DOWN seek -5 0 1 PGUP seek 600 PGDWN seek -600 -m mute -# switch_audio # switch audio streams -+ audio_delay 0.100 -= audio_delay 0.100 ++ audio_delay 0.100 # this changes audio/video sync - audio_delay -0.100 -[ speed_mult 0.9091 # scale playback speed +[ speed_mult 0.9091 # scale playback speed ] speed_mult 1.1 { speed_mult 0.5 } speed_mult 2.0 -BS speed_set 1.0 # reset speed to normal +BS speed_set 1.0 # reset speed to normal q quit ESC quit -ENTER pt_step 1 1 # skip to next file -p pause -. frame_step # advance one frame and pause +p pause # toggle pause/playback mode +. frame_step # advance one frame and pause SPACE pause HOME pt_up_step 1 END pt_up_step -1 -> pt_step 1 # skip to next file -< pt_step -1 # previous +> pt_step 1 # skip to next file +ENTER pt_step 1 1 # skip to next file or quit +< pt_step -1 # skip to previous file INS alt_src_step 1 DEL alt_src_step -1 -o osd -I osd_show_property_text "${filename}" # display filename in osd +o osd # cycle through OSD mode +I osd_show_property_text "${filename}" # display filename in osd P osd_show_progression -z sub_delay -0.1 # subtract 100 ms delay from subs -x sub_delay +0.1 # add +z sub_delay -0.1 # subtract 100 ms delay from subs +x sub_delay +0.1 # add +g sub_step -1 # immediately display next subtitle +y sub_step +1 # previous 9 volume -1 / volume -1 0 volume 1 * volume 1 +( balance -0.1 # adjust audio balance in favor of left +) balance 0.1 # right +m mute 1 contrast -1 2 contrast 1 3 brightness -1 @@ -65,54 +86,78 @@ 6 hue 1 7 saturation -1 8 saturation 1 -( balance -0.1 # adjust audio balance in favor of left -) balance +0.1 # right -d frame_drop -D step_property deinterlace # toggle deinterlacer, requires -vf yadif or kerndeint -r sub_pos -1 # move subtitles up -t sub_pos +1 # down -#? sub_step +1 # immediately display next subtitle -#? sub_step -1 # previous -#? sub_scale +0.1 # increase subtitle font size -#? sub_scale -0.1 # decrease subtitle font size -V step_property_osd ass_vsfilter_aspect_compat # stretch SSA/ASS subtitles with anamorphic videos to match historical VSFilter behavior -f vo_fullscreen -T vo_ontop # toggle video window ontop of other windows -w panscan -0.1 # zoom out with -panscan 0 -fs -e panscan +0.1 # in -s screenshot # take a png screenshot with -vf screenshot - # S will take a png screenshot of every frame +d frame_drop # cycle through framedrop modes +# toggle deinterlacer; requires either vdpau output, -vf yadif or kerndeint +D step_property_osd deinterlace +c step_property_osd colormatrix +# Next 3 currently only work with --no-ass +r sub_pos -1 # move subtitles up +t sub_pos +1 # down +a sub_alignment +v sub_visibility +# stretch SSA/ASS subtitles with anamorphic videos to match historical +V step_property_osd ass_vsfilter_aspect_compat +j sub_select # cycle through subtitles +J sub_select -3 # ...backwards +F forced_subs_only +SHARP switch_audio # switch audio streams +_ step_property switch_video +TAB step_property switch_program +i edl_mark # for use with --edlout mode +T vo_ontop # toggle video window ontop of other windows +f vo_fullscreen # toggle fullscreen +C step_property_osd capturing +s screenshot 0 # take a png screenshot +S screenshot 1 # ...on every frame +Alt+s screenshot 0 1 # take a screenshot of window contents +Alt+S screenshot 1 1 # ...on every frame +w panscan -0.1 # zoom out with -panscan 0 -fs +e panscan +0.1 # in +POWER quit +MENU osd +PLAY pause +PAUSE pause +PLAYPAUSE pause +STOP quit +FORWARD seek 60 +REWIND seek -60 +NEXT pt_step 1 +PREV pt_step -1 +VOLUME_UP volume 1 +VOLUME_DOWN volume -1 +MUTE mute +CLOSE_WIN quit +! seek_chapter -1 # skip to previous chapter +@ seek_chapter 1 # next +A switch_angle 1 +U stop +# TV h tv_step_channel 1 -l tv_step_channel -1 +k tv_step_channel -1 n tv_step_norm -b tv_step_chanlist - -## -## Mouse section -## - -MOUSE_BTN0_DBL vo_fullscreen # toggle fullscreen on/off -MOUSE_BTN2 pause # toggle pause on/off - -## -## Joystick section -## WARNING: joystick support has to be explicitly enabled at -## compiletime with --enable-joystick -## - -JOY_RIGHT seek 10 -JOY_LEFT seek -10 -JOY_UP seek 60 -JOY_DOWN seek -60 -JOY_BTN0 pause -JOY_BTN1 osd -JOY_BTN2 volume 1 -JOY_BTN3 volume -1 - -## -## Apple Remote section -## +u tv_step_chanlist +X step_property teletext_mode 1 +W step_property teletext_page 1 +Q step_property teletext_page -1 + +# +# DVDNAV +# Requires dvdnav:// +# + +KP8 dvdnav up +KP2 dvdnav down +KP4 dvdnav left +KP6 dvdnav right +KP5 dvdnav menu +KP_ENTER dvdnav select +MOUSE_BTN0 dvdnav mouse +KP7 dvdnav prev + +# +# Apple Remote section +# AR_PLAY pause AR_PLAY_HOLD quit @@ -120,29 +165,30 @@ AR_NEXT_HOLD seek 120 AR_PREV seek -10 AR_PREV_HOLD seek -120 +AR_MENU osd AR_MENU_HOLD mute AR_VUP volume 1 AR_VDOWN volume -1 -## -## DVDNAV -## Requires dvdnav:// -## - -UP {dvdnav} dvdnav up # DVDNav UP -DOWN {dvdnav} dvdnav down # DVDNav DOWN -LEFT {dvdnav} dvdnav left # DVDNav LEFT -RIGHT {dvdnav} dvdnav right # DVDNav RIGHT -ESC {dvdnav} dvdnav menu # DVDNav MENU -ENTER {dvdnav} dvdnav select # DVDNav SELECT (ok) -BS {dvdnav} dvdnav prev # DVDNav PREVIOUS menu (in the order chapter->title->root) - -AR_VUP {dvdnav} dvdnav up # DVDNav UP -AR_VDOWN {dvdnav} dvdnav down # DVDNav DOWN -AR_PREV {dvdnav} dvdnav left # DVDNav LEFT -AR_NEXT {dvdnav} dvdnav right # DVDNav RIGHT -AR_MENU {dvdnav} dvdnav menu # DVDNav MENU -AR_PLAY {dvdnav} dvdnav select # DVDNav SELECT (ok) +# +# Joystick section +# WARNING: joystick support has to be explicitly enabled at +# compiletime with --enable-joystick +# + +JOY_AXIS0_PLUS seek 10 +JOY_AXIS0_MINUS seek -10 +JOY_AXIS1_MINUS seek 60 +JOY_AXIS1_PLUS seek -60 +JOY_BTN0 pause +JOY_BTN1 osd +JOY_BTN2 volume 1 +JOY_BTN3 volume -1 + +# +# Not assigned by default +# (not an exhaustive list of unbound commands) +# -#? seek_chapter -1 # skip to previous dvd chapter -#? seek_chapter +1 # next +#? sub_scale +0.1 # increase subtitle font size +#? sub_scale -0.1 # decrease subtitle font size diff -Nru mplayer2-2.0-426-gc32b3ed/ffmpeg_files/arm/bswap.h mplayer2-2.0-554-gf63dbad/ffmpeg_files/arm/bswap.h --- mplayer2-2.0-426-gc32b3ed/ffmpeg_files/arm/bswap.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/ffmpeg_files/arm/bswap.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef MP_AVUTIL_ARM_BSWAP_H -#define MP_AVUTIL_ARM_BSWAP_H - -#include -#include "config.h" -#include "libavutil/common.h" - -#ifdef __ARMCC_VERSION - -#if HAVE_ARMV6 -#define bswap_16 bswap_16 -static av_always_inline av_const uint16_t bswap_16(uint16_t x) -{ - __asm { rev16 x, x } - return x; -} - -#define bswap_32 bswap_32 -static av_always_inline av_const uint32_t bswap_32(uint32_t x) -{ - return __rev(x); -} -#endif /* HAVE_ARMV6 */ - -#elif HAVE_INLINE_ASM - -#if HAVE_ARMV6 -#define bswap_16 bswap_16 -static av_always_inline av_const uint16_t bswap_16(uint16_t x) -{ - __asm__("rev16 %0, %0" : "+r"(x)); - return x; -} -#endif - -#define bswap_32 bswap_32 -static av_always_inline av_const uint32_t bswap_32(uint32_t x) -{ -#if HAVE_ARMV6 - __asm__("rev %0, %0" : "+r"(x)); -#else - uint32_t t; - __asm__ ("eor %1, %0, %0, ror #16 \n\t" - "bic %1, %1, #0xFF0000 \n\t" - "mov %0, %0, ror #8 \n\t" - "eor %0, %0, %1, lsr #8 \n\t" - : "+r"(x), "=&r"(t)); -#endif /* HAVE_ARMV6 */ - return x; -} - -#endif /* __ARMCC_VERSION */ - -#endif /* AVUTIL_ARM_BSWAP_H */ diff -Nru mplayer2-2.0-426-gc32b3ed/ffmpeg_files/bfin/bswap.h mplayer2-2.0-554-gf63dbad/ffmpeg_files/bfin/bswap.h --- mplayer2-2.0-426-gc32b3ed/ffmpeg_files/bfin/bswap.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/ffmpeg_files/bfin/bswap.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2007 Marc Hoffman - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file libavutil/bfin/bswap.h - * byte swapping routines - */ - -#ifndef MP_AVUTIL_BFIN_BSWAP_H -#define MP_AVUTIL_BFIN_BSWAP_H - -#include -#include "config.h" -#include "libavutil/common.h" - -#define bswap_32 bswap_32 -static av_always_inline av_const uint32_t bswap_32(uint32_t x) -{ - unsigned tmp; - __asm__("%1 = %0 >> 8 (V); \n\t" - "%0 = %0 << 8 (V); \n\t" - "%0 = %0 | %1; \n\t" - "%0 = PACK(%0.L, %0.H); \n\t" - : "+d"(x), "=&d"(tmp)); - return x; -} - -#endif /* AVUTIL_BFIN_BSWAP_H */ diff -Nru mplayer2-2.0-426-gc32b3ed/ffmpeg_files/bswap.h mplayer2-2.0-554-gf63dbad/ffmpeg_files/bswap.h --- mplayer2-2.0-426-gc32b3ed/ffmpeg_files/bswap.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/ffmpeg_files/bswap.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ -/* - * copyright (c) 2006 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -// This file in MPlayer is otherwise the same as in FFmpeg, except it -// includes "libavutil/common.h" instead of "common.h". - -/** - * @file libavutil/bswap.h - * byte swapping routines - */ - -#ifndef MP_AVUTIL_BSWAP_H -#define MP_AVUTIL_BSWAP_H - -#include -#include "libavutil/common.h" -#include "config.h" - -#if ARCH_ARM -# include "arm/bswap.h" -#elif ARCH_BFIN -# include "bfin/bswap.h" -#elif ARCH_SH4 -# include "sh4/bswap.h" -#elif ARCH_X86 -# include "x86/bswap.h" -#endif - -#ifndef bswap_16 -static av_always_inline av_const uint16_t bswap_16(uint16_t x) -{ - x= (x>>8) | (x<<8); - return x; -} -#endif - -#ifndef bswap_32 -static av_always_inline av_const uint32_t bswap_32(uint32_t x) -{ - x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF); - x= (x>>16) | (x<<16); - return x; -} -#endif - -#ifndef bswap_64 -static inline uint64_t av_const bswap_64(uint64_t x) -{ -#if 0 - x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL); - x= ((x<<16)&0xFFFF0000FFFF0000ULL) | ((x>>16)&0x0000FFFF0000FFFFULL); - return (x>>32) | (x<<32); -#else - union { - uint64_t ll; - uint32_t l[2]; - } w, r; - w.ll = x; - r.l[0] = bswap_32 (w.l[1]); - r.l[1] = bswap_32 (w.l[0]); - return r.ll; -#endif -} -#endif - -// be2me ... big-endian to machine-endian -// le2me ... little-endian to machine-endian - -#ifdef WORDS_BIGENDIAN -#define be2me_16(x) (x) -#define be2me_32(x) (x) -#define be2me_64(x) (x) -#define le2me_16(x) bswap_16(x) -#define le2me_32(x) bswap_32(x) -#define le2me_64(x) bswap_64(x) -#else -#define be2me_16(x) bswap_16(x) -#define be2me_32(x) bswap_32(x) -#define be2me_64(x) bswap_64(x) -#define le2me_16(x) (x) -#define le2me_32(x) (x) -#define le2me_64(x) (x) -#endif - -#endif /* AVUTIL_BSWAP_H */ diff -Nru mplayer2-2.0-426-gc32b3ed/ffmpeg_files/intreadwrite.h mplayer2-2.0-554-gf63dbad/ffmpeg_files/intreadwrite.h --- mplayer2-2.0-426-gc32b3ed/ffmpeg_files/intreadwrite.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/ffmpeg_files/intreadwrite.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,226 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef MP_AVUTIL_INTREADWRITE_H -#define MP_AVUTIL_INTREADWRITE_H - -#include -#include "config.h" -#include "bswap.h" - -#ifndef AV_RB16 -#define AV_RB16(x) ((((const uint8_t*)(x))[0] << 8) | \ - ((const uint8_t*)(x))[1]) -#endif -#ifndef AV_WB16 -#define AV_WB16(p, d) do { \ - ((uint8_t*)(p))[1] = (d); \ - ((uint8_t*)(p))[0] = (d)>>8; } while(0) -#endif - -#ifndef AV_RL16 -#define AV_RL16(x) ((((const uint8_t*)(x))[1] << 8) | \ - ((const uint8_t*)(x))[0]) -#endif -#ifndef AV_WL16 -#define AV_WL16(p, d) do { \ - ((uint8_t*)(p))[0] = (d); \ - ((uint8_t*)(p))[1] = (d)>>8; } while(0) -#endif - -#ifndef AV_RB32 -#define AV_RB32(x) (((uint32_t)((const uint8_t*)(x))[0] << 24) | \ - (((const uint8_t*)(x))[1] << 16) | \ - (((const uint8_t*)(x))[2] << 8) | \ - ((const uint8_t*)(x))[3]) -#endif -#ifndef AV_WB32 -#define AV_WB32(p, d) do { \ - ((uint8_t*)(p))[3] = (d); \ - ((uint8_t*)(p))[2] = (d)>>8; \ - ((uint8_t*)(p))[1] = (d)>>16; \ - ((uint8_t*)(p))[0] = (d)>>24; } while(0) -#endif - -#ifndef AV_RL32 -#define AV_RL32(x) (((uint32_t)((const uint8_t*)(x))[3] << 24) | \ - (((const uint8_t*)(x))[2] << 16) | \ - (((const uint8_t*)(x))[1] << 8) | \ - ((const uint8_t*)(x))[0]) -#endif -#ifndef AV_WL32 -#define AV_WL32(p, d) do { \ - ((uint8_t*)(p))[0] = (d); \ - ((uint8_t*)(p))[1] = (d)>>8; \ - ((uint8_t*)(p))[2] = (d)>>16; \ - ((uint8_t*)(p))[3] = (d)>>24; } while(0) -#endif - -#ifndef AV_RB64 -#define AV_RB64(x) (((uint64_t)((const uint8_t*)(x))[0] << 56) | \ - ((uint64_t)((const uint8_t*)(x))[1] << 48) | \ - ((uint64_t)((const uint8_t*)(x))[2] << 40) | \ - ((uint64_t)((const uint8_t*)(x))[3] << 32) | \ - ((uint64_t)((const uint8_t*)(x))[4] << 24) | \ - ((uint64_t)((const uint8_t*)(x))[5] << 16) | \ - ((uint64_t)((const uint8_t*)(x))[6] << 8) | \ - (uint64_t)((const uint8_t*)(x))[7]) -#endif -#ifndef AV_WB64 -#define AV_WB64(p, d) do { \ - ((uint8_t*)(p))[7] = (d); \ - ((uint8_t*)(p))[6] = (d)>>8; \ - ((uint8_t*)(p))[5] = (d)>>16; \ - ((uint8_t*)(p))[4] = (d)>>24; \ - ((uint8_t*)(p))[3] = (d)>>32; \ - ((uint8_t*)(p))[2] = (d)>>40; \ - ((uint8_t*)(p))[1] = (d)>>48; \ - ((uint8_t*)(p))[0] = (d)>>56; } while(0) -#endif - -#ifndef AV_RL64 -#define AV_RL64(x) (((uint64_t)((const uint8_t*)(x))[7] << 56) | \ - ((uint64_t)((const uint8_t*)(x))[6] << 48) | \ - ((uint64_t)((const uint8_t*)(x))[5] << 40) | \ - ((uint64_t)((const uint8_t*)(x))[4] << 32) | \ - ((uint64_t)((const uint8_t*)(x))[3] << 24) | \ - ((uint64_t)((const uint8_t*)(x))[2] << 16) | \ - ((uint64_t)((const uint8_t*)(x))[1] << 8) | \ - (uint64_t)((const uint8_t*)(x))[0]) -#endif -#ifndef AV_WL64 -#define AV_WL64(p, d) do { \ - ((uint8_t*)(p))[0] = (d); \ - ((uint8_t*)(p))[1] = (d)>>8; \ - ((uint8_t*)(p))[2] = (d)>>16; \ - ((uint8_t*)(p))[3] = (d)>>24; \ - ((uint8_t*)(p))[4] = (d)>>32; \ - ((uint8_t*)(p))[5] = (d)>>40; \ - ((uint8_t*)(p))[6] = (d)>>48; \ - ((uint8_t*)(p))[7] = (d)>>56; } while(0) -#endif - -#ifdef WORDS_BIGENDIAN -# define AV_RN(s, p) AV_RB##s(p) -# define AV_WN(s, p, v) AV_WB##s(p, v) -#else -# define AV_RN(s, p) AV_RL##s(p) -# define AV_WN(s, p, v) AV_WL##s(p, v) -#endif - -#ifndef AV_RN16 -# define AV_RN16(p) AV_RN(16, p) -#endif - -#ifndef AV_RN32 -# define AV_RN32(p) AV_RN(32, p) -#endif - -#ifndef AV_RN64 -# define AV_RN64(p) AV_RN(64, p) -#endif - -#ifndef AV_WN16 -# define AV_WN16(p, v) AV_WN(16, p, v) -#endif - -#ifndef AV_WN32 -# define AV_WN32(p, v) AV_WN(32, p, v) -#endif - -#ifndef AV_WN64 -# define AV_WN64(p, v) AV_WN(64, p, v) -#endif - -#ifdef WORDS_BIGENDIAN -# define AV_RB(s, p) AV_RN(s, p) -# define AV_WB(s, p, v) AV_WN(s, p, v) -# define AV_RL(s, p) bswap_##s(AV_RN(s, p)) -# define AV_WL(s, p, v) AV_WN(s, p, bswap_##s(v)) -#else -# define AV_RB(s, p) bswap_##s(AV_RN(s, p)) -# define AV_WB(s, p, v) AV_WN(s, p, bswap_##s(v)) -# define AV_RL(s, p) AV_RN(s, p) -# define AV_WL(s, p, v) AV_WN(s, p, v) -#endif - -#define AV_RB8(x) (((const uint8_t*)(x))[0]) -#define AV_WB8(p, d) do { ((uint8_t*)(p))[0] = (d); } while(0) - -#define AV_RL8(x) AV_RB8(x) -#define AV_WL8(p, d) AV_WB8(p, d) - -#ifndef AV_RB16 -# define AV_RB16(p) AV_RB(16, p) -#endif -#ifndef AV_WB16 -# define AV_WB16(p, v) AV_WB(16, p, v) -#endif - -#ifndef AV_RL16 -# define AV_RL16(p) AV_RL(16, p) -#endif -#ifndef AV_WL16 -# define AV_WL16(p, v) AV_WL(16, p, v) -#endif - -#ifndef AV_RB32 -# define AV_RB32(p) AV_RB(32, p) -#endif -#ifndef AV_WB32 -# define AV_WB32(p, v) AV_WB(32, p, v) -#endif - -#ifndef AV_RL32 -# define AV_RL32(p) AV_RL(32, p) -#endif -#ifndef AV_WL32 -# define AV_WL32(p, v) AV_WL(32, p, v) -#endif - -#ifndef AV_RB64 -# define AV_RB64(p) AV_RB(64, p) -#endif -#ifndef AV_WB64 -# define AV_WB64(p, v) AV_WB(64, p, v) -#endif - -#ifndef AV_RL64 -# define AV_RL64(p) AV_RL(64, p) -#endif -#ifndef AV_WL64 -# define AV_WL64(p, v) AV_WL(64, p, v) -#endif - -#define AV_RB24(x) ((((const uint8_t*)(x))[0] << 16) | \ - (((const uint8_t*)(x))[1] << 8) | \ - ((const uint8_t*)(x))[2]) -#define AV_WB24(p, d) do { \ - ((uint8_t*)(p))[2] = (d); \ - ((uint8_t*)(p))[1] = (d)>>8; \ - ((uint8_t*)(p))[0] = (d)>>16; } while(0) - -#define AV_RL24(x) ((((const uint8_t*)(x))[2] << 16) | \ - (((const uint8_t*)(x))[1] << 8) | \ - ((const uint8_t*)(x))[0]) -#define AV_WL24(p, d) do { \ - ((uint8_t*)(p))[0] = (d); \ - ((uint8_t*)(p))[1] = (d)>>8; \ - ((uint8_t*)(p))[2] = (d)>>16; } while(0) - -#endif /* AVUTIL_INTREADWRITE_H */ diff -Nru mplayer2-2.0-426-gc32b3ed/ffmpeg_files/sh4/bswap.h mplayer2-2.0-554-gf63dbad/ffmpeg_files/sh4/bswap.h --- mplayer2-2.0-426-gc32b3ed/ffmpeg_files/sh4/bswap.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/ffmpeg_files/sh4/bswap.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file libavutil/sh4/bswap.h - * byte swapping routines - */ - -#ifndef MP_AVUTIL_SH4_BSWAP_H -#define MP_AVUTIL_SH4_BSWAP_H - -#include -#include "config.h" -#include "libavutil/common.h" - -#define bswap_16 bswap_16 -static av_always_inline av_const uint16_t bswap_16(uint16_t x) -{ - __asm__("swap.b %0,%0" : "+r"(x)); - return x; -} - -#define bswap_32 bswap_32 -static av_always_inline av_const uint32_t bswap_32(uint32_t x) -{ - __asm__("swap.b %0,%0\n" - "swap.w %0,%0\n" - "swap.b %0,%0\n" - : "+r"(x)); - return x; -} - -#endif /* AVUTIL_SH4_BSWAP_H */ diff -Nru mplayer2-2.0-426-gc32b3ed/ffmpeg_files/taglists.c mplayer2-2.0-554-gf63dbad/ffmpeg_files/taglists.c --- mplayer2-2.0-426-gc32b3ed/ffmpeg_files/taglists.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/ffmpeg_files/taglists.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,367 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -/* This file contains: - * - the tables ff_codec_bmp_tags and ff_codec_wav_tags from FFmpeg's - * libavformat/riff.c, renamed to have an extra mp_ prefix, and with - * libavcodec version check added around CODEC_ID_ macros only available - * in latest libavcodec versions - * - an implementation of av_codec_get_tag and av_codec_get_id from - * libavformat/utils.c, renamed to have an extra mp_ prefix - */ - - -const struct mp_AVCodecTag mp_ff_codec_bmp_tags[] = { - { CODEC_ID_H264, MKTAG('H', '2', '6', '4') }, - { CODEC_ID_H264, MKTAG('h', '2', '6', '4') }, - { CODEC_ID_H264, MKTAG('X', '2', '6', '4') }, - { CODEC_ID_H264, MKTAG('x', '2', '6', '4') }, - { CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') }, - { CODEC_ID_H264, MKTAG('V', 'S', 'S', 'H') }, - { CODEC_ID_H263, MKTAG('H', '2', '6', '3') }, - { CODEC_ID_H263, MKTAG('X', '2', '6', '3') }, - { CODEC_ID_H263, MKTAG('T', '2', '6', '3') }, - { CODEC_ID_H263, MKTAG('L', '2', '6', '3') }, - { CODEC_ID_H263, MKTAG('V', 'X', '1', 'K') }, - { CODEC_ID_H263, MKTAG('Z', 'y', 'G', 'o') }, - { CODEC_ID_H263P, MKTAG('H', '2', '6', '3') }, - { CODEC_ID_H263I, MKTAG('I', '2', '6', '3') }, /* intel h263 */ - { CODEC_ID_H261, MKTAG('H', '2', '6', '1') }, - { CODEC_ID_H263P, MKTAG('U', '2', '6', '3') }, - { CODEC_ID_H263P, MKTAG('v', 'i', 'v', '1') }, - { CODEC_ID_MPEG4, MKTAG('F', 'M', 'P', '4') }, - { CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', 'X') }, - { CODEC_ID_MPEG4, MKTAG('D', 'X', '5', '0') }, - { CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'D') }, - { CODEC_ID_MPEG4, MKTAG('M', 'P', '4', 'S') }, - { CODEC_ID_MPEG4, MKTAG('M', '4', 'S', '2') }, - { CODEC_ID_MPEG4, MKTAG( 4 , 0 , 0 , 0 ) }, /* some broken avi use this */ - { CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', '1') }, - { CODEC_ID_MPEG4, MKTAG('B', 'L', 'Z', '0') }, - { CODEC_ID_MPEG4, MKTAG('m', 'p', '4', 'v') }, - { CODEC_ID_MPEG4, MKTAG('U', 'M', 'P', '4') }, - { CODEC_ID_MPEG4, MKTAG('W', 'V', '1', 'F') }, - { CODEC_ID_MPEG4, MKTAG('S', 'E', 'D', 'G') }, - { CODEC_ID_MPEG4, MKTAG('R', 'M', 'P', '4') }, - { CODEC_ID_MPEG4, MKTAG('3', 'I', 'V', '2') }, - { CODEC_ID_MPEG4, MKTAG('W', 'A', 'W', 'V') }, /* WaWv MPEG-4 Video Codec */ - { CODEC_ID_MPEG4, MKTAG('F', 'F', 'D', 'S') }, - { CODEC_ID_MPEG4, MKTAG('F', 'V', 'F', 'W') }, - { CODEC_ID_MPEG4, MKTAG('D', 'C', 'O', 'D') }, - { CODEC_ID_MPEG4, MKTAG('M', 'V', 'X', 'M') }, - { CODEC_ID_MPEG4, MKTAG('P', 'M', '4', 'V') }, - { CODEC_ID_MPEG4, MKTAG('S', 'M', 'P', '4') }, - { CODEC_ID_MPEG4, MKTAG('D', 'X', 'G', 'M') }, - { CODEC_ID_MPEG4, MKTAG('V', 'I', 'D', 'M') }, - { CODEC_ID_MPEG4, MKTAG('M', '4', 'T', '3') }, - { CODEC_ID_MPEG4, MKTAG('G', 'E', 'O', 'X') }, - { CODEC_ID_MPEG4, MKTAG('H', 'D', 'X', '4') }, /* flipped video */ - { CODEC_ID_MPEG4, MKTAG('D', 'M', 'K', '2') }, - { CODEC_ID_MPEG4, MKTAG('D', 'I', 'G', 'I') }, - { CODEC_ID_MPEG4, MKTAG('I', 'N', 'M', 'C') }, - { CODEC_ID_MPEG4, MKTAG('E', 'P', 'H', 'V') }, /* Ephv MPEG-4 */ - { CODEC_ID_MPEG4, MKTAG('E', 'M', '4', 'A') }, - { CODEC_ID_MPEG4, MKTAG('M', '4', 'C', 'C') }, /* Divio MPEG-4 */ - { CODEC_ID_MPEG4, MKTAG('S', 'N', '4', '0') }, - { CODEC_ID_MPEG4, MKTAG('V', 'S', 'P', 'X') }, - { CODEC_ID_MPEG4, MKTAG('U', 'L', 'D', 'X') }, - { CODEC_ID_MPEG4, MKTAG('G', 'E', 'O', 'V') }, - { CODEC_ID_MPEG4, MKTAG('S', 'I', 'P', 'P') }, /* Samsung SHR-6040 */ - { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') }, - { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '3') }, - { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', 'G', '3') }, - { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '5') }, - { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '6') }, - { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '4') }, - { CODEC_ID_MSMPEG4V3, MKTAG('D', 'V', 'X', '3') }, - { CODEC_ID_MSMPEG4V3, MKTAG('A', 'P', '4', '1') }, - { CODEC_ID_MSMPEG4V3, MKTAG('C', 'O', 'L', '1') }, - { CODEC_ID_MSMPEG4V3, MKTAG('C', 'O', 'L', '0') }, - { CODEC_ID_MSMPEG4V2, MKTAG('M', 'P', '4', '2') }, - { CODEC_ID_MSMPEG4V2, MKTAG('D', 'I', 'V', '2') }, - { CODEC_ID_MSMPEG4V1, MKTAG('M', 'P', 'G', '4') }, - { CODEC_ID_MSMPEG4V1, MKTAG('M', 'P', '4', '1') }, - { CODEC_ID_WMV1, MKTAG('W', 'M', 'V', '1') }, - { CODEC_ID_WMV2, MKTAG('W', 'M', 'V', '2') }, - { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 's', 'd') }, - { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', 'd') }, - { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '1') }, - { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 's', 'l') }, - { CODEC_ID_DVVIDEO, MKTAG('d', 'v', '2', '5') }, - { CODEC_ID_DVVIDEO, MKTAG('d', 'v', '5', '0') }, - { CODEC_ID_DVVIDEO, MKTAG('c', 'd', 'v', 'c') }, /* Canopus DV */ - { CODEC_ID_DVVIDEO, MKTAG('C', 'D', 'V', 'H') }, /* Canopus DV */ - { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', ' ') }, - { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', 's') }, - { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '1') }, - { CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'g', '1') }, - { CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'g', '2') }, - { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'p', 'g', '2') }, - { CODEC_ID_MPEG2VIDEO, MKTAG('M', 'P', 'E', 'G') }, - { CODEC_ID_MPEG1VIDEO, MKTAG('P', 'I', 'M', '1') }, - { CODEC_ID_MPEG2VIDEO, MKTAG('P', 'I', 'M', '2') }, - { CODEC_ID_MPEG1VIDEO, MKTAG('V', 'C', 'R', '2') }, - { CODEC_ID_MPEG1VIDEO, MKTAG( 1 , 0 , 0 , 16) }, - { CODEC_ID_MPEG2VIDEO, MKTAG( 2 , 0 , 0 , 16) }, - { CODEC_ID_MPEG4, MKTAG( 4 , 0 , 0 , 16) }, - { CODEC_ID_MPEG2VIDEO, MKTAG('D', 'V', 'R', ' ') }, - { CODEC_ID_MPEG2VIDEO, MKTAG('M', 'M', 'E', 'S') }, - { CODEC_ID_MPEG2VIDEO, MKTAG('L', 'M', 'P', '2') }, /* Lead MPEG2 in avi */ - { CODEC_ID_MPEG2VIDEO, MKTAG('s', 'l', 'i', 'f') }, - { CODEC_ID_MPEG2VIDEO, MKTAG('E', 'M', '2', 'V') }, - { CODEC_ID_MPEG2VIDEO, MKTAG('M', '7', '0', '1') }, /* Matrox MPEG2 intra-only */ - { CODEC_ID_MJPEG, MKTAG('M', 'J', 'P', 'G') }, - { CODEC_ID_MJPEG, MKTAG('L', 'J', 'P', 'G') }, - { CODEC_ID_MJPEG, MKTAG('d', 'm', 'b', '1') }, - { CODEC_ID_MJPEG, MKTAG('m', 'j', 'p', 'a') }, - { CODEC_ID_LJPEG, MKTAG('L', 'J', 'P', 'G') }, - { CODEC_ID_MJPEG, MKTAG('J', 'P', 'G', 'L') }, /* Pegasus lossless JPEG */ - { CODEC_ID_JPEGLS, MKTAG('M', 'J', 'L', 'S') }, /* JPEG-LS custom FOURCC for avi - encoder */ - { CODEC_ID_JPEGLS, MKTAG('M', 'J', 'P', 'G') }, - { CODEC_ID_MJPEG, MKTAG('M', 'J', 'L', 'S') }, /* JPEG-LS custom FOURCC for avi - decoder */ - { CODEC_ID_MJPEG, MKTAG('j', 'p', 'e', 'g') }, - { CODEC_ID_MJPEG, MKTAG('I', 'J', 'P', 'G') }, - { CODEC_ID_MJPEG, MKTAG('A', 'V', 'R', 'n') }, - { CODEC_ID_MJPEG, MKTAG('A', 'C', 'D', 'V') }, - { CODEC_ID_MJPEG, MKTAG('Q', 'I', 'V', 'G') }, - { CODEC_ID_MJPEG, MKTAG('S', 'L', 'M', 'J') }, /* SL M-JPEG */ - { CODEC_ID_MJPEG, MKTAG('C', 'J', 'P', 'G') }, /* Creative Webcam JPEG */ - { CODEC_ID_MJPEG, MKTAG('I', 'J', 'L', 'V') }, /* Intel JPEG Library Video Codec */ - { CODEC_ID_MJPEG, MKTAG('M', 'V', 'J', 'P') }, /* Midvid JPEG Video Codec */ - { CODEC_ID_MJPEG, MKTAG('A', 'V', 'I', '1') }, - { CODEC_ID_MJPEG, MKTAG('A', 'V', 'I', '2') }, - { CODEC_ID_MJPEG, MKTAG('M', 'T', 'S', 'J') }, - { CODEC_ID_MJPEG, MKTAG('Z', 'J', 'P', 'G') }, /* Paradigm Matrix M-JPEG Codec */ - { CODEC_ID_HUFFYUV, MKTAG('H', 'F', 'Y', 'U') }, - { CODEC_ID_FFVHUFF, MKTAG('F', 'F', 'V', 'H') }, - { CODEC_ID_CYUV, MKTAG('C', 'Y', 'U', 'V') }, - { CODEC_ID_RAWVIDEO, MKTAG( 0 , 0 , 0 , 0 ) }, - { CODEC_ID_RAWVIDEO, MKTAG( 3 , 0 , 0 , 0 ) }, - { CODEC_ID_RAWVIDEO, MKTAG('I', '4', '2', '0') }, - { CODEC_ID_RAWVIDEO, MKTAG('Y', 'U', 'Y', '2') }, - { CODEC_ID_RAWVIDEO, MKTAG('Y', '4', '2', '2') }, - { CODEC_ID_RAWVIDEO, MKTAG('V', '4', '2', '2') }, - { CODEC_ID_RAWVIDEO, MKTAG('Y', 'U', 'N', 'V') }, - { CODEC_ID_RAWVIDEO, MKTAG('U', 'Y', 'N', 'V') }, - { CODEC_ID_RAWVIDEO, MKTAG('U', 'Y', 'N', 'Y') }, - { CODEC_ID_RAWVIDEO, MKTAG('u', 'y', 'v', '1') }, - { CODEC_ID_RAWVIDEO, MKTAG('2', 'V', 'u', '1') }, - { CODEC_ID_RAWVIDEO, MKTAG('2', 'v', 'u', 'y') }, - { CODEC_ID_RAWVIDEO, MKTAG('y', 'u', 'v', 's') }, - { CODEC_ID_RAWVIDEO, MKTAG('P', '4', '2', '2') }, - { CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', '1', '2') }, - { CODEC_ID_RAWVIDEO, MKTAG('U', 'Y', 'V', 'Y') }, - { CODEC_ID_RAWVIDEO, MKTAG('V', 'Y', 'U', 'Y') }, - { CODEC_ID_RAWVIDEO, MKTAG('I', 'Y', 'U', 'V') }, - { CODEC_ID_RAWVIDEO, MKTAG('Y', '8', '0', '0') }, - { CODEC_ID_RAWVIDEO, MKTAG('H', 'D', 'Y', 'C') }, - { CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', 'U', '9') }, - { CODEC_ID_RAWVIDEO, MKTAG('V', 'D', 'T', 'Z') }, /* SoftLab-NSK VideoTizer */ - { CODEC_ID_RAWVIDEO, MKTAG('Y', '4', '1', '1') }, - { CODEC_ID_RAWVIDEO, MKTAG('N', 'V', '1', '2') }, - { CODEC_ID_RAWVIDEO, MKTAG('N', 'V', '2', '1') }, - { CODEC_ID_RAWVIDEO, MKTAG('Y', '4', '1', 'B') }, - { CODEC_ID_RAWVIDEO, MKTAG('Y', '4', '2', 'B') }, - { CODEC_ID_RAWVIDEO, MKTAG('Y', 'U', 'V', '9') }, - { CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', 'U', '9') }, - { CODEC_ID_FRWU, MKTAG('F', 'R', 'W', 'U') }, - { CODEC_ID_R10K, MKTAG('R', '1', '0', 'k') }, - { CODEC_ID_R210, MKTAG('r', '2', '1', '0') }, - { CODEC_ID_V210, MKTAG('v', '2', '1', '0') }, - { CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '1') }, - { CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '2') }, - { CODEC_ID_INDEO4, MKTAG('I', 'V', '4', '1') }, - { CODEC_ID_INDEO5, MKTAG('I', 'V', '5', '0') }, - { CODEC_ID_VP3, MKTAG('V', 'P', '3', '1') }, - { CODEC_ID_VP3, MKTAG('V', 'P', '3', '0') }, - { CODEC_ID_VP5, MKTAG('V', 'P', '5', '0') }, - { CODEC_ID_VP6, MKTAG('V', 'P', '6', '0') }, - { CODEC_ID_VP6, MKTAG('V', 'P', '6', '1') }, - { CODEC_ID_VP6, MKTAG('V', 'P', '6', '2') }, - { CODEC_ID_VP6F, MKTAG('V', 'P', '6', 'F') }, - { CODEC_ID_VP6F, MKTAG('F', 'L', 'V', '4') }, - { CODEC_ID_VP8, MKTAG('V', 'P', '8', '0') }, - { CODEC_ID_ASV1, MKTAG('A', 'S', 'V', '1') }, - { CODEC_ID_ASV2, MKTAG('A', 'S', 'V', '2') }, - { CODEC_ID_VCR1, MKTAG('V', 'C', 'R', '1') }, - { CODEC_ID_FFV1, MKTAG('F', 'F', 'V', '1') }, - { CODEC_ID_XAN_WC4, MKTAG('X', 'x', 'a', 'n') }, - { CODEC_ID_MIMIC, MKTAG('L', 'M', '2', '0') }, - { CODEC_ID_MSRLE, MKTAG('m', 'r', 'l', 'e') }, - { CODEC_ID_MSRLE, MKTAG( 1 , 0 , 0 , 0 ) }, - { CODEC_ID_MSRLE, MKTAG( 2 , 0 , 0 , 0 ) }, - { CODEC_ID_MSVIDEO1, MKTAG('M', 'S', 'V', 'C') }, - { CODEC_ID_MSVIDEO1, MKTAG('m', 's', 'v', 'c') }, - { CODEC_ID_MSVIDEO1, MKTAG('C', 'R', 'A', 'M') }, - { CODEC_ID_MSVIDEO1, MKTAG('c', 'r', 'a', 'm') }, - { CODEC_ID_MSVIDEO1, MKTAG('W', 'H', 'A', 'M') }, - { CODEC_ID_MSVIDEO1, MKTAG('w', 'h', 'a', 'm') }, - { CODEC_ID_CINEPAK, MKTAG('c', 'v', 'i', 'd') }, - { CODEC_ID_TRUEMOTION1, MKTAG('D', 'U', 'C', 'K') }, - { CODEC_ID_TRUEMOTION1, MKTAG('P', 'V', 'E', 'Z') }, - { CODEC_ID_MSZH, MKTAG('M', 'S', 'Z', 'H') }, - { CODEC_ID_ZLIB, MKTAG('Z', 'L', 'I', 'B') }, - { CODEC_ID_SNOW, MKTAG('S', 'N', 'O', 'W') }, - { CODEC_ID_4XM, MKTAG('4', 'X', 'M', 'V') }, - { CODEC_ID_FLV1, MKTAG('F', 'L', 'V', '1') }, - { CODEC_ID_FLASHSV, MKTAG('F', 'S', 'V', '1') }, - { CODEC_ID_SVQ1, MKTAG('s', 'v', 'q', '1') }, - { CODEC_ID_TSCC, MKTAG('t', 's', 'c', 'c') }, - { CODEC_ID_ULTI, MKTAG('U', 'L', 'T', 'I') }, - { CODEC_ID_VIXL, MKTAG('V', 'I', 'X', 'L') }, - { CODEC_ID_QPEG, MKTAG('Q', 'P', 'E', 'G') }, - { CODEC_ID_QPEG, MKTAG('Q', '1', '.', '0') }, - { CODEC_ID_QPEG, MKTAG('Q', '1', '.', '1') }, - { CODEC_ID_WMV3, MKTAG('W', 'M', 'V', '3') }, - { CODEC_ID_WMV3, MKTAG('W', 'M', 'V', 'P') }, - { CODEC_ID_VC1, MKTAG('W', 'V', 'C', '1') }, - { CODEC_ID_VC1, MKTAG('W', 'M', 'V', 'A') }, - { CODEC_ID_LOCO, MKTAG('L', 'O', 'C', 'O') }, - { CODEC_ID_WNV1, MKTAG('W', 'N', 'V', '1') }, - { CODEC_ID_AASC, MKTAG('A', 'A', 'S', 'C') }, - { CODEC_ID_INDEO2, MKTAG('R', 'T', '2', '1') }, - { CODEC_ID_FRAPS, MKTAG('F', 'P', 'S', '1') }, - { CODEC_ID_THEORA, MKTAG('t', 'h', 'e', 'o') }, - { CODEC_ID_TRUEMOTION2, MKTAG('T', 'M', '2', '0') }, - { CODEC_ID_CSCD, MKTAG('C', 'S', 'C', 'D') }, - { CODEC_ID_ZMBV, MKTAG('Z', 'M', 'B', 'V') }, - { CODEC_ID_KMVC, MKTAG('K', 'M', 'V', 'C') }, - { CODEC_ID_CAVS, MKTAG('C', 'A', 'V', 'S') }, - { CODEC_ID_JPEG2000, MKTAG('M', 'J', '2', 'C') }, - { CODEC_ID_VMNC, MKTAG('V', 'M', 'n', 'c') }, - { CODEC_ID_TARGA, MKTAG('t', 'g', 'a', ' ') }, - { CODEC_ID_PNG, MKTAG('M', 'P', 'N', 'G') }, - { CODEC_ID_PNG, MKTAG('P', 'N', 'G', '1') }, - { CODEC_ID_CLJR, MKTAG('c', 'l', 'j', 'r') }, - { CODEC_ID_DIRAC, MKTAG('d', 'r', 'a', 'c') }, - { CODEC_ID_RPZA, MKTAG('a', 'z', 'p', 'r') }, - { CODEC_ID_RPZA, MKTAG('R', 'P', 'Z', 'A') }, - { CODEC_ID_RPZA, MKTAG('r', 'p', 'z', 'a') }, - { CODEC_ID_SP5X, MKTAG('S', 'P', '5', '4') }, - { CODEC_ID_AURA, MKTAG('A', 'U', 'R', 'A') }, - { CODEC_ID_AURA2, MKTAG('A', 'U', 'R', '2') }, - { CODEC_ID_DPX, MKTAG('d', 'p', 'x', ' ') }, - { CODEC_ID_KGV1, MKTAG('K', 'G', 'V', '1') }, - { CODEC_ID_LAGARITH, MKTAG('L', 'A', 'G', 'S') }, - { CODEC_ID_NONE, 0 } -}; - -const struct mp_AVCodecTag mp_ff_codec_wav_tags[] = { - { CODEC_ID_PCM_S16LE, 0x0001 }, - { CODEC_ID_PCM_U8, 0x0001 }, /* must come after s16le in this list */ - { CODEC_ID_PCM_S24LE, 0x0001 }, - { CODEC_ID_PCM_S32LE, 0x0001 }, - { CODEC_ID_ADPCM_MS, 0x0002 }, - { CODEC_ID_PCM_F32LE, 0x0003 }, - { CODEC_ID_PCM_F64LE, 0x0003 }, /* must come after f32le in this list */ - { CODEC_ID_PCM_ALAW, 0x0006 }, - { CODEC_ID_PCM_MULAW, 0x0007 }, - { CODEC_ID_WMAVOICE, 0x000A }, - { CODEC_ID_ADPCM_IMA_WAV, 0x0011 }, - { CODEC_ID_PCM_ZORK, 0x0011 }, /* must come after adpcm_ima_wav in this list */ - { CODEC_ID_ADPCM_YAMAHA, 0x0020 }, - { CODEC_ID_TRUESPEECH, 0x0022 }, - { CODEC_ID_GSM_MS, 0x0031 }, - { CODEC_ID_ADPCM_G726, 0x0045 }, - { CODEC_ID_MP2, 0x0050 }, - { CODEC_ID_MP3, 0x0055 }, - { CODEC_ID_AMR_NB, 0x0057 }, - { CODEC_ID_AMR_WB, 0x0058 }, - { CODEC_ID_ADPCM_IMA_DK4, 0x0061 }, /* rogue format number */ - { CODEC_ID_ADPCM_IMA_DK3, 0x0062 }, /* rogue format number */ - { CODEC_ID_ADPCM_IMA_WAV, 0x0069 }, - { CODEC_ID_VOXWARE, 0x0075 }, - { CODEC_ID_AAC, 0x00ff }, - { CODEC_ID_SIPR, 0x0130 }, - { CODEC_ID_WMAV1, 0x0160 }, - { CODEC_ID_WMAV2, 0x0161 }, - { CODEC_ID_WMAPRO, 0x0162 }, - { CODEC_ID_WMALOSSLESS, 0x0163 }, - { CODEC_ID_ADPCM_CT, 0x0200 }, - { CODEC_ID_ATRAC3, 0x0270 }, - { CODEC_ID_ADPCM_G722, 0x028F }, - { CODEC_ID_IMC, 0x0401 }, - { CODEC_ID_GSM_MS, 0x1500 }, - { CODEC_ID_TRUESPEECH, 0x1501 }, - { CODEC_ID_AAC_LATM, 0x1602 }, - { CODEC_ID_AC3, 0x2000 }, - { CODEC_ID_DTS, 0x2001 }, - { CODEC_ID_SONIC, 0x2048 }, - { CODEC_ID_SONIC_LS, 0x2048 }, - { CODEC_ID_PCM_MULAW, 0x6c75 }, - { CODEC_ID_AAC, 0x706d }, - { CODEC_ID_AAC, 0x4143 }, - { CODEC_ID_FLAC, 0xF1AC }, - { CODEC_ID_ADPCM_SWF, ('S'<<8)+'F' }, - { CODEC_ID_VORBIS, ('V'<<8)+'o' }, //HACK/FIXME, does vorbis in WAV/AVI have an (in)official id? - - /* FIXME: All of the IDs below are not 16 bit and thus illegal. */ - // for NuppelVideo (nuv.c) - { CODEC_ID_PCM_S16LE, MKTAG('R', 'A', 'W', 'A') }, - { CODEC_ID_MP3, MKTAG('L', 'A', 'M', 'E') }, - { CODEC_ID_MP3, MKTAG('M', 'P', '3', ' ') }, - { CODEC_ID_NONE, 0 }, -}; - -static unsigned int ff_codec_get_tag(const struct mp_AVCodecTag *tags, int id) -{ - while (tags->id != CODEC_ID_NONE) { - if (tags->id == id) - return tags->tag; - tags++; - } - return 0; -} - -static enum CodecID ff_codec_get_id(const struct mp_AVCodecTag *tags, unsigned int tag) -{ - int i; - for(i=0; tags[i].id != CODEC_ID_NONE;i++) { - if(tag == tags[i].tag) - return tags[i].id; - } - for(i=0; tags[i].id != CODEC_ID_NONE; i++) { - if( toupper((tag >> 0)&0xFF) == toupper((tags[i].tag >> 0)&0xFF) - && toupper((tag >> 8)&0xFF) == toupper((tags[i].tag >> 8)&0xFF) - && toupper((tag >>16)&0xFF) == toupper((tags[i].tag >>16)&0xFF) - && toupper((tag >>24)&0xFF) == toupper((tags[i].tag >>24)&0xFF)) - return tags[i].id; - } - return CODEC_ID_NONE; -} - -unsigned int mp_av_codec_get_tag(const struct mp_AVCodecTag * const *tags, enum CodecID id) -{ - int i; - for(i=0; tags && tags[i]; i++){ - int tag= ff_codec_get_tag(tags[i], id); - if(tag) return tag; - } - return 0; -} - -enum CodecID mp_av_codec_get_id(const struct mp_AVCodecTag * const *tags, unsigned int tag) -{ - int i; - for(i=0; tags && tags[i]; i++){ - enum CodecID id= ff_codec_get_id(tags[i], tag); - if(id!=CODEC_ID_NONE) return id; - } - return CODEC_ID_NONE; -} diff -Nru mplayer2-2.0-426-gc32b3ed/ffmpeg_files/taglists.h mplayer2-2.0-554-gf63dbad/ffmpeg_files/taglists.h --- mplayer2-2.0-426-gc32b3ed/ffmpeg_files/taglists.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/ffmpeg_files/taglists.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -#include "libavcodec/avcodec.h" - -struct mp_AVCodecTag { - int id; - unsigned int tag; -}; - -unsigned int mp_av_codec_get_tag(const struct mp_AVCodecTag * const *tags, enum CodecID id); -enum CodecID mp_av_codec_get_id(const struct mp_AVCodecTag * const *tags, unsigned int tag); diff -Nru mplayer2-2.0-426-gc32b3ed/ffmpeg_files/x86/bswap.h mplayer2-2.0-554-gf63dbad/ffmpeg_files/x86/bswap.h --- mplayer2-2.0-426-gc32b3ed/ffmpeg_files/x86/bswap.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/ffmpeg_files/x86/bswap.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file libavutil/x86/bswap.h - * byte swapping routines - */ - -#ifndef MP_AVUTIL_X86_BSWAP_H -#define MP_AVUTIL_X86_BSWAP_H - -#include -#include "config.h" -#include "libavutil/common.h" - -#define bswap_16 bswap_16 -static av_always_inline av_const uint16_t bswap_16(uint16_t x) -{ - __asm__("rorw $8, %0" : "+r"(x)); - return x; -} - -#define bswap_32 bswap_32 -static av_always_inline av_const uint32_t bswap_32(uint32_t x) -{ -#if HAVE_BSWAP - __asm__("bswap %0" : "+r" (x)); -#else - __asm__("rorw $8, %w0 \n\t" - "rorl $16, %0 \n\t" - "rorw $8, %w0" - : "+r"(x)); -#endif - return x; -} - -#if ARCH_X86_64 -#define bswap_64 bswap_64 -static inline uint64_t av_const bswap_64(uint64_t x) -{ - __asm__("bswap %0": "=r" (x) : "0" (x)); - return x; -} -#endif - -#endif /* AVUTIL_X86_BSWAP_H */ diff -Nru mplayer2-2.0-426-gc32b3ed/input/input.c mplayer2-2.0-554-gf63dbad/input/input.c --- mplayer2-2.0-426-gc32b3ed/input/input.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/input/input.c 2012-05-17 14:38:00.000000000 +0000 @@ -31,11 +31,14 @@ #include #include +#include "osdep/io.h" + #include "input.h" #include "mp_fifo.h" #include "keycodes.h" #include "osdep/timer.h" #include "libavutil/avstring.h" +#include "libavutil/common.h" #include "mp_msg.h" #include "m_config.h" #include "m_option.h" @@ -56,6 +59,10 @@ #include "ar.h" +#ifdef CONFIG_COCOA +#include "osdep/cocoa_events.h" +#endif + #define MP_MAX_KEY_DOWN 32 struct cmd_bind { @@ -68,148 +75,152 @@ char *name; }; -/// This array defines all known commands. -/// The first field is an id used to recognize the command without too many strcmp. -/// The second is obviously the command name. -/// The third is the minimum number of arguments this command needs. -/// Then comes the definition of each argument, terminated with an arg of type -1. -/// A command can take a maximum of MP_CMD_MAX_ARGS-1 arguments (-1 because of -/// the last one) which is actually 9. - -/// For the args, the first field is the type (actually int, float or string), the second -/// is the default value wich is used for optional arguments +/* This array defines all known commands. + * The first field is an id used to recognize the command. + * The second is the command name used in slave mode and input.conf. + * Then comes the definition of each argument, first mandatory arguments + * (ARG_INT, ARG_FLOAT, ARG_STRING) if any, then optional arguments + * (OARG_INT(default), etc) if any. The command will be given the default + * argument value if the user didn't give enough arguments to specify it. + * A command can take a maximum of MP_CMD_MAX_ARGS arguments (10). + */ +#define ARG_INT { .type = MP_CMD_ARG_INT } +#define OARG_INT(def) { .type = MP_CMD_ARG_INT, .optional = true, .v.i = def } +#define ARG_FLOAT { .type = MP_CMD_ARG_FLOAT } +#define OARG_FLOAT(def) { .type = MP_CMD_ARG_FLOAT, .optional = true, .v.f = def } +#define ARG_STRING { .type = MP_CMD_ARG_STRING } +#define OARG_STRING(def) { .type = MP_CMD_ARG_STRING, .optional = true, .v.s = def } static const mp_cmd_t mp_cmds[] = { #ifdef CONFIG_RADIO - { MP_CMD_RADIO_STEP_CHANNEL, "radio_step_channel", 1, { { MP_CMD_ARG_INT ,{0}}, {-1,{0}} }}, - { MP_CMD_RADIO_SET_CHANNEL, "radio_set_channel", 1, { { MP_CMD_ARG_STRING, {0}}, {-1,{0}} }}, - { MP_CMD_RADIO_SET_FREQ, "radio_set_freq", 1, { {MP_CMD_ARG_FLOAT,{0}}, {-1,{0}} } }, - { MP_CMD_RADIO_STEP_FREQ, "radio_step_freq", 1, { {MP_CMD_ARG_FLOAT,{0}}, {-1,{0}} } }, -#endif - { MP_CMD_SEEK, "seek", 1, { {MP_CMD_ARG_FLOAT,{0}}, {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, - { MP_CMD_EDL_MARK, "edl_mark", 0, { {-1,{0}} } }, - { MP_CMD_AUDIO_DELAY, "audio_delay", 1, { {MP_CMD_ARG_FLOAT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, - { MP_CMD_SPEED_INCR, "speed_incr", 1, { {MP_CMD_ARG_FLOAT,{0}}, {-1,{0}} } }, - { MP_CMD_SPEED_MULT, "speed_mult", 1, { {MP_CMD_ARG_FLOAT,{0}}, {-1,{0}} } }, - { MP_CMD_SPEED_SET, "speed_set", 1, { {MP_CMD_ARG_FLOAT,{0}}, {-1,{0}} } }, - { MP_CMD_QUIT, "quit", 0, { {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, - { MP_CMD_STOP, "stop", 0, { {-1,{0}} } }, - { MP_CMD_PAUSE, "pause", 0, { {-1,{0}} } }, - { MP_CMD_FRAME_STEP, "frame_step", 0, { {-1,{0}} } }, - { MP_CMD_PLAY_TREE_STEP, "pt_step",1, { { MP_CMD_ARG_INT ,{0}}, { MP_CMD_ARG_INT ,{0}}, {-1,{0}} } }, - { MP_CMD_PLAY_TREE_UP_STEP, "pt_up_step",1, { { MP_CMD_ARG_INT,{0} }, { MP_CMD_ARG_INT ,{0}}, {-1,{0}} } }, - { MP_CMD_PLAY_ALT_SRC_STEP, "alt_src_step",1, { { MP_CMD_ARG_INT,{0} }, {-1,{0}} } }, - { MP_CMD_LOOP, "loop", 1, { {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, - { MP_CMD_SUB_DELAY, "sub_delay",1, { {MP_CMD_ARG_FLOAT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, - { MP_CMD_SUB_STEP, "sub_step",1, { { MP_CMD_ARG_INT,{0} }, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, - { MP_CMD_OSD, "osd",0, { {MP_CMD_ARG_INT,{-1}}, {-1,{0}} } }, - { MP_CMD_OSD_SHOW_TEXT, "osd_show_text", 1, { {MP_CMD_ARG_STRING, {0}}, {MP_CMD_ARG_INT,{-1}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, - { MP_CMD_OSD_SHOW_PROPERTY_TEXT, "osd_show_property_text",1, { {MP_CMD_ARG_STRING, {0}}, {MP_CMD_ARG_INT,{-1}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, - { MP_CMD_OSD_SHOW_PROGRESSION, "osd_show_progression", 0, { {-1,{0}} } }, - { MP_CMD_VOLUME, "volume", 1, { { MP_CMD_ARG_FLOAT,{0} }, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, - { MP_CMD_BALANCE, "balance", 1, { { MP_CMD_ARG_FLOAT,{0} }, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, - { MP_CMD_MIXER_USEMASTER, "use_master", 0, { {-1,{0}} } }, - { MP_CMD_MUTE, "mute", 0, { {MP_CMD_ARG_INT,{-1}}, {-1,{0}} } }, - { MP_CMD_CONTRAST, "contrast",1, { {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, - { MP_CMD_GAMMA, "gamma", 1, { {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, - { MP_CMD_BRIGHTNESS, "brightness",1, { {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, - { MP_CMD_HUE, "hue",1, { {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, - { MP_CMD_SATURATION, "saturation",1, { {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, - { MP_CMD_FRAMEDROPPING, "frame_drop",0, { { MP_CMD_ARG_INT,{-1} }, {-1,{0}} } }, - { MP_CMD_SUB_POS, "sub_pos", 1, { {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, - { MP_CMD_SUB_ALIGNMENT, "sub_alignment",0, { {MP_CMD_ARG_INT,{-1}}, {-1,{0}} } }, - { MP_CMD_SUB_VISIBILITY, "sub_visibility", 0, { {MP_CMD_ARG_INT,{-1}}, {-1,{0}} } }, - { MP_CMD_SUB_LOAD, "sub_load", 1, { {MP_CMD_ARG_STRING,{0}}, {-1,{0}} } }, - { MP_CMD_SUB_REMOVE, "sub_remove", 0, { {MP_CMD_ARG_INT,{-1}}, {-1,{0}} } }, - { MP_CMD_SUB_SELECT, "vobsub_lang", 0, { { MP_CMD_ARG_INT,{-2} }, {-1,{0}} } }, // for compatibility - { MP_CMD_SUB_SELECT, "sub_select", 0, { { MP_CMD_ARG_INT,{-2} }, {-1,{0}} } }, - { MP_CMD_SUB_SOURCE, "sub_source", 0, { { MP_CMD_ARG_INT,{-2} }, {-1,{0}} } }, - { MP_CMD_SUB_VOB, "sub_vob", 0, { { MP_CMD_ARG_INT,{-2} }, {-1,{0}} } }, - { MP_CMD_SUB_DEMUX, "sub_demux", 0, { { MP_CMD_ARG_INT,{-2} }, {-1,{0}} } }, - { MP_CMD_SUB_FILE, "sub_file", 0, { { MP_CMD_ARG_INT,{-2} }, {-1,{0}} } }, - { MP_CMD_SUB_LOG, "sub_log", 0, { {-1,{0}} } }, - { MP_CMD_SUB_SCALE, "sub_scale",1, { {MP_CMD_ARG_FLOAT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, + { MP_CMD_RADIO_STEP_CHANNEL, "radio_step_channel", { ARG_INT } }, + { MP_CMD_RADIO_SET_CHANNEL, "radio_set_channel", { ARG_STRING } }, + { MP_CMD_RADIO_SET_FREQ, "radio_set_freq", { ARG_FLOAT } }, + { MP_CMD_RADIO_STEP_FREQ, "radio_step_freq", {ARG_FLOAT } }, +#endif + { MP_CMD_SEEK, "seek", { ARG_FLOAT, OARG_INT(0), OARG_INT(0) } }, + { MP_CMD_EDL_MARK, "edl_mark", }, + { MP_CMD_AUDIO_DELAY, "audio_delay", { ARG_FLOAT, OARG_INT(0) } }, + { MP_CMD_SPEED_INCR, "speed_incr", { ARG_FLOAT } }, + { MP_CMD_SPEED_MULT, "speed_mult", { ARG_FLOAT } }, + { MP_CMD_SPEED_SET, "speed_set", { ARG_FLOAT } }, + { MP_CMD_QUIT, "quit", { OARG_INT(0) } }, + { MP_CMD_STOP, "stop", }, + { MP_CMD_PAUSE, "pause", }, + { MP_CMD_FRAME_STEP, "frame_step", }, + { MP_CMD_PLAY_TREE_STEP, "pt_step", { ARG_INT, OARG_INT(0) } }, + { MP_CMD_PLAY_TREE_UP_STEP, "pt_up_step", { ARG_INT, OARG_INT(0) } }, + { MP_CMD_PLAY_ALT_SRC_STEP, "alt_src_step", { ARG_INT } }, + { MP_CMD_LOOP, "loop", { ARG_INT, OARG_INT(0) } }, + { MP_CMD_SUB_DELAY, "sub_delay", { ARG_FLOAT, OARG_INT(0) } }, + { MP_CMD_SUB_STEP, "sub_step", { ARG_INT, OARG_INT(0) } }, + { MP_CMD_OSD, "osd", { OARG_INT(-1) } }, + { MP_CMD_OSD_SHOW_TEXT, "osd_show_text", { ARG_STRING, OARG_INT(-1), OARG_INT(0) } }, + { MP_CMD_OSD_SHOW_PROPERTY_TEXT, "osd_show_property_text", { ARG_STRING, OARG_INT(-1), OARG_INT(0) } }, + { MP_CMD_OSD_SHOW_PROGRESSION, "osd_show_progression", }, + { MP_CMD_VOLUME, "volume", { ARG_FLOAT, OARG_INT(0) } }, + { MP_CMD_BALANCE, "balance", { ARG_FLOAT, OARG_INT(0) } }, + { MP_CMD_MIXER_USEMASTER, "use_master", }, + { MP_CMD_MUTE, "mute", { OARG_INT(-1) } }, + { MP_CMD_CONTRAST, "contrast", { ARG_INT, OARG_INT(0) } }, + { MP_CMD_GAMMA, "gamma", { ARG_INT, OARG_INT(0) } }, + { MP_CMD_BRIGHTNESS, "brightness", { ARG_INT, OARG_INT(0) } }, + { MP_CMD_HUE, "hue", { ARG_INT, OARG_INT(0) } }, + { MP_CMD_SATURATION, "saturation", { ARG_INT, OARG_INT(0) } }, + { MP_CMD_FRAMEDROPPING, "frame_drop", { OARG_INT(-1) } }, + { MP_CMD_SUB_POS, "sub_pos", { ARG_INT, OARG_INT(0) } }, + { MP_CMD_SUB_ALIGNMENT, "sub_alignment", { OARG_INT(-1) } }, + { MP_CMD_SUB_VISIBILITY, "sub_visibility", { OARG_INT(-1) } }, + { MP_CMD_SUB_LOAD, "sub_load", { ARG_STRING } }, + { MP_CMD_SUB_REMOVE, "sub_remove", { OARG_INT(-1) } }, + { MP_CMD_SUB_SELECT, "vobsub_lang", { OARG_INT(-2) } }, // for compatibility + { MP_CMD_SUB_SELECT, "sub_select", { OARG_INT(-2) } }, + { MP_CMD_SUB_SOURCE, "sub_source", { OARG_INT(-2) } }, + { MP_CMD_SUB_VOB, "sub_vob", { OARG_INT(-2) } }, + { MP_CMD_SUB_DEMUX, "sub_demux", { OARG_INT(-2) } }, + { MP_CMD_SUB_FILE, "sub_file", { OARG_INT(-2) } }, + { MP_CMD_SUB_LOG, "sub_log", }, + { MP_CMD_SUB_SCALE, "sub_scale", { ARG_FLOAT, OARG_INT(0) } }, #ifdef CONFIG_ASS - { MP_CMD_ASS_USE_MARGINS, "ass_use_margins", 0, { {MP_CMD_ARG_INT,{-1}}, {-1,{0}} } }, + { MP_CMD_ASS_USE_MARGINS, "ass_use_margins", { OARG_INT(-1) } }, #endif - { MP_CMD_GET_PERCENT_POS, "get_percent_pos", 0, { {-1,{0}} } }, - { MP_CMD_GET_TIME_POS, "get_time_pos", 0, { {-1,{0}} } }, - { MP_CMD_GET_TIME_LENGTH, "get_time_length", 0, { {-1,{0}} } }, - { MP_CMD_GET_FILENAME, "get_file_name", 0, { {-1,{0}} } }, - { MP_CMD_GET_VIDEO_CODEC, "get_video_codec", 0, { {-1,{0}} } }, - { MP_CMD_GET_VIDEO_BITRATE, "get_video_bitrate", 0, { {-1,{0}} } }, - { MP_CMD_GET_VIDEO_RESOLUTION, "get_video_resolution", 0, { {-1,{0}} } }, - { MP_CMD_GET_AUDIO_CODEC, "get_audio_codec", 0, { {-1,{0}} } }, - { MP_CMD_GET_AUDIO_BITRATE, "get_audio_bitrate", 0, { {-1,{0}} } }, - { MP_CMD_GET_AUDIO_SAMPLES, "get_audio_samples", 0, { {-1,{0}} } }, - { MP_CMD_GET_META_TITLE, "get_meta_title", 0, { {-1,{0}} } }, - { MP_CMD_GET_META_ARTIST, "get_meta_artist", 0, { {-1,{0}} } }, - { MP_CMD_GET_META_ALBUM, "get_meta_album", 0, { {-1,{0}} } }, - { MP_CMD_GET_META_YEAR, "get_meta_year", 0, { {-1,{0}} } }, - { MP_CMD_GET_META_COMMENT, "get_meta_comment", 0, { {-1,{0}} } }, - { MP_CMD_GET_META_TRACK, "get_meta_track", 0, { {-1,{0}} } }, - { MP_CMD_GET_META_GENRE, "get_meta_genre", 0, { {-1,{0}} } }, - { MP_CMD_SWITCH_AUDIO, "switch_audio", 0, { { MP_CMD_ARG_INT,{-1} }, {-1,{0}} } }, - { MP_CMD_SWITCH_ANGLE, "switch_angle", 0, { { MP_CMD_ARG_INT,{-1} }, {-1,{0}} } }, - { MP_CMD_SWITCH_TITLE, "switch_title", 0, { { MP_CMD_ARG_INT,{-1} }, {-1,{0}} } }, + { MP_CMD_GET_PERCENT_POS, "get_percent_pos", }, + { MP_CMD_GET_TIME_POS, "get_time_pos", }, + { MP_CMD_GET_TIME_LENGTH, "get_time_length", }, + { MP_CMD_GET_FILENAME, "get_file_name", }, + { MP_CMD_GET_VIDEO_CODEC, "get_video_codec", }, + { MP_CMD_GET_VIDEO_BITRATE, "get_video_bitrate", }, + { MP_CMD_GET_VIDEO_RESOLUTION, "get_video_resolution", }, + { MP_CMD_GET_AUDIO_CODEC, "get_audio_codec", }, + { MP_CMD_GET_AUDIO_BITRATE, "get_audio_bitrate", }, + { MP_CMD_GET_AUDIO_SAMPLES, "get_audio_samples", }, + { MP_CMD_GET_META_TITLE, "get_meta_title", }, + { MP_CMD_GET_META_ARTIST, "get_meta_artist", }, + { MP_CMD_GET_META_ALBUM, "get_meta_album", }, + { MP_CMD_GET_META_YEAR, "get_meta_year", }, + { MP_CMD_GET_META_COMMENT, "get_meta_comment", }, + { MP_CMD_GET_META_TRACK, "get_meta_track", }, + { MP_CMD_GET_META_GENRE, "get_meta_genre", }, + { MP_CMD_SWITCH_AUDIO, "switch_audio", { OARG_INT(-1) } }, + { MP_CMD_SWITCH_ANGLE, "switch_angle", { OARG_INT(-1) } }, + { MP_CMD_SWITCH_TITLE, "switch_title", { OARG_INT(-1) } }, #ifdef CONFIG_TV - { MP_CMD_TV_START_SCAN, "tv_start_scan", 0, { {-1,{0}} }}, - { MP_CMD_TV_STEP_CHANNEL, "tv_step_channel", 1, { { MP_CMD_ARG_INT ,{0}}, {-1,{0}} }}, - { MP_CMD_TV_STEP_NORM, "tv_step_norm",0, { {-1,{0}} } }, - { MP_CMD_TV_STEP_CHANNEL_LIST, "tv_step_chanlist", 0, { {-1,{0}} } }, - { MP_CMD_TV_SET_CHANNEL, "tv_set_channel", 1, { { MP_CMD_ARG_STRING, {0}}, {-1,{0}} }}, - { MP_CMD_TV_LAST_CHANNEL, "tv_last_channel", 0, { {-1,{0}} } }, - { MP_CMD_TV_SET_FREQ, "tv_set_freq", 1, { {MP_CMD_ARG_FLOAT,{0}}, {-1,{0}} } }, - { MP_CMD_TV_STEP_FREQ, "tv_step_freq", 1, { {MP_CMD_ARG_FLOAT,{0}}, {-1,{0}} } }, - { MP_CMD_TV_SET_NORM, "tv_set_norm", 1, { {MP_CMD_ARG_STRING,{0}}, {-1,{0}} } }, - { MP_CMD_TV_SET_BRIGHTNESS, "tv_set_brightness", 1, { { MP_CMD_ARG_INT ,{0}}, { MP_CMD_ARG_INT,{1} }, {-1,{0}} }}, - { MP_CMD_TV_SET_CONTRAST, "tv_set_contrast", 1, { { MP_CMD_ARG_INT ,{0}}, { MP_CMD_ARG_INT,{1} }, {-1,{0}} }}, - { MP_CMD_TV_SET_HUE, "tv_set_hue", 1, { { MP_CMD_ARG_INT ,{0}}, { MP_CMD_ARG_INT,{1} }, {-1,{0}} }}, - { MP_CMD_TV_SET_SATURATION, "tv_set_saturation", 1, { { MP_CMD_ARG_INT ,{0}}, { MP_CMD_ARG_INT,{1} }, {-1,{0}} }}, + { MP_CMD_TV_START_SCAN, "tv_start_scan", }, + { MP_CMD_TV_STEP_CHANNEL, "tv_step_channel", { ARG_INT } }, + { MP_CMD_TV_STEP_NORM, "tv_step_norm", }, + { MP_CMD_TV_STEP_CHANNEL_LIST, "tv_step_chanlist", }, + { MP_CMD_TV_SET_CHANNEL, "tv_set_channel", { ARG_STRING } }, + { MP_CMD_TV_LAST_CHANNEL, "tv_last_channel", }, + { MP_CMD_TV_SET_FREQ, "tv_set_freq", { ARG_FLOAT } }, + { MP_CMD_TV_STEP_FREQ, "tv_step_freq", { ARG_FLOAT } }, + { MP_CMD_TV_SET_NORM, "tv_set_norm", { ARG_STRING } }, + { MP_CMD_TV_SET_BRIGHTNESS, "tv_set_brightness", { ARG_INT, OARG_INT(1) } }, + { MP_CMD_TV_SET_CONTRAST, "tv_set_contrast", { ARG_INT, OARG_INT(1) } }, + { MP_CMD_TV_SET_HUE, "tv_set_hue", { ARG_INT, OARG_INT(1) } }, + { MP_CMD_TV_SET_SATURATION, "tv_set_saturation", { ARG_INT, OARG_INT(1) } }, #endif - { MP_CMD_SUB_FORCED_ONLY, "forced_subs_only", 0, { {MP_CMD_ARG_INT,{-1}}, {-1,{0}} } }, + { MP_CMD_SUB_FORCED_ONLY, "forced_subs_only", { OARG_INT(-1) } }, #ifdef CONFIG_DVBIN - { MP_CMD_DVB_SET_CHANNEL, "dvb_set_channel", 2, { {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}}}}, + { MP_CMD_DVB_SET_CHANNEL, "dvb_set_channel", { ARG_INT, ARG_INT } }, #endif - { MP_CMD_SWITCH_RATIO, "switch_ratio", 0, { {MP_CMD_ARG_FLOAT,{0}}, {-1,{0}} } }, - { MP_CMD_VO_FULLSCREEN, "vo_fullscreen", 0, { {MP_CMD_ARG_INT,{-1}}, {-1,{0}} } }, - { MP_CMD_VO_ONTOP, "vo_ontop", 0, { {MP_CMD_ARG_INT,{-1}}, {-1,{0}} } }, - { MP_CMD_VO_ROOTWIN, "vo_rootwin", 0, { {MP_CMD_ARG_INT,{-1}}, {-1,{0}} } }, - { MP_CMD_VO_BORDER, "vo_border", 0, { {MP_CMD_ARG_INT,{-1}}, {-1,{0}} } }, - { MP_CMD_SCREENSHOT, "screenshot", 0, { {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, - { MP_CMD_PANSCAN, "panscan",1, { {MP_CMD_ARG_FLOAT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, - { MP_CMD_SWITCH_VSYNC, "switch_vsync", 0, { {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, - { MP_CMD_LOADFILE, "loadfile", 1, { {MP_CMD_ARG_STRING, {0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, - { MP_CMD_LOADLIST, "loadlist", 1, { {MP_CMD_ARG_STRING, {0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, - { MP_CMD_RUN, "run", 1, { {MP_CMD_ARG_STRING,{0}}, {-1,{0}} } }, - { MP_CMD_CAPTURING, "capturing", 0, { {-1,{0}} } }, - { MP_CMD_VF_CHANGE_RECTANGLE, "change_rectangle", 2, { {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}}}}, - { MP_CMD_TV_TELETEXT_ADD_DEC, "teletext_add_dec", 1, { {MP_CMD_ARG_STRING,{0}}, {-1,{0}} } }, - { MP_CMD_TV_TELETEXT_GO_LINK, "teletext_go_link", 1, { {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, + { MP_CMD_SWITCH_RATIO, "switch_ratio", { OARG_FLOAT(0) } }, + { MP_CMD_VO_FULLSCREEN, "vo_fullscreen", { OARG_INT(-1) } }, + { MP_CMD_VO_ONTOP, "vo_ontop", { OARG_INT(-1) } }, + { MP_CMD_VO_ROOTWIN, "vo_rootwin", { OARG_INT(-1) } }, + { MP_CMD_VO_BORDER, "vo_border", { OARG_INT(-1) } }, + { MP_CMD_SCREENSHOT, "screenshot", { OARG_INT(0), OARG_INT(0) } }, + { MP_CMD_PANSCAN, "panscan", { ARG_FLOAT, OARG_INT(0) } }, + { MP_CMD_SWITCH_VSYNC, "switch_vsync", { OARG_INT(0) } }, + { MP_CMD_LOADFILE, "loadfile", { ARG_STRING, OARG_INT(0) } }, + { MP_CMD_LOADLIST, "loadlist", { ARG_STRING, OARG_INT(0) } }, + { MP_CMD_RUN, "run", { ARG_STRING } }, + { MP_CMD_CAPTURING, "capturing", }, + { MP_CMD_VF_CHANGE_RECTANGLE, "change_rectangle", { ARG_INT, ARG_INT } }, + { MP_CMD_TV_TELETEXT_ADD_DEC, "teletext_add_dec", { ARG_STRING } }, + { MP_CMD_TV_TELETEXT_GO_LINK, "teletext_go_link", { ARG_INT } }, #ifdef CONFIG_DVDNAV - { MP_CMD_DVDNAV, "dvdnav", 1, { {MP_CMD_ARG_STRING, {0}}, {-1,{0}} } }, + { MP_CMD_DVDNAV, "dvdnav", { ARG_STRING } }, #endif - { MP_CMD_GET_VO_FULLSCREEN, "get_vo_fullscreen", 0, { {-1,{0}} } }, - { MP_CMD_GET_SUB_VISIBILITY, "get_sub_visibility", 0, { {-1,{0}} } }, - { MP_CMD_KEYDOWN_EVENTS, "key_down_event", 1, { {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, - { MP_CMD_SET_PROPERTY, "set_property", 2, { {MP_CMD_ARG_STRING, {0}}, {MP_CMD_ARG_STRING, {0}}, {-1,{0}} } }, - { MP_CMD_SET_PROPERTY_OSD, "set_property_osd", 2, { {MP_CMD_ARG_STRING, {0}}, {MP_CMD_ARG_STRING, {0}}, {-1,{0}} } }, - { MP_CMD_GET_PROPERTY, "get_property", 1, { {MP_CMD_ARG_STRING, {0}}, {-1,{0}} } }, - { MP_CMD_STEP_PROPERTY, "step_property", 1, { {MP_CMD_ARG_STRING, {0}}, {MP_CMD_ARG_FLOAT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, - { MP_CMD_STEP_PROPERTY_OSD, "step_property_osd", 1, { {MP_CMD_ARG_STRING, {0}}, {MP_CMD_ARG_FLOAT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, - - { MP_CMD_SEEK_CHAPTER, "seek_chapter", 1, { {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, - { MP_CMD_SET_MOUSE_POS, "set_mouse_pos", 2, { {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, - - { MP_CMD_AF_SWITCH, "af_switch", 1, { {MP_CMD_ARG_STRING, {0}}, {-1,{0}} } }, - { MP_CMD_AF_ADD, "af_add", 1, { {MP_CMD_ARG_STRING, {0}}, {-1,{0}} } }, - { MP_CMD_AF_DEL, "af_del", 1, { {MP_CMD_ARG_STRING, {0}}, {-1,{0}} } }, - { MP_CMD_AF_CLR, "af_clr", 0, { {-1,{0}} } }, - { MP_CMD_AF_CMDLINE, "af_cmdline", 2, { {MP_CMD_ARG_STRING, {0}}, {MP_CMD_ARG_STRING, {0}}, {-1,{0}} } }, - - { 0, NULL, 0, {} } + { MP_CMD_GET_VO_FULLSCREEN, "get_vo_fullscreen", }, + { MP_CMD_GET_SUB_VISIBILITY, "get_sub_visibility", }, + { MP_CMD_KEYDOWN_EVENTS, "key_down_event", { ARG_INT } }, + { MP_CMD_SET_PROPERTY, "set_property", { ARG_STRING, ARG_STRING } }, + { MP_CMD_SET_PROPERTY_OSD, "set_property_osd", { ARG_STRING, ARG_STRING } }, + { MP_CMD_GET_PROPERTY, "get_property", { ARG_STRING } }, + { MP_CMD_STEP_PROPERTY, "step_property", { ARG_STRING, OARG_FLOAT(0), OARG_INT(0) } }, + { MP_CMD_STEP_PROPERTY_OSD, "step_property_osd", { ARG_STRING, OARG_FLOAT(0), OARG_INT(0) } }, + + { MP_CMD_SEEK_CHAPTER, "seek_chapter", { ARG_INT, OARG_INT(0) } }, + { MP_CMD_SET_MOUSE_POS, "set_mouse_pos", { ARG_INT, ARG_INT } }, + + { MP_CMD_AF_SWITCH, "af_switch", { ARG_STRING } }, + { MP_CMD_AF_ADD, "af_add", { ARG_STRING } }, + { MP_CMD_AF_DEL, "af_del", { ARG_STRING } }, + { MP_CMD_AF_CLR, "af_clr", }, + { MP_CMD_AF_CMDLINE, "af_cmdline", { ARG_STRING, ARG_STRING } }, + {0} }; /// The names of the keys as used in input.conf @@ -228,6 +239,7 @@ { KEY_PAGE_UP, "PGUP" }, { KEY_PAGE_DOWN, "PGDWN" }, { KEY_ESC, "ESC" }, + { KEY_PRINT, "PRINT" }, { KEY_RIGHT, "RIGHT" }, { KEY_LEFT, "LEFT" }, { KEY_DOWN, "DOWN" }, @@ -614,21 +626,23 @@ struct cmd_queue key_cmd_queue; struct cmd_queue control_cmd_queue; + + int wakeup_pipe[2]; }; int async_quit_request; -static int print_key_list(m_option_t *cfg); -static int print_cmd_list(m_option_t *cfg); +static int print_key_list(m_option_t *cfg, char *optname, char *optparam); +static int print_cmd_list(m_option_t *cfg, char *optname, char *optparam); // Our command line options static const m_option_t input_conf[] = { OPT_STRING("conf", input.config_file, CONF_GLOBAL), OPT_INT("ar-delay", input.ar_delay, CONF_GLOBAL), OPT_INT("ar-rate", input.ar_rate, CONF_GLOBAL), - { "keylist", print_key_list, CONF_TYPE_FUNC, CONF_GLOBAL, 0, 0, NULL }, - { "cmdlist", print_cmd_list, CONF_TYPE_FUNC, CONF_GLOBAL, 0, 0, NULL }, + { "keylist", print_key_list, CONF_TYPE_PRINT_FUNC, CONF_NOCFG }, + { "cmdlist", print_cmd_list, CONF_TYPE_PRINT_FUNC, CONF_NOCFG }, OPT_STRING("js-dev", input.js_dev, CONF_GLOBAL), OPT_STRING("ar-dev", input.ar_dev, CONF_GLOBAL), OPT_STRING("file", input.in_file, CONF_GLOBAL), @@ -647,6 +661,17 @@ static int default_cmd_func(int fd, char *buf, int l); +// Encode the unicode codepoint as UTF-8, and append to the end of the +// talloc'ed buffer. +static char *append_utf8_buffer(char *buffer, uint32_t codepoint) +{ + char data[8]; + uint8_t tmp; + char *output = data; + PUT_UTF8(codepoint, tmp, *output++ = tmp;); + return talloc_strndup_append_buffer(buffer, data, output - data); +} + static char *get_key_name(int key, char *ret) { for (int i = 0; modifier_names[i].name; i++) { @@ -661,8 +686,9 @@ return talloc_asprintf_append_buffer(ret, "%s", key_names[i].name); } - if (isascii(key)) - return talloc_asprintf_append_buffer(ret, "%c", key); + // printable, and valid unicode range + if (key >= 32 && key <= 0x10FFFF) + return append_utf8_buffer(ret, key); // Print the hex key code return talloc_asprintf_append_buffer(ret, "%#-8x", key); @@ -945,7 +971,7 @@ *argptr = 0; break; } - case -1: + case 0: ptr = NULL; break; default: @@ -954,14 +980,18 @@ } cmd->nargs = i; - if (cmd_def->nargs > cmd->nargs) { - mp_tmsg(MSGT_INPUT, MSGL_ERR, "Command %s requires at least %d " + int min_args; + for (min_args = 0; min_args < MP_CMD_MAX_ARGS + && cmd_def->args[min_args].type + && !cmd_def->args[min_args].optional; min_args++); + if (cmd->nargs < min_args) { + mp_tmsg(MSGT_INPUT, MSGL_ERR, "Command \"%s\" requires at least %d " "arguments, we found only %d so far.\n", cmd_def->name, - cmd_def->nargs, cmd->nargs); + min_args, cmd->nargs); goto error; } - for (; i < MP_CMD_MAX_ARGS && cmd_def->args[i].type != -1; i++) { + for (; i < MP_CMD_MAX_ARGS && cmd_def->args[i].type; i++) { memcpy(&cmd->args[i], &cmd_def->args[i], sizeof(struct mp_cmd_arg)); if (cmd_def->args[i].type == MP_CMD_ARG_STRING && cmd_def->args[i].v.s != NULL) @@ -969,7 +999,7 @@ } if (i < MP_CMD_MAX_ARGS) - cmd->args[i].type = -1; + cmd->args[i].type = 0; return cmd; @@ -1080,6 +1110,13 @@ } } +static int read_wakeup(void *ctx, int fd) +{ + char buf[100]; + read(fd, buf, sizeof(buf)); + return MP_INPUT_NOTHING; +} + static char *find_bind_for_key(const struct cmd_bind *binds, int n, int *keys) { @@ -1102,7 +1139,7 @@ } static struct cmd_bind_section *get_bind_section(struct input_ctx *ictx, - char *section) + char *section) { struct cmd_bind_section *bind_section = ictx->cmd_bind_sections; @@ -1171,7 +1208,7 @@ * shift modifier is still kept for special keys like arrow keys. */ int unmod = code & ~KEY_MODIFIER_MASK; - if (unmod < 256 && unmod != KEY_ENTER && unmod != KEY_TAB) + if (unmod >= 32 && unmod < MP_KEY_BASE) code &= ~KEY_MODIFIER_SHIFT; if (code & MP_KEY_DOWN) { @@ -1403,7 +1440,7 @@ * every source until it's known to be empty. Instead we use this wrapper * to run select() again. */ -static void read_all_events(struct input_ctx *ictx, int time) +static void read_all_fd_events(struct input_ctx *ictx, int time) { while (1) { read_events(ictx, time); @@ -1413,6 +1450,15 @@ } } +static void read_all_events(struct input_ctx *ictx, int time) +{ +#ifdef CONFIG_COCOA + cocoa_events_read_all_events(ictx, time); +#else + read_all_fd_events(ictx, time); +#endif +} + int mp_input_queue_cmd(struct input_ctx *ictx, mp_cmd_t *cmd) { ictx->got_new_events = true; @@ -1464,7 +1510,7 @@ ret = talloc_memdup(NULL, cmd, sizeof(mp_cmd_t)); ret->name = talloc_strdup(ret, cmd->name); - for (i = 0; i < MP_CMD_MAX_ARGS && cmd->args[i].type != -1; i++) { + for (i = 0; i < MP_CMD_MAX_ARGS && cmd->args[i].type; i++) { if (cmd->args[i].type == MP_CMD_ARG_STRING && cmd->args[i].v.s != NULL) ret->args[i].v.s = talloc_strdup(ret, cmd->args[i].v.s); } @@ -1489,10 +1535,15 @@ found: name = p + 1; } - int len = strlen(name); - if (len == 1) // Direct key code - return (unsigned char)name[0] + modifiers; - else if (len > 2 && strncasecmp("0x", name, 2) == 0) + + struct bstr bname = bstr(name); + + struct bstr rest; + int code = bstr_decode_utf8(bname, &rest); + if (code >= 0 && rest.len == 0) + return code + modifiers; + + if (bstr_startswith0(bname, "0x")) return strtol(name, NULL, 16) + modifiers; for (int i = 0; key_names[i].name != NULL; i++) { @@ -1702,8 +1753,29 @@ .ar_delay = input_conf->ar_delay, .ar_rate = input_conf->ar_rate, .default_bindings = input_conf->default_bindings, + .wakeup_pipe = {-1, -1}, }; +#ifdef CONFIG_COCOA + cocoa_events_init(ictx, read_all_fd_events); +#endif + +#ifndef __MINGW32__ + long ret = pipe(ictx->wakeup_pipe); + for (int i = 0; i < 2 && ret >= 0; i++) { + ret = fcntl(ictx->wakeup_pipe[i], F_GETFL); + if (ret < 0) + break; + ret = fcntl(ictx->wakeup_pipe[i], F_SETFL, ret | O_NONBLOCK); + } + if (ret < 0) + mp_msg(MSGT_INPUT, MSGL_ERR, + "Failed to initialize wakeup pipe: %s\n", strerror(errno)); + else + mp_input_add_key_fd(ictx, ictx->wakeup_pipe[0], true, read_wakeup, + NULL, NULL); +#endif + char *file; char *config_file = input_conf->config_file; file = config_file[0] != '/' ? get_path(config_file) : config_file; @@ -1776,13 +1848,16 @@ #endif if (input_conf->in_file) { - struct stat st; - int mode = O_RDONLY | O_NONBLOCK; + int mode = O_RDONLY; +#ifndef __MINGW32__ // Use RDWR for FIFOs to ensure they stay open over multiple accesses. - // Note that on Windows stat may fail for named pipes, - // but due to how the API works, using RDONLY should be ok. + // Note that on Windows due to how the API works, using RDONLY should + // be ok. + struct stat st; if (stat(input_conf->in_file, &st) == 0 && S_ISFIFO(st.st_mode)) - mode = O_RDWR | O_NONBLOCK; + mode = O_RDWR; + mode |= O_NONBLOCK; +#endif int in_file_fd = open(input_conf->in_file, mode); if (in_file_fd >= 0) mp_input_add_cmd_fd(ictx, in_file_fd, 1, NULL, close); @@ -1790,25 +1865,30 @@ mp_tmsg(MSGT_INPUT, MSGL_ERR, "Can't open %s: %s\n", input_conf->in_file, strerror(errno)); } + return ictx; } void mp_input_uninit(struct input_ctx *ictx) { +#ifdef CONFIG_COCOA + cocoa_events_uninit(); +#endif + if (!ictx) return; - unsigned int i; - - for (i = 0; i < ictx->num_key_fd; i++) { + for (int i = 0; i < ictx->num_key_fd; i++) { if (ictx->key_fds[i].close_func) ictx->key_fds[i].close_func(ictx->key_fds[i].fd); } - - for (i = 0; i < ictx->num_cmd_fd; i++) { + for (int i = 0; i < ictx->num_cmd_fd; i++) { if (ictx->cmd_fds[i].close_func) ictx->cmd_fds[i].close_func(ictx->cmd_fds[i].fd); } + for (int i = 0; i < 2; i++) + if (ictx->wakeup_pipe[i] != -1) + close(ictx->wakeup_pipe[i]); talloc_free(ictx); } @@ -1817,16 +1897,16 @@ m_config_register_options(cfg, mp_input_opts); } -static int print_key_list(m_option_t *cfg) +static int print_key_list(m_option_t *cfg, char *optname, char *optparam) { int i; printf("\n"); for (i = 0; key_names[i].name != NULL; i++) printf("%s\n", key_names[i].name); - exit(0); + return M_OPT_EXIT; } -static int print_cmd_list(m_option_t *cfg) +static int print_cmd_list(m_option_t *cfg, char *optname, char *optparam) { const mp_cmd_t *cmd; int i, j; @@ -1834,7 +1914,7 @@ for (i = 0; (cmd = &mp_cmds[i])->name != NULL; i++) { printf("%-20.20s", cmd->name); - for (j = 0; j < MP_CMD_MAX_ARGS && cmd->args[j].type != -1; j++) { + for (j = 0; j < MP_CMD_MAX_ARGS && cmd->args[j].type; j++) { switch (cmd->args[j].type) { case MP_CMD_ARG_INT: type = "Integer"; @@ -1848,14 +1928,20 @@ default: type = "??"; } - if (j + 1 > cmd->nargs) + if (cmd->args[j].optional) printf(" [%s]", type); else printf(" %s", type); } printf("\n"); } - exit(0); + return M_OPT_EXIT; +} + +void mp_input_wakeup(struct input_ctx *ictx) +{ + if (ictx->wakeup_pipe[1] >= 0) + write(ictx->wakeup_pipe[1], &(char){0}, 1); } /** diff -Nru mplayer2-2.0-426-gc32b3ed/input/input.h mplayer2-2.0-554-gf63dbad/input/input.h --- mplayer2-2.0-426-gc32b3ed/input/input.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/input/input.h 2012-05-17 14:38:00.000000000 +0000 @@ -19,6 +19,8 @@ #ifndef MPLAYER_INPUT_H #define MPLAYER_INPUT_H +#include + // All command IDs enum mp_command_type { MP_CMD_SEEK, @@ -153,14 +155,11 @@ }; // The arg types -#define MP_CMD_ARG_INT 0 -#define MP_CMD_ARG_FLOAT 1 -#define MP_CMD_ARG_STRING 2 -#define MP_CMD_ARG_VOID 3 +#define MP_CMD_ARG_INT 1 +#define MP_CMD_ARG_FLOAT 2 +#define MP_CMD_ARG_STRING 3 -#ifndef MP_CMD_MAX_ARGS #define MP_CMD_MAX_ARGS 10 -#endif // Error codes for the drivers @@ -180,19 +179,19 @@ struct mp_cmd_arg { int type; + bool optional; union { int i; float f; char *s; - void *v; } v; }; typedef struct mp_cmd { int id; char *name; - int nargs; struct mp_cmd_arg args[MP_CMD_MAX_ARGS]; + int nargs; int pausing; struct mp_cmd *queue_prev; struct mp_cmd *queue_next; @@ -273,6 +272,9 @@ struct m_config; void mp_input_register_options(struct m_config *cfg); +// Wake up sleeping input loop from another thread. +void mp_input_wakeup(struct input_ctx *ictx); + // Interruptible usleep: (used by libmpdemux) int mp_input_check_interrupt(struct input_ctx *ictx, int time); diff -Nru mplayer2-2.0-426-gc32b3ed/input/keycodes.h mplayer2-2.0-554-gf63dbad/input/keycodes.h --- mplayer2-2.0-426-gc32b3ed/input/keycodes.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/input/keycodes.h 2012-05-17 14:38:00.000000000 +0000 @@ -21,19 +21,16 @@ #ifndef MPLAYER_KEYCODES_H #define MPLAYER_KEYCODES_H +#define MP_KEY_BASE (1<<21) + // For appleir.c which includes another header with KEY_ENTER etc defines #ifndef AR_DEFINES_ONLY #define KEY_ENTER 13 #define KEY_TAB 9 -#define KEY_BASE 0x100 - -/* Function keys */ -#define KEY_F (KEY_BASE+64) - /* Control keys */ -#define KEY_CTRL (KEY_BASE) +#define KEY_CTRL (MP_KEY_BASE) #define KEY_BACKSPACE (KEY_CTRL+0) #define KEY_DELETE (KEY_CTRL+1) #define KEY_INSERT (KEY_CTRL+2) @@ -42,6 +39,7 @@ #define KEY_PAGE_UP (KEY_CTRL+5) #define KEY_PAGE_DOWN (KEY_CTRL+6) #define KEY_ESC (KEY_CTRL+7) +#define KEY_PRINT (KEY_CTRL+8) /* Control keys short name */ #define KEY_BS KEY_BACKSPACE @@ -52,14 +50,14 @@ #define KEY_PGDWN KEY_PAGE_DOWN /* Cursor movement */ -#define KEY_CRSR (KEY_BASE+16) +#define KEY_CRSR (MP_KEY_BASE+0x10) #define KEY_RIGHT (KEY_CRSR+0) #define KEY_LEFT (KEY_CRSR+1) #define KEY_DOWN (KEY_CRSR+2) #define KEY_UP (KEY_CRSR+3) /* Multimedia keyboard/remote keys */ -#define KEY_MM_BASE (0x100+384) +#define KEY_MM_BASE (MP_KEY_BASE+0x20) #define KEY_POWER (KEY_MM_BASE+0) #define KEY_MENU (KEY_MM_BASE+1) #define KEY_PLAY (KEY_MM_BASE+2) @@ -74,8 +72,11 @@ #define KEY_VOLUME_DOWN (KEY_MM_BASE+11) #define KEY_MUTE (KEY_MM_BASE+12) +/* Function keys */ +#define KEY_F (MP_KEY_BASE+0x40) + /* Keypad keys */ -#define KEY_KEYPAD (KEY_BASE+32) +#define KEY_KEYPAD (MP_KEY_BASE+0x60) #define KEY_KP0 (KEY_KEYPAD+0) #define KEY_KP1 (KEY_KEYPAD+1) #define KEY_KP2 (KEY_KEYPAD+2) @@ -93,7 +94,7 @@ // Joystick input module -#define JOY_BASE (0x100+128) +#define JOY_BASE (MP_KEY_BASE+0x70) #define JOY_AXIS0_PLUS (JOY_BASE+0) #define JOY_AXIS0_MINUS (JOY_BASE+1) #define JOY_AXIS1_PLUS (JOY_BASE+2) @@ -115,7 +116,7 @@ #define JOY_AXIS9_PLUS (JOY_BASE+18) #define JOY_AXIS9_MINUS (JOY_BASE+19) -#define JOY_BTN_BASE ((0x100+148)|MP_NO_REPEAT_KEY) +#define JOY_BTN_BASE ((MP_KEY_BASE+0x90)|MP_NO_REPEAT_KEY) #define JOY_BTN0 (JOY_BTN_BASE+0) #define JOY_BTN1 (JOY_BTN_BASE+1) #define JOY_BTN2 (JOY_BTN_BASE+2) @@ -129,7 +130,7 @@ // Mouse events from VOs -#define MOUSE_BASE ((0x100+256)|MP_NO_REPEAT_KEY) +#define MOUSE_BASE ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY) #define MOUSE_BTN0 (MOUSE_BASE+0) #define MOUSE_BTN1 (MOUSE_BASE+1) #define MOUSE_BTN2 (MOUSE_BASE+2) @@ -152,7 +153,7 @@ #define MOUSE_BTN19 (MOUSE_BASE+19) #define MOUSE_BTN_END (MOUSE_BASE+20) -#define MOUSE_BASE_DBL (0x300|MP_NO_REPEAT_KEY) +#define MOUSE_BASE_DBL ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY) #define MOUSE_BTN0_DBL (MOUSE_BASE_DBL+0) #define MOUSE_BTN1_DBL (MOUSE_BASE_DBL+1) #define MOUSE_BTN2_DBL (MOUSE_BASE_DBL+2) @@ -179,7 +180,7 @@ #endif // AR_DEFINES_ONLY // Apple Remote input module -#define AR_BASE 0x500 +#define AR_BASE (MP_KEY_BASE+0xE0) #define AR_PLAY (AR_BASE + 0) #define AR_PLAY_HOLD (AR_BASE + 1) #define AR_NEXT (AR_BASE + 2) @@ -195,14 +196,14 @@ /* Special keys */ -#define KEY_INTERN (0x1000) +#define KEY_INTERN (MP_KEY_BASE+0x1000) #define KEY_CLOSE_WIN (KEY_INTERN+0) /* Modifiers added to individual keys */ -#define KEY_MODIFIER_SHIFT 0x2000 -#define KEY_MODIFIER_CTRL 0x4000 -#define KEY_MODIFIER_ALT 0x8000 -#define KEY_MODIFIER_META 0x10000 +#define KEY_MODIFIER_SHIFT (1<<22) +#define KEY_MODIFIER_CTRL (1<<23) +#define KEY_MODIFIER_ALT (1<<24) +#define KEY_MODIFIER_META (1<<25) #endif // AR_DEFINES_ONLY diff -Nru mplayer2-2.0-426-gc32b3ed/libaf/af.c mplayer2-2.0-554-gf63dbad/libaf/af.c --- mplayer2-2.0-426-gc32b3ed/libaf/af.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libaf/af.c 2012-05-17 14:38:00.000000000 +0000 @@ -246,6 +246,43 @@ free(af); } +static void print_fmt(af_data_t *d) +{ + if (d) { + mp_msg(MSGT_AFILTER, MSGL_V, "%dHz/%dch/%s", d->rate, d->nch, + af_fmt2str_short(d->format)); + } else { + mp_msg(MSGT_AFILTER, MSGL_V, "(?)"); + } +} + +static void af_print_filter_chain(af_stream_t* s) +{ + mp_msg(MSGT_AFILTER, MSGL_V, "Audio filter chain:\n"); + + mp_msg(MSGT_AFILTER, MSGL_V, " [in] "); + print_fmt(&s->input); + mp_msg(MSGT_AFILTER, MSGL_V, "\n"); + + af_instance_t *af = s->first; + while (af) { + mp_msg(MSGT_AFILTER, MSGL_V, " [%s] ", af->info->name); + print_fmt(af->data); + mp_msg(MSGT_AFILTER, MSGL_V, "\n"); + + af = af->next; + } + + mp_msg(MSGT_AFILTER, MSGL_V, " [out] "); + print_fmt(&s->output); + mp_msg(MSGT_AFILTER, MSGL_V, "\n"); +} + +// Warning: +// A failed af_reinit() leaves the audio chain behind in a useless, broken +// state (for example, format filters that were tentatively inserted stay +// inserted). +// In that case, you should always rebuild the filter chain, or abort. int af_reinit(af_stream_t* s, af_instance_t* af) { do{ @@ -343,6 +380,9 @@ return AF_ERROR; } }while(af); + + af_print_filter_chain(s); + return AF_OK; } @@ -552,7 +592,9 @@ // Reinitalize the filter list if(AF_OK != af_reinit(s, s->first) || AF_OK != fixup_output_format(s)){ - free(new); + while (s->first) + af_remove(s, s->first); + af_init(s); return NULL; } return new; diff -Nru mplayer2-2.0-426-gc32b3ed/libaf/af_lavcac3enc.c mplayer2-2.0-554-gf63dbad/libaf/af_lavcac3enc.c --- mplayer2-2.0-426-gc32b3ed/libaf/af_lavcac3enc.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libaf/af_lavcac3enc.c 2012-05-17 14:38:00.000000000 +0000 @@ -26,12 +26,13 @@ #include #include +#include +#include + #include "config.h" #include "af.h" #include "reorder_ch.h" -#include "libavcodec/avcodec.h" -#include "ffmpeg_files/intreadwrite.h" #define AC3_MAX_CHANNELS 6 #define AC3_MAX_CODED_FRAME_SIZE 3840 @@ -98,15 +99,14 @@ s->lavc_actx->sample_rate != af->data->rate || s->lavc_actx->bit_rate != bit_rate) { - if (s->lavc_actx->codec) - avcodec_close(s->lavc_actx); + avcodec_close(s->lavc_actx); // Put sample parameters s->lavc_actx->channels = af->data->nch; s->lavc_actx->sample_rate = af->data->rate; s->lavc_actx->bit_rate = bit_rate; - if(avcodec_open(s->lavc_actx, s->lavc_acodec) < 0) { + if (avcodec_open2(s->lavc_actx, s->lavc_acodec, NULL) < 0) { mp_tmsg(MSGT_AFILTER, MSGL_ERR, "Couldn't open codec %s, br=%d.\n", "ac3", bit_rate); return AF_ERROR; } @@ -160,9 +160,8 @@ af_ac3enc_t *s = af->setup; af->setup = NULL; if(s->lavc_actx) { - if (s->lavc_actx->codec) - avcodec_close(s->lavc_actx); - free(s->lavc_actx); + avcodec_close(s->lavc_actx); + av_free(s->lavc_actx); } free(s->pending_data); free(s); @@ -291,23 +290,22 @@ return AF_ERROR; } - s->lavc_actx = avcodec_alloc_context(); + s->lavc_actx = avcodec_alloc_context3(s->lavc_acodec); if (!s->lavc_actx) { mp_tmsg(MSGT_AFILTER, MSGL_ERR, "Audio LAVC, couldn't allocate context!\n"); return AF_ERROR; } - // using deprecated SampleFormat/FMT, AV* versions only added in 2010-11 - const enum SampleFormat *fmts = s->lavc_acodec->sample_fmts; + const enum AVSampleFormat *fmts = s->lavc_acodec->sample_fmts; for (int i = 0; ; i++) { - if (fmts[i] == SAMPLE_FMT_NONE) { + if (fmts[i] == AV_SAMPLE_FMT_NONE) { mp_msg(MSGT_AFILTER, MSGL_ERR, "Audio LAVC, encoder doesn't " "support expected sample formats!\n"); return AF_ERROR; - } else if (fmts[i] == SAMPLE_FMT_S16) { + } else if (fmts[i] == AV_SAMPLE_FMT_S16) { s->in_sampleformat = AF_FORMAT_S16_NE; s->lavc_actx->sample_fmt = fmts[i]; break; - } else if (fmts[i] == SAMPLE_FMT_FLT) { + } else if (fmts[i] == AV_SAMPLE_FMT_FLT) { s->in_sampleformat = AF_FORMAT_FLOAT_NE; s->lavc_actx->sample_fmt = fmts[i]; break; diff -Nru mplayer2-2.0-426-gc32b3ed/libaf/af_volume.c mplayer2-2.0-554-gf63dbad/libaf/af_volume.c --- mplayer2-2.0-426-gc32b3ed/libaf/af_volume.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libaf/af_volume.c 2012-05-17 14:38:00.000000000 +0000 @@ -142,7 +142,6 @@ { af_data_t* c = data; // Current working data af_volume_t* s = (af_volume_t*)af->setup; // Setup for this instance - int ch = 0; // Channel counter register int nch = c->nch; // Number of channels register int i = 0; @@ -150,9 +149,9 @@ if(af->data->format == (AF_FORMAT_S16_NE)){ int16_t* a = (int16_t*)c->audio; // Audio data int len = c->len/2; // Number of samples - for(ch = 0; ch < nch ; ch++){ - if(s->enable[ch]){ - register int vol = (int)(255.0 * s->level[ch]); + for (int ch = 0; ch < nch; ch++) { + int vol = 256.0 * s->level[ch]; + if (s->enable[ch] && vol != 256) { for(i=ch;i> 8; a[i]=clamp(x,SHRT_MIN,SHRT_MAX); @@ -164,7 +163,7 @@ else if(af->data->format == (AF_FORMAT_FLOAT_NE)){ float* a = (float*)c->audio; // Audio data int len = c->len/4; // Number of samples - for(ch = 0; ch < nch ; ch++){ + for (int ch = 0; ch < nch; ch++) { // Volume control (fader) if(s->enable[ch]){ float t = 1.0 - s->time; diff -Nru mplayer2-2.0-426-gc32b3ed/libao2/ao_alsa.c mplayer2-2.0-554-gf63dbad/libao2/ao_alsa.c --- mplayer2-2.0-426-gc32b3ed/libao2/ao_alsa.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libao2/ao_alsa.c 2012-05-17 14:38:00.000000000 +0000 @@ -43,14 +43,7 @@ #define ALSA_PCM_NEW_HW_PARAMS_API #define ALSA_PCM_NEW_SW_PARAMS_API -#ifdef HAVE_SYS_ASOUNDLIB_H -#include -#elif defined(HAVE_ALSA_ASOUNDLIB_H) #include -#else -#error "asoundlib.h is not in sys/ or alsa/ - please bugreport" -#endif - #include "audio_out.h" #include "audio_out_internal.h" @@ -104,19 +97,17 @@ static int control(int cmd, void *arg) { switch(cmd) { - case AOCONTROL_QUERY_FORMAT: - return CONTROL_TRUE; + case AOCONTROL_GET_MUTE: + case AOCONTROL_SET_MUTE: case AOCONTROL_GET_VOLUME: case AOCONTROL_SET_VOLUME: { - ao_control_vol_t *vol = (ao_control_vol_t *)arg; - int err; snd_mixer_t *handle; snd_mixer_elem_t *elem; snd_mixer_selem_id_t *sid; - char *mix_name = "PCM"; + char *mix_name = "Master"; char *card = "default"; int mix_index = 0; @@ -192,16 +183,16 @@ snd_mixer_selem_get_playback_volume_range(elem,&pmin,&pmax); f_multi = (100 / (float)(pmax - pmin)); - if (cmd == AOCONTROL_SET_VOLUME) { - + switch (cmd) { + case AOCONTROL_SET_VOLUME: { + ao_control_vol_t *vol = arg; set_vol = vol->left / f_multi + pmin + 0.5; //setting channels if ((err = snd_mixer_selem_set_playback_volume(elem, SND_MIXER_SCHN_FRONT_LEFT, set_vol)) < 0) { mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Error setting left channel, %s\n", snd_strerror(err)); - snd_mixer_close(handle); - return CONTROL_ERROR; + goto mixer_error; } mp_msg(MSGT_AO,MSGL_DBG2,"left=%li, ", set_vol); @@ -210,33 +201,54 @@ if ((err = snd_mixer_selem_set_playback_volume(elem, SND_MIXER_SCHN_FRONT_RIGHT, set_vol)) < 0) { mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Error setting right channel, %s\n", snd_strerror(err)); - snd_mixer_close(handle); - return CONTROL_ERROR; + goto mixer_error; } mp_msg(MSGT_AO,MSGL_DBG2,"right=%li, pmin=%li, pmax=%li, mult=%f\n", set_vol, pmin, pmax, f_multi); - - if (snd_mixer_selem_has_playback_switch(elem)) { - int lmute = (vol->left == 0.0); - int rmute = (vol->right == 0.0); - if (snd_mixer_selem_has_playback_switch_joined(elem)) { - lmute = rmute = lmute && rmute; - } else { - snd_mixer_selem_set_playback_switch(elem, SND_MIXER_SCHN_FRONT_RIGHT, !rmute); - } - snd_mixer_selem_set_playback_switch(elem, SND_MIXER_SCHN_FRONT_LEFT, !lmute); - } + break; + } + case AOCONTROL_GET_VOLUME: { + ao_control_vol_t *vol = arg; + snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_FRONT_LEFT, &get_vol); + vol->left = (get_vol - pmin) * f_multi; + snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_FRONT_RIGHT, &get_vol); + vol->right = (get_vol - pmin) * f_multi; + mp_msg(MSGT_AO,MSGL_DBG2,"left=%f, right=%f\n",vol->left,vol->right); + break; + } + case AOCONTROL_SET_MUTE: { + bool *mute = arg; + if (!snd_mixer_selem_has_playback_switch(elem)) + goto mixer_error; + if (!snd_mixer_selem_has_playback_switch_joined(elem)) { + snd_mixer_selem_set_playback_switch( + elem, SND_MIXER_SCHN_FRONT_RIGHT, !*mute); + } + snd_mixer_selem_set_playback_switch(elem, SND_MIXER_SCHN_FRONT_LEFT, + !*mute); + break; + } + case AOCONTROL_GET_MUTE: { + bool *mute = arg; + if (!snd_mixer_selem_has_playback_switch(elem)) + goto mixer_error; + int tmp = 1; + snd_mixer_selem_get_playback_switch(elem, SND_MIXER_SCHN_FRONT_LEFT, + &tmp); + *mute = !tmp; + if (!snd_mixer_selem_has_playback_switch_joined(elem)) { + snd_mixer_selem_get_playback_switch( + elem, SND_MIXER_SCHN_FRONT_RIGHT, &tmp); + *mute &= !tmp; + } + break; } - else { - snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_FRONT_LEFT, &get_vol); - vol->left = (get_vol - pmin) * f_multi; - snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_FRONT_RIGHT, &get_vol); - vol->right = (get_vol - pmin) * f_multi; - - mp_msg(MSGT_AO,MSGL_DBG2,"left=%f, right=%f\n",vol->left,vol->right); } snd_mixer_close(handle); return CONTROL_OK; + mixer_error: + snd_mixer_close(handle); + return CONTROL_ERROR; } } //end switch @@ -342,11 +354,7 @@ mp_msg(MSGT_AO,MSGL_V,"alsa-init: requested format: %d Hz, %d channels, %x\n", rate_hz, channels, format); alsa_handler = NULL; -#if SND_LIB_VERSION >= 0x010005 mp_msg(MSGT_AO,MSGL_V,"alsa-init: using ALSA %s\n", snd_asoundlib_version()); -#else - mp_msg(MSGT_AO,MSGL_V,"alsa-init: compiled for ALSA-%s\n", SND_LIB_VERSION_STR); -#endif prepause_frames = 0; @@ -554,7 +562,6 @@ /* workaround for buggy rate plugin (should be fixed in ALSA 1.0.11) prefer our own resampler, since that allows users to choose the resampler, even per file if desired */ -#if SND_LIB_VERSION >= 0x010009 if ((err = snd_pcm_hw_params_set_rate_resample(alsa_handler, alsa_hwparams, 0)) < 0) { @@ -562,7 +569,6 @@ snd_strerror(err)); return 0; } -#endif if ((err = snd_pcm_hw_params_set_rate_near(alsa_handler, alsa_hwparams, &ao_data.samplerate, NULL)) < 0) @@ -626,15 +632,11 @@ snd_strerror(err)); return 0; } -#if SND_LIB_VERSION >= 0x000901 if ((err = snd_pcm_sw_params_get_boundary(alsa_swparams, &boundary)) < 0) { mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to get boundary: %s\n", snd_strerror(err)); return 0; } -#else - boundary = 0x7fffffff; -#endif /* start playing when one period has been written */ if ((err = snd_pcm_sw_params_set_start_threshold(alsa_handler, alsa_swparams, chunk_size)) < 0) { mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to set start threshold: %s\n", @@ -647,14 +649,12 @@ snd_strerror(err)); return 0; } -#if SND_LIB_VERSION >= 0x000901 /* play silence when there is an underrun */ if ((err = snd_pcm_sw_params_set_silence_size(alsa_handler, alsa_swparams, boundary)) < 0) { mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to set silence size: %s\n", snd_strerror(err)); return 0; } -#endif if ((err = snd_pcm_sw_params(alsa_handler, alsa_swparams)) < 0) { mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to get sw-parameters: %s\n", snd_strerror(err)); @@ -851,9 +851,7 @@ if (delay < 0) { /* underrun - move the application pointer forward to catch up */ -#if SND_LIB_VERSION >= 0x000901 /* snd_pcm_forward() exists since 0.9.0rc8 */ snd_pcm_forward(alsa_handler, -delay); -#endif delay = 0; } return (float)delay / (float)ao_data.samplerate; diff -Nru mplayer2-2.0-426-gc32b3ed/libao2/ao_alsa5.c mplayer2-2.0-554-gf63dbad/libao2/ao_alsa5.c --- mplayer2-2.0-426-gc32b3ed/libao2/ao_alsa5.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libao2/ao_alsa5.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,383 +0,0 @@ -/* - * ALSA 0.5.x audio output driver - * - * Copyright (C) 2001 Alex Beregszaszi - * - * Thanks to Arpi for helping me ;) - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include - -#include "config.h" - -#include "audio_out.h" -#include "audio_out_internal.h" -#include "libaf/af_format.h" - -#include "mp_msg.h" - -static const ao_info_t info = -{ - "ALSA-0.5.x audio output", - "alsa5", - "Alex Beregszaszi", - "" -}; - -LIBAO_EXTERN(alsa5) - -static snd_pcm_t *alsa_handler; -static snd_pcm_format_t alsa_format; -static int alsa_rate = SND_PCM_RATE_CONTINUOUS; - -/* to set/get/query special features/parameters */ -static int control(int cmd, void *arg) -{ - return CONTROL_UNKNOWN; -} - -/* - open & setup audio device - return: 1=success 0=fail -*/ -static int init(int rate_hz, int channels, int format, int flags) -{ - int err; - int cards = -1; - snd_pcm_channel_params_t params; - snd_pcm_channel_setup_t setup; - snd_pcm_info_t info; - snd_pcm_channel_info_t chninfo; - - mp_tmsg(MSGT_AO, MSGL_INFO, "[AO ALSA5] alsa-init: requested format: %d Hz, %d channels, %s\n", rate_hz, - channels, af_fmt2str_short(format)); - - alsa_handler = NULL; - - mp_msg(MSGT_AO, MSGL_V, "alsa-init: compiled for ALSA-%s (%d)\n", SND_LIB_VERSION_STR, - SND_LIB_VERSION); - - if ((cards = snd_cards()) < 0) - { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-init: no soundcards found.\n"); - return 0; - } - - ao_data.format = format; - ao_data.channels = channels; - ao_data.samplerate = rate_hz; - ao_data.bps = ao_data.samplerate*ao_data.channels; - ao_data.outburst = OUTBURST; - ao_data.buffersize = 16384; - - memset(&alsa_format, 0, sizeof(alsa_format)); - switch (format) - { - case AF_FORMAT_S8: - alsa_format.format = SND_PCM_SFMT_S8; - break; - case AF_FORMAT_U8: - alsa_format.format = SND_PCM_SFMT_U8; - break; - case AF_FORMAT_U16_LE: - alsa_format.format = SND_PCM_SFMT_U16_LE; - break; - case AF_FORMAT_U16_BE: - alsa_format.format = SND_PCM_SFMT_U16_BE; - break; - case AF_FORMAT_AC3_LE: - case AF_FORMAT_S16_LE: - alsa_format.format = SND_PCM_SFMT_S16_LE; - break; - case AF_FORMAT_AC3_BE: - case AF_FORMAT_S16_BE: - alsa_format.format = SND_PCM_SFMT_S16_BE; - break; - default: - alsa_format.format = SND_PCM_SFMT_MPEG; - break; - } - - switch(alsa_format.format) - { - case SND_PCM_SFMT_S16_LE: - case SND_PCM_SFMT_U16_LE: - ao_data.bps *= 2; - break; - case -1: - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-init: invalid format (%s) requested - output disabled.\n",af_fmt2str_short(format)); - return 0; - default: - break; - } - - switch(rate_hz) - { - case 8000: - alsa_rate = SND_PCM_RATE_8000; - break; - case 11025: - alsa_rate = SND_PCM_RATE_11025; - break; - case 16000: - alsa_rate = SND_PCM_RATE_16000; - break; - case 22050: - alsa_rate = SND_PCM_RATE_22050; - break; - case 32000: - alsa_rate = SND_PCM_RATE_32000; - break; - case 44100: - alsa_rate = SND_PCM_RATE_44100; - break; - case 48000: - alsa_rate = SND_PCM_RATE_48000; - break; - case 88200: - alsa_rate = SND_PCM_RATE_88200; - break; - case 96000: - alsa_rate = SND_PCM_RATE_96000; - break; - case 176400: - alsa_rate = SND_PCM_RATE_176400; - break; - case 192000: - alsa_rate = SND_PCM_RATE_192000; - break; - default: - alsa_rate = SND_PCM_RATE_CONTINUOUS; - break; - } - - alsa_format.rate = ao_data.samplerate; - alsa_format.voices = ao_data.channels; - alsa_format.interleave = 1; - - if ((err = snd_pcm_open(&alsa_handler, 0, 0, SND_PCM_OPEN_PLAYBACK)) < 0) - { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-init: playback open error: %s\n", snd_strerror(err)); - return 0; - } - - if ((err = snd_pcm_info(alsa_handler, &info)) < 0) - { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-init: PCM info error: %s\n", snd_strerror(err)); - return 0; - } - - mp_tmsg(MSGT_AO, MSGL_INFO, "[AO ALSA5] alsa-init: %d soundcard(s) found, using: %s\n", - cards, info.name); - - if (info.flags & SND_PCM_INFO_PLAYBACK) - { - memset(&chninfo, 0, sizeof(chninfo)); - chninfo.channel = SND_PCM_CHANNEL_PLAYBACK; - if ((err = snd_pcm_channel_info(alsa_handler, &chninfo)) < 0) - { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-init: PCM channel info error: %s\n", snd_strerror(err)); - return 0; - } - -#ifndef __QNX__ - if (chninfo.buffer_size) - ao_data.buffersize = chninfo.buffer_size; -#endif - - mp_msg(MSGT_AO, MSGL_V, "alsa-init: setting preferred buffer size from driver: %d bytes\n", - ao_data.buffersize); - } - - memset(¶ms, 0, sizeof(params)); - params.channel = SND_PCM_CHANNEL_PLAYBACK; - params.mode = SND_PCM_MODE_STREAM; - params.format = alsa_format; - params.start_mode = SND_PCM_START_DATA; - params.stop_mode = SND_PCM_STOP_ROLLOVER; - params.buf.stream.queue_size = ao_data.buffersize; - params.buf.stream.fill = SND_PCM_FILL_NONE; - - if ((err = snd_pcm_channel_params(alsa_handler, ¶ms)) < 0) - { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-init: error setting parameters: %s\n", snd_strerror(err)); - return 0; - } - - memset(&setup, 0, sizeof(setup)); - setup.channel = SND_PCM_CHANNEL_PLAYBACK; - setup.mode = SND_PCM_MODE_STREAM; - setup.format = alsa_format; - setup.buf.stream.queue_size = ao_data.buffersize; - setup.msbits_per_sample = ao_data.bps; - - if ((err = snd_pcm_channel_setup(alsa_handler, &setup)) < 0) - { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-init: error setting up channel: %s\n", snd_strerror(err)); - return 0; - } - - if ((err = snd_pcm_channel_prepare(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0) - { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-init: channel prepare error: %s\n", snd_strerror(err)); - return 0; - } - - mp_msg(MSGT_AO, MSGL_INFO, "AUDIO: %d Hz/%d channels/%d bps/%d bytes buffer/%s\n", - ao_data.samplerate, ao_data.channels, ao_data.bps, ao_data.buffersize, - snd_pcm_get_format_name(alsa_format.format)); - return 1; -} - -/* close audio device */ -static void uninit(int immed) -{ - int err; - - if ((err = snd_pcm_playback_drain(alsa_handler)) < 0) - { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-uninit: playback drain error: %s\n", snd_strerror(err)); - return; - } - - if ((err = snd_pcm_channel_flush(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0) - { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-uninit: playback flush error: %s\n", snd_strerror(err)); - return; - } - - if ((err = snd_pcm_close(alsa_handler)) < 0) - { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-uninit: PCM close error: %s\n", snd_strerror(err)); - return; - } -} - -/* stop playing and empty buffers (for seeking/pause) */ -static void reset(void) -{ - int err; - - if ((err = snd_pcm_playback_drain(alsa_handler)) < 0) - { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-reset: playback drain error: %s\n", snd_strerror(err)); - return; - } - - if ((err = snd_pcm_channel_flush(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0) - { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-reset: playback flush error: %s\n", snd_strerror(err)); - return; - } - - if ((err = snd_pcm_channel_prepare(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0) - { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-reset: channel prepare error: %s\n", snd_strerror(err)); - return; - } -} - -/* stop playing, keep buffers (for pause) */ -static void audio_pause(void) -{ - int err; - - if ((err = snd_pcm_playback_drain(alsa_handler)) < 0) - { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-pause: playback drain error: %s\n", snd_strerror(err)); - return; - } - - if ((err = snd_pcm_channel_flush(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0) - { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-pause: playback flush error: %s\n", snd_strerror(err)); - return; - } -} - -/* resume playing, after audio_pause() */ -static void audio_resume(void) -{ - int err; - if ((err = snd_pcm_channel_prepare(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0) - { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-resume: channel prepare error: %s\n", snd_strerror(err)); - return; - } -} - -/* - plays 'len' bytes of 'data' - returns: number of bytes played -*/ -static int play(void* data, int len, int flags) -{ - int got_len; - - if (!len) - return 0; - - if ((got_len = snd_pcm_write(alsa_handler, data, len)) < 0) - { - if (got_len == -EPIPE) /* underrun? */ - { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-play: alsa underrun, resetting stream.\n"); - if ((got_len = snd_pcm_channel_prepare(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0) - { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-play: playback prepare error: %s\n", snd_strerror(got_len)); - return 0; - } - if ((got_len = snd_pcm_write(alsa_handler, data, len)) < 0) - { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-play: write error after reset: %s - giving up.\n", - snd_strerror(got_len)); - return 0; - } - return got_len; /* 2nd write was ok */ - } - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-play: output error: %s\n", snd_strerror(got_len)); - return 0; - } - return got_len; -} - -/* how many byes are free in the buffer */ -static int get_space(void) -{ - snd_pcm_channel_status_t ch_stat; - - ch_stat.channel = SND_PCM_CHANNEL_PLAYBACK; - - if (snd_pcm_channel_status(alsa_handler, &ch_stat) < 0) - return 0; /* error occurred */ - else - return ch_stat.free; -} - -/* delay in seconds between first and last sample in buffer */ -static float get_delay(void) -{ - snd_pcm_channel_status_t ch_stat; - - ch_stat.channel = SND_PCM_CHANNEL_PLAYBACK; - - if (snd_pcm_channel_status(alsa_handler, &ch_stat) < 0) - return (float)ao_data.buffersize/(float)ao_data.bps; /* error occurred */ - else - return (float)ch_stat.count/(float)ao_data.bps; -} diff -Nru mplayer2-2.0-426-gc32b3ed/libao2/ao_arts.c mplayer2-2.0-554-gf63dbad/libao2/ao_arts.c --- mplayer2-2.0-426-gc32b3ed/libao2/ao_arts.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libao2/ao_arts.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,148 +0,0 @@ -/* - * aRts audio output driver for MPlayer - * - * copyright (c) 2002 Michele Balistreri - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include - -#include "config.h" -#include "audio_out.h" -#include "audio_out_internal.h" -#include "libaf/af_format.h" -#include "mp_msg.h" - -#define OBTAIN_BITRATE(a) (((a != AF_FORMAT_U8) && (a != AF_FORMAT_S8)) ? 16 : 8) - -/* Feel free to experiment with the following values: */ -#define ARTS_PACKETS 10 /* Number of audio packets */ -#define ARTS_PACKET_SIZE_LOG2 11 /* Log2 of audio packet size */ - -static arts_stream_t stream; - -static const ao_info_t info = -{ - "aRts audio output", - "arts", - "Michele Balistreri ", - "" -}; - -LIBAO_EXTERN(arts) - -static int control(int cmd, void *arg) -{ - return CONTROL_UNKNOWN; -} - -static int init(int rate_hz, int channels, int format, int flags) -{ - int err; - int frag_spec; - - if( (err=arts_init()) ) { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ARTS] %s\n", arts_error_text(err)); - return 0; - } - mp_tmsg(MSGT_AO, MSGL_INFO, "[AO ARTS] Connected to sound server.\n"); - - /* - * arts supports 8bit unsigned and 16bit signed sample formats - * (16bit apparently in little endian format, even in the case - * when artsd runs on a big endian cpu). - * - * Unsupported formats are translated to one of these two formats - * using mplayer's audio filters. - */ - switch (format) { - case AF_FORMAT_U8: - case AF_FORMAT_S8: - format = AF_FORMAT_U8; - break; - default: - format = AF_FORMAT_S16_LE; /* artsd always expects little endian?*/ - break; - } - - ao_data.format = format; - ao_data.channels = channels; - ao_data.samplerate = rate_hz; - ao_data.bps = (rate_hz*channels); - - if(format != AF_FORMAT_U8 && format != AF_FORMAT_S8) - ao_data.bps*=2; - - stream=arts_play_stream(rate_hz, OBTAIN_BITRATE(format), channels, "MPlayer"); - - if(stream == NULL) { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ARTS] Unable to open a stream.\n"); - arts_free(); - return 0; - } - - /* Set the stream to blocking: it will not block anyway, but it seems */ - /* to be working better */ - arts_stream_set(stream, ARTS_P_BLOCKING, 1); - frag_spec = ARTS_PACKET_SIZE_LOG2 | ARTS_PACKETS << 16; - arts_stream_set(stream, ARTS_P_PACKET_SETTINGS, frag_spec); - ao_data.buffersize = arts_stream_get(stream, ARTS_P_BUFFER_SIZE); - mp_tmsg(MSGT_AO, MSGL_INFO, "[AO ARTS] Stream opened.\n"); - - mp_tmsg(MSGT_AO, MSGL_INFO, "[AO ARTS] buffer size: %d\n", - ao_data.buffersize); - mp_tmsg(MSGT_AO, MSGL_INFO, "[AO ARTS] buffer size: %d\n", - arts_stream_get(stream, ARTS_P_PACKET_SIZE)); - - return 1; -} - -static void uninit(int immed) -{ - arts_close_stream(stream); - arts_free(); -} - -static int play(void* data,int len,int flags) -{ - return arts_write(stream, data, len); -} - -static void audio_pause(void) -{ -} - -static void audio_resume(void) -{ -} - -static void reset(void) -{ -} - -static int get_space(void) -{ - return arts_stream_get(stream, ARTS_P_BUFFER_SPACE); -} - -static float get_delay(void) -{ - return ((float) (ao_data.buffersize - arts_stream_get(stream, - ARTS_P_BUFFER_SPACE))) / ((float) ao_data.bps); -} diff -Nru mplayer2-2.0-426-gc32b3ed/libao2/ao_coreaudio.c mplayer2-2.0-554-gf63dbad/libao2/ao_coreaudio.c --- mplayer2-2.0-426-gc32b3ed/libao2/ao_coreaudio.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libao2/ao_coreaudio.c 2012-05-17 14:38:00.000000000 +0000 @@ -169,7 +169,11 @@ control_vol = (ao_control_vol_t*)arg; if (ao->b_digital) { // Digital output has no volume adjust. - return CONTROL_FALSE; + int vol = ao->b_muted ? 0 : 100; + *control_vol = (ao_control_vol_t) { + .left = vol, .right = vol, + }; + return CONTROL_TRUE; } err = AudioUnitGetParameter(ao->theOutputUnit, kHALOutputParam_Volume, kAudioUnitScope_Global, 0, &vol); @@ -450,6 +454,8 @@ ao->b_revert = 0; ao->b_changed_mixing = 0; + global_ao->no_persistent_volume = true; + if (device_id == 0) { /* Find the ID of the default Device. */ err = GetAudioProperty(kAudioObjectSystemObject, diff -Nru mplayer2-2.0-426-gc32b3ed/libao2/ao_dart.c mplayer2-2.0-554-gf63dbad/libao2/ao_dart.c --- mplayer2-2.0-426-gc32b3ed/libao2/ao_dart.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libao2/ao_dart.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,276 +0,0 @@ -/* - * OS/2 DART audio output driver - * - * Copyright (c) 2007-2009 by KO Myung-Hun (komh@chollian.net) - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#define INCL_DOS -#define INCL_DOSERRORS -#include - -#include -#include -#include -#include - -#include - -#include "config.h" -#include "libaf/af_format.h" -#include "audio_out.h" -#include "audio_out_internal.h" -#include "mp_msg.h" -#include "libvo/fastmemcpy.h" -#include "subopt-helper.h" -#include "libavutil/fifo.h" - -static const ao_info_t info = { - "DART audio output", - "dart", - "KO Myung-Hun ", - "" -}; - -LIBAO_EXTERN(dart) - -#define OUTBURST_SAMPLES 512 -#define DEFAULT_DART_SAMPLES (OUTBURST_SAMPLES << 2) - -#define CHUNK_SIZE ao_data.outburst - -static AVFifoBuffer *m_audioBuf; - -static int m_nBufSize = 0; - -static volatile int m_fQuit = FALSE; - -static int write_buffer(unsigned char *data, int len) -{ - int nFree = av_fifo_space(m_audioBuf); - - if (len > nFree) - len = nFree; - - return av_fifo_generic_write(m_audioBuf, data, len, NULL); -} - -static int read_buffer(unsigned char *data, int len) -{ - int nBuffered = av_fifo_size(m_audioBuf); - - if (len > nBuffered) - len = nBuffered; - - av_fifo_generic_read(m_audioBuf, data, len, NULL); - return len; -} - -// end ring buffer stuff - -static ULONG APIENTRY dart_audio_callback(PVOID pCBData, PVOID pBuffer, - ULONG ulSize) -{ - int nReadLen; - - nReadLen = read_buffer(pBuffer, ulSize); - if (nReadLen < ulSize && !m_fQuit) { - memset((uint8_t *)pBuffer + nReadLen, DART.bSilence, ulSize - nReadLen); - nReadLen = ulSize; - } - - return nReadLen; -} - -// to set/get/query special features/parameters -static int control(int cmd, void *arg) -{ - switch (cmd) { - case AOCONTROL_GET_VOLUME: - { - ao_control_vol_t *vol = arg; - - vol->left = vol->right = LOUSHORT(dartGetVolume()); - - return CONTROL_OK; - } - - case AOCONTROL_SET_VOLUME: - { - int mid; - ao_control_vol_t *vol = arg; - - mid = (vol->left + vol->right) / 2; - dartSetVolume(MCI_SET_AUDIO_ALL, mid); - - return CONTROL_OK; - } - } - - return CONTROL_UNKNOWN; -} - -static void print_help(void) -{ - mp_msg(MSGT_AO, MSGL_FATAL, - "\n-ao dart commandline help:\n" - "Example: mplayer -ao dart:noshare\n" - " open DART in exclusive mode\n" - "\nOptions:\n" - " (no)share\n" - " Open DART in shareable or exclusive mode\n" - " bufsize=\n" - " Set buffer size to in samples(default: 2048)\n"); -} - -// open & set up audio device -// return: 1=success 0=fail -static int init(int rate, int channels, int format, int flags) -{ - int fShare = 1; - int nDartSamples = DEFAULT_DART_SAMPLES; - int nBytesPerSample; - - const opt_t subopts[] = { - {"share", OPT_ARG_BOOL, &fShare, NULL}, - {"bufsize", OPT_ARG_INT, &nDartSamples, int_non_neg}, - {NULL} - }; - - if (subopt_parse(ao_subdevice, subopts) != 0) { - print_help(); - return 0; - } - - if (!nDartSamples) - nDartSamples = DEFAULT_DART_SAMPLES; - - mp_msg(MSGT_AO, MSGL_V, "DART: opened in %s mode, buffer size = %d sample(s)\n", - fShare ? "shareable" : "exclusive", nDartSamples); - - switch (format) { - case AF_FORMAT_S16_LE: - case AF_FORMAT_S8: - break; - - default: - format = AF_FORMAT_S16_LE; - mp_msg(MSGT_AO, MSGL_V, "DART: format %s not supported defaulting to Signed 16-bit Little-Endian\n", - af_fmt2str_short(format)); - break; - } - - nBytesPerSample = (af_fmt2bits(format) >> 3) * channels; - - if (dartInit(0, af_fmt2bits(format), rate, MCI_WAVE_FORMAT_PCM, channels, - 2, nBytesPerSample * nDartSamples, fShare, - dart_audio_callback, NULL)) - return 0; - - mp_msg(MSGT_AO, MSGL_V, "DART: obtained buffer size = %lu bytes\n", - DART.ulBufferSize); - - m_fQuit = FALSE; - - ao_data.channels = channels; - ao_data.samplerate = rate; - ao_data.format = format; - ao_data.bps = nBytesPerSample * rate; - ao_data.outburst = nBytesPerSample * OUTBURST_SAMPLES; - ao_data.buffersize = DART.ulBufferSize; - - // multiple of CHUNK_SIZE - m_nBufSize = ((DART.ulBufferSize << 2) / CHUNK_SIZE) * CHUNK_SIZE; - // and one more chunk plus round up - m_nBufSize += 2 * CHUNK_SIZE; - - m_audioBuf = av_fifo_alloc(m_nBufSize); - - dartPlay(); - - // might cause PM DLLs to be loaded which incorrectly enable SIG_FPE, - // which AAC decoding might trigger. - // so, mask off all floating-point exceptions. - _control87(MCW_EM, MCW_EM); - - return 1; -} - -// close audio device -static void uninit(int immed) -{ - m_fQuit = TRUE; - - if (!immed) { - while (DART.fPlaying) - DosSleep(1); - } - - dartClose(); - - av_fifo_free(m_audioBuf); -} - -// stop playing and empty buffers (for seeking/pause) -static void reset(void) -{ - dartPause(); - - // Reset ring-buffer state - av_fifo_reset(m_audioBuf); - - dartResume(); -} - -// stop playing, keep buffers (for pause) -static void audio_pause(void) -{ - dartPause(); -} - -// resume playing, after audio_pause() -static void audio_resume(void) -{ - dartResume(); -} - -// return: how many bytes can be played without blocking -static int get_space(void) -{ - return av_fifo_space(m_audioBuf); -} - -// plays 'len' bytes of 'data' -// it should round it down to outburst*n -// return: number of bytes played -static int play(void *data, int len, int flags) -{ - - if (!(flags & AOPLAY_FINAL_CHUNK)) - len = (len / ao_data.outburst) * ao_data.outburst; - - return write_buffer(data, len); -} - -// return: delay in seconds between first and last sample in buffer -static float get_delay(void) -{ - int nBuffered = av_fifo_size(m_audioBuf); // could be less - - return (float)nBuffered / (float)ao_data.bps; -} diff -Nru mplayer2-2.0-426-gc32b3ed/libao2/ao_dsound.c mplayer2-2.0-554-gf63dbad/libao2/ao_dsound.c --- mplayer2-2.0-426-gc32b3ed/libao2/ao_dsound.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libao2/ao_dsound.c 2012-05-17 14:38:00.000000000 +0000 @@ -81,12 +81,14 @@ #define SPEAKER_TOP_BACK_RIGHT 0x20000 #define SPEAKER_RESERVED 0x80000000 +#if 0 #define DSSPEAKER_HEADPHONE 0x00000001 #define DSSPEAKER_MONO 0x00000002 #define DSSPEAKER_QUAD 0x00000003 #define DSSPEAKER_STEREO 0x00000004 #define DSSPEAKER_SURROUND 0x00000005 #define DSSPEAKER_5POINT1 0x00000006 +#endif #ifndef _WAVEFORMATEXTENSIBLE_ typedef struct { @@ -337,14 +339,14 @@ numsamp = dwBytes1 / (ao_data.channels * sampsize); // number of samples for each channel in this buffer for( i = 0; i < numsamp; i++ ) for( j = 0; j < ao_data.channels; j++ ) { - memcpy(lpvPtr1+(i*ao_data.channels*sampsize)+(chantable[j]*sampsize),data+(i*ao_data.channels*sampsize)+(j*sampsize),sampsize); + memcpy((char*)lpvPtr1+(i*ao_data.channels*sampsize)+(chantable[j]*sampsize),data+(i*ao_data.channels*sampsize)+(j*sampsize),sampsize); } if (NULL != lpvPtr2 ) { numsamp = dwBytes2 / (ao_data.channels * sampsize); for( i = 0; i < numsamp; i++ ) for( j = 0; j < ao_data.channels; j++ ) { - memcpy(lpvPtr2+(i*ao_data.channels*sampsize)+(chantable[j]*sampsize),data+dwBytes1+(i*ao_data.channels*sampsize)+(j*sampsize),sampsize); + memcpy((char*)lpvPtr2+(i*ao_data.channels*sampsize)+(chantable[j]*sampsize),data+dwBytes1+(i*ao_data.channels*sampsize)+(j*sampsize),sampsize); } } @@ -418,6 +420,8 @@ int res; if (!InitDirectSound()) return 0; + global_ao->no_persistent_volume = true; + // ok, now create the buffers WAVEFORMATEXTENSIBLE wformat; DSBUFFERDESC dsbpridesc; diff -Nru mplayer2-2.0-426-gc32b3ed/libao2/ao_esd.c mplayer2-2.0-554-gf63dbad/libao2/ao_esd.c --- mplayer2-2.0-426-gc32b3ed/libao2/ao_esd.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libao2/ao_esd.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,475 +0,0 @@ -/* - * EsounD audio output driver for MPlayer - * - * copyright (c) 2002 Juergen Keil - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - - /* - * TODO / known problems: - * - does not work well when the esd daemon has autostandby disabled - * (workaround: run esd with option "-as 2" - fortunatelly this is - * the default) - * - plays noise on a linux 2.4.4 kernel with a SB16PCI card, when using - * a local tcp connection to the esd daemon; there is no noise when using - * a unix domain socket connection. - * (there are EIO errors reported by the sound card driver, so this is - * most likely a linux sound card driver problem) - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef __svr4__ -#include -#endif -#include - -#include "config.h" -#include "audio_out.h" -#include "audio_out_internal.h" -#include "libaf/af_format.h" -#include "mp_msg.h" - - -#define ESD_RESAMPLES 0 -#define ESD_DEBUG 0 - -#if ESD_DEBUG -#define dprintf(...) printf(__VA_ARGS__) -#else -#define dprintf(...) /**/ -#endif - - -#define ESD_CLIENT_NAME "MPlayer" -#define ESD_MAX_DELAY (1.0f) /* max amount of data buffered in esd (#sec) */ - -static const ao_info_t info = -{ - "EsounD audio output", - "esd", - "Juergen Keil ", - "" -}; - -LIBAO_EXTERN(esd) - -static int esd_fd = -1; -static int esd_play_fd = -1; -static esd_server_info_t *esd_svinfo; -static int esd_latency; -static int esd_bytes_per_sample; -static unsigned long esd_samples_written; -static struct timeval esd_play_start; -extern float audio_delay; - -/* - * to set/get/query special features/parameters - */ -static int control(int cmd, void *arg) -{ - esd_player_info_t *esd_pi; - esd_info_t *esd_i; - time_t now; - static time_t vol_cache_time; - static ao_control_vol_t vol_cache; - - switch (cmd) { - case AOCONTROL_GET_VOLUME: - time(&now); - if (now == vol_cache_time) { - *(ao_control_vol_t *)arg = vol_cache; - return CONTROL_OK; - } - - dprintf("esd: get vol\n"); - if ((esd_i = esd_get_all_info(esd_fd)) == NULL) - return CONTROL_ERROR; - - for (esd_pi = esd_i->player_list; esd_pi != NULL; esd_pi = esd_pi->next) - if (strcmp(esd_pi->name, ESD_CLIENT_NAME) == 0) - break; - - if (esd_pi != NULL) { - ao_control_vol_t *vol = (ao_control_vol_t *)arg; - vol->left = esd_pi->left_vol_scale * 100 / ESD_VOLUME_BASE; - vol->right = esd_pi->right_vol_scale * 100 / ESD_VOLUME_BASE; - - vol_cache = *vol; - vol_cache_time = now; - } - esd_free_all_info(esd_i); - - return CONTROL_OK; - - case AOCONTROL_SET_VOLUME: - dprintf("esd: set vol\n"); - if ((esd_i = esd_get_all_info(esd_fd)) == NULL) - return CONTROL_ERROR; - - for (esd_pi = esd_i->player_list; esd_pi != NULL; esd_pi = esd_pi->next) - if (strcmp(esd_pi->name, ESD_CLIENT_NAME) == 0) - break; - - if (esd_pi != NULL) { - ao_control_vol_t *vol = (ao_control_vol_t *)arg; - esd_set_stream_pan(esd_fd, esd_pi->source_id, - vol->left * ESD_VOLUME_BASE / 100, - vol->right * ESD_VOLUME_BASE / 100); - - vol_cache = *vol; - time(&vol_cache_time); - } - esd_free_all_info(esd_i); - return CONTROL_OK; - - default: - return CONTROL_UNKNOWN; - } -} - - -/* - * open & setup audio device - * return: 1=success 0=fail - */ -static int init(int rate_hz, int channels, int format, int flags) -{ - esd_format_t esd_fmt; - int bytes_per_sample; - int fl; - char *server = ao_subdevice; /* NULL for localhost */ - float lag_seconds, lag_net = 0., lag_serv; - struct timeval proto_start, proto_end; - - if (esd_fd < 0) { - esd_fd = esd_open_sound(server); - if (esd_fd < 0) { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ESD] esd_open_sound failed: %s\n", - strerror(errno)); - return 0; - } - - /* get server info, and measure network latency */ - gettimeofday(&proto_start, NULL); - esd_svinfo = esd_get_server_info(esd_fd); - if(server) { - gettimeofday(&proto_end, NULL); - lag_net = (proto_end.tv_sec - proto_start.tv_sec) + - (proto_end.tv_usec - proto_start.tv_usec) / 1000000.0; - lag_net /= 2.0; /* round trip -> one way */ - } else - lag_net = 0.0; /* no network lag */ - - /* - if (esd_svinfo) { - mp_msg(MSGT_AO, MSGL_INFO, "AO: [esd] server info:\n"); - esd_print_server_info(esd_svinfo); - } - */ - } - - esd_fmt = ESD_STREAM | ESD_PLAY; - -#if ESD_RESAMPLES - /* let the esd daemon convert sample rate */ -#else - /* let mplayer's audio filter convert the sample rate */ - if (esd_svinfo != NULL) - rate_hz = esd_svinfo->rate; -#endif - ao_data.samplerate = rate_hz; - - /* EsounD can play mono or stereo */ - switch (channels) { - case 1: - esd_fmt |= ESD_MONO; - ao_data.channels = bytes_per_sample = 1; - break; - default: - esd_fmt |= ESD_STEREO; - ao_data.channels = bytes_per_sample = 2; - break; - } - - /* EsounD can play 8bit unsigned and 16bit signed native */ - switch (format) { - case AF_FORMAT_S8: - case AF_FORMAT_U8: - esd_fmt |= ESD_BITS8; - ao_data.format = AF_FORMAT_U8; - break; - default: - esd_fmt |= ESD_BITS16; - ao_data.format = AF_FORMAT_S16_NE; - bytes_per_sample *= 2; - break; - } - - /* modify audio_delay depending on esd_latency - * latency is number of samples @ 44.1khz stereo 16 bit - * adjust according to rate_hz & bytes_per_sample - */ -#ifdef CONFIG_ESD_LATENCY - esd_latency = esd_get_latency(esd_fd); -#else - esd_latency = ((channels == 1 ? 2 : 1) * ESD_DEFAULT_RATE * - (ESD_BUF_SIZE + 64 * (4.0f / bytes_per_sample)) - ) / rate_hz; - esd_latency += ESD_BUF_SIZE * 2; -#endif - if(esd_latency > 0) { - lag_serv = (esd_latency * 4.0f) / (bytes_per_sample * rate_hz); - lag_seconds = lag_net + lag_serv; - audio_delay += lag_seconds; - mp_tmsg(MSGT_AO, MSGL_INFO,"[AO ESD] latency: [server: %0.2fs, net: %0.2fs] (adjust %0.2fs)\n", - lag_serv, lag_net, lag_seconds); - } - - esd_play_fd = esd_play_stream_fallback(esd_fmt, rate_hz, - server, ESD_CLIENT_NAME); - if (esd_play_fd < 0) { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ESD] failed to open ESD playback stream: %s\n", strerror(errno)); - return 0; - } - - /* enable non-blocking i/o on the socket connection to the esd server */ - if ((fl = fcntl(esd_play_fd, F_GETFL)) >= 0) - fcntl(esd_play_fd, F_SETFL, O_NDELAY|fl); - -#if ESD_DEBUG - { - int sbuf, rbuf, len; - len = sizeof(sbuf); - getsockopt(esd_play_fd, SOL_SOCKET, SO_SNDBUF, &sbuf, &len); - len = sizeof(rbuf); - getsockopt(esd_play_fd, SOL_SOCKET, SO_RCVBUF, &rbuf, &len); - dprintf("esd: send/receive socket buffer space %d/%d bytes\n", - sbuf, rbuf); - } -#endif - - ao_data.bps = bytes_per_sample * rate_hz; - ao_data.outburst = ao_data.bps > 100000 ? 4*ESD_BUF_SIZE : 2*ESD_BUF_SIZE; - - esd_play_start.tv_sec = 0; - esd_samples_written = 0; - esd_bytes_per_sample = bytes_per_sample; - - return 1; -} - - -/* - * close audio device - */ -static void uninit(int immed) -{ - if (esd_play_fd >= 0) { - esd_close(esd_play_fd); - esd_play_fd = -1; - } - - if (esd_svinfo) { - esd_free_server_info(esd_svinfo); - esd_svinfo = NULL; - } - - if (esd_fd >= 0) { - esd_close(esd_fd); - esd_fd = -1; - } -} - - -/* - * plays 'len' bytes of 'data' - * it should round it down to outburst*n - * return: number of bytes played - */ -static int play(void* data, int len, int flags) -{ - int offs; - int nwritten; - int nsamples; - int n; - - /* round down buffersize to a multiple of ESD_BUF_SIZE bytes */ - len = len / ESD_BUF_SIZE * ESD_BUF_SIZE; - if (len <= 0) - return 0; - -#define SINGLE_WRITE 0 -#if SINGLE_WRITE - nwritten = write(esd_play_fd, data, len); -#else - for (offs = 0, nwritten=0; offs + ESD_BUF_SIZE <= len; offs += ESD_BUF_SIZE) { - /* - * note: we're writing to a non-blocking socket here. - * A partial write means, that the socket buffer is full. - */ - n = write(esd_play_fd, (char*)data + offs, ESD_BUF_SIZE); - if ( n < 0 ) { - if ( errno != EAGAIN ) - dprintf("esd play: write failed: %s\n", strerror(errno)); - break; - } else if ( n != ESD_BUF_SIZE ) { - nwritten += n; - break; - } else - nwritten += n; - } -#endif - - if (nwritten > 0) { - if (!esd_play_start.tv_sec) - gettimeofday(&esd_play_start, NULL); - nsamples = nwritten / esd_bytes_per_sample; - esd_samples_written += nsamples; - - dprintf("esd play: %d %lu\n", nsamples, esd_samples_written); - } else { - dprintf("esd play: blocked / %lu\n", esd_samples_written); - } - - return nwritten; -} - - -/* - * stop playing, keep buffers (for pause) - */ -static void audio_pause(void) -{ - /* - * not possible with esd. the esd daemom will continue playing - * buffered data (not more than ESD_MAX_DELAY seconds of samples) - */ -} - - -/* - * resume playing, after audio_pause() - */ -static void audio_resume(void) -{ - /* - * not possible with esd. - * - * Let's hope the pause was long enough that the esd ran out of - * buffered data; we restart our time based delay computation - * for an audio resume. - */ - esd_play_start.tv_sec = 0; - esd_samples_written = 0; -} - - -/* - * stop playing and empty buffers (for seeking/pause) - */ -static void reset(void) -{ -#ifdef __svr4__ - /* throw away data buffered in the esd connection */ - if (ioctl(esd_play_fd, I_FLUSH, FLUSHW)) - perror("I_FLUSH"); -#endif -} - - -/* - * return: how many bytes can be played without blocking - */ -static int get_space(void) -{ - struct timeval tmout; - fd_set wfds; - float current_delay; - int space; - - /* - * Don't buffer too much data in the esd daemon. - * - * If we send too much, esd will block in write()s to the sound - * device, and the consequence is a huge slow down for things like - * esd_get_all_info(). - */ - if ((current_delay = get_delay()) >= ESD_MAX_DELAY) { - dprintf("esd get_space: too much data buffered\n"); - return 0; - } - - FD_ZERO(&wfds); - FD_SET(esd_play_fd, &wfds); - tmout.tv_sec = 0; - tmout.tv_usec = 0; - - if (select(esd_play_fd + 1, NULL, &wfds, NULL, &tmout) != 1) - return 0; - - if (!FD_ISSET(esd_play_fd, &wfds)) - return 0; - - /* try to fill 50% of the remaining "free" buffer space */ - space = (ESD_MAX_DELAY - current_delay) * ao_data.bps * 0.5f; - - /* round up to next multiple of ESD_BUF_SIZE */ - space = (space + ESD_BUF_SIZE-1) / ESD_BUF_SIZE * ESD_BUF_SIZE; - - dprintf("esd get_space: %d\n", space); - return space; -} - - -/* - * return: delay in seconds between first and last sample in buffer - */ -static float get_delay(void) -{ - struct timeval now; - double buffered_samples_time; - double play_time; - - if (!esd_play_start.tv_sec) - return 0; - - buffered_samples_time = (float)esd_samples_written / ao_data.samplerate; - gettimeofday(&now, NULL); - play_time = now.tv_sec - esd_play_start.tv_sec; - play_time += (now.tv_usec - esd_play_start.tv_usec) / 1000000.; - - /* dprintf("esd delay: %f %f\n", play_time, buffered_samples_time); */ - - if (play_time > buffered_samples_time) { - dprintf("esd: underflow\n"); - esd_play_start.tv_sec = 0; - esd_samples_written = 0; - return 0; - } - - dprintf("esd: get_delay %f\n", buffered_samples_time - play_time); - return buffered_samples_time - play_time; -} diff -Nru mplayer2-2.0-426-gc32b3ed/libao2/ao_kai.c mplayer2-2.0-554-gf63dbad/libao2/ao_kai.c --- mplayer2-2.0-426-gc32b3ed/libao2/ao_kai.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libao2/ao_kai.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,332 +0,0 @@ -/* - * OS/2 KAI audio output driver - * - * Copyright (c) 2010 by KO Myung-Hun (komh@chollian.net) - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#define INCL_DOS -#define INCL_DOSERRORS -#include - -#include -#include -#include -#include - -#include - -#include "config.h" -#include "libaf/af_format.h" -#include "audio_out.h" -#include "audio_out_internal.h" -#include "mp_msg.h" -#include "libvo/fastmemcpy.h" -#include "subopt-helper.h" -#include "libavutil/avutil.h" -#include "libavutil/fifo.h" - -static const ao_info_t info = { - "KAI audio output", - "kai", - "KO Myung-Hun ", - "" -}; - -LIBAO_EXTERN(kai) - -#define OUTBURST_SAMPLES 512 -#define DEFAULT_SAMPLES (OUTBURST_SAMPLES << 2) - -#define CHUNK_SIZE ao_data.outburst - -static AVFifoBuffer *m_audioBuf; - -static int m_nBufSize = 0; - -static volatile int m_fQuit = FALSE; - -static KAISPEC m_kaiSpec; - -static HKAI m_hkai; - -static int write_buffer(unsigned char *data, int len) -{ - int nFree = av_fifo_space(m_audioBuf); - - len = FFMIN(len, nFree); - - return av_fifo_generic_write(m_audioBuf, data, len, NULL); -} - -static int read_buffer(unsigned char *data, int len) -{ - int nBuffered = av_fifo_size(m_audioBuf); - - len = FFMIN(len, nBuffered); - - av_fifo_generic_read(m_audioBuf, data, len, NULL); - return len; -} - -// end ring buffer stuff - -static ULONG APIENTRY kai_audio_callback(PVOID pCBData, PVOID pBuffer, - ULONG ulSize) -{ - int nReadLen; - - nReadLen = read_buffer(pBuffer, ulSize); - if (nReadLen < ulSize && !m_fQuit) { - memset((uint8_t *)pBuffer + nReadLen, m_kaiSpec.bSilence, ulSize - nReadLen); - nReadLen = ulSize; - } - - return nReadLen; -} - -// to set/get/query special features/parameters -static int control(int cmd, void *arg) -{ - switch (cmd) { - case AOCONTROL_GET_VOLUME: - { - ao_control_vol_t *vol = arg; - - vol->left = vol->right = kaiGetVolume(m_hkai, MCI_STATUS_AUDIO_ALL); - - return CONTROL_OK; - } - - case AOCONTROL_SET_VOLUME: - { - int mid; - ao_control_vol_t *vol = arg; - - mid = (vol->left + vol->right) / 2; - kaiSetVolume(m_hkai, MCI_SET_AUDIO_ALL, mid); - - return CONTROL_OK; - } - } - - return CONTROL_UNKNOWN; -} - -static void print_help(void) -{ - mp_msg(MSGT_AO, MSGL_FATAL, - "\n-ao kai commandline help:\n" - "Example: mplayer -ao kai:noshare\n" - " open audio in exclusive mode\n" - "\nOptions:\n" - " uniaud\n" - " Use UNIAUD audio driver\n" - " dart\n" - " Use DART audio driver\n" - " (no)share\n" - " Open audio in shareable or exclusive mode\n" - " bufsize=\n" - " Set buffer size to in samples(default: 2048)\n"); -} - -// open & set up audio device -// return: 1=success 0=fail -static int init(int rate, int channels, int format, int flags) -{ - int fUseUniaud = 0; - int fUseDart = 0; - int fShare = 1; - ULONG kaiMode; - KAICAPS kc; - int nSamples = DEFAULT_SAMPLES; - int nBytesPerSample; - KAISPEC ksWanted; - - const opt_t subopts[] = { - {"uniaud", OPT_ARG_BOOL, &fUseUniaud, NULL}, - {"dart", OPT_ARG_BOOL, &fUseDart, NULL}, - {"share", OPT_ARG_BOOL, &fShare, NULL}, - {"bufsize", OPT_ARG_INT, &nSamples, int_non_neg}, - {NULL} - }; - - const char *audioDriver[] = {"DART", "UNIAUD",}; - - if (subopt_parse(ao_subdevice, subopts) != 0) { - print_help(); - return 0; - } - - if (fUseUniaud && fUseDart) - mp_msg(MSGT_VO, MSGL_WARN,"KAI: Multiple mode specified!!!\n"); - - if (fUseUniaud) - kaiMode = KAIM_UNIAUD; - else if (fUseDart) - kaiMode = KAIM_DART; - else - kaiMode = KAIM_AUTO; - - if (kaiInit(kaiMode)) { - mp_msg(MSGT_VO, MSGL_ERR, "KAI: Init failed!!!\n"); - return 0; - } - - kaiCaps(&kc); - mp_msg(MSGT_AO, MSGL_V, "KAI: selected audio driver = %s\n", - audioDriver[kc.ulMode - 1]); - mp_msg(MSGT_AO, MSGL_V, "KAI: PDD name = %s, maximum channels = %lu\n", - kc.szPDDName, kc.ulMaxChannels); - - if (!nSamples) - nSamples = DEFAULT_SAMPLES; - - mp_msg(MSGT_AO, MSGL_V, "KAI: open in %s mode, buffer size = %d sample(s)\n", - fShare ? "shareable" : "exclusive", nSamples); - - switch (format) { - case AF_FORMAT_S16_LE: - case AF_FORMAT_S8: - break; - - default: - format = AF_FORMAT_S16_LE; - mp_msg(MSGT_AO, MSGL_V, "KAI: format %s not supported defaulting to Signed 16-bit Little-Endian\n", - af_fmt2str_short(format)); - break; - } - - nBytesPerSample = (af_fmt2bits(format) >> 3) * channels; - - ksWanted.usDeviceIndex = 0; - ksWanted.ulType = KAIT_PLAY; - ksWanted.ulBitsPerSample = af_fmt2bits(format); - ksWanted.ulSamplingRate = rate; - ksWanted.ulDataFormat = MCI_WAVE_FORMAT_PCM; - ksWanted.ulChannels = channels; - ksWanted.ulNumBuffers = 2; - ksWanted.ulBufferSize = nBytesPerSample * nSamples; - ksWanted.fShareable = fShare; - ksWanted.pfnCallBack = kai_audio_callback; - ksWanted.pCallBackData = NULL; - - if (kaiOpen(&ksWanted, &m_kaiSpec, &m_hkai)) { - mp_msg(MSGT_VO, MSGL_ERR, "KAI: Open failed!!!\n"); - return 0; - } - - mp_msg(MSGT_AO, MSGL_V, "KAI: obtained buffer count = %lu, size = %lu bytes\n", - m_kaiSpec.ulNumBuffers, m_kaiSpec.ulBufferSize); - - m_fQuit = FALSE; - - ao_data.channels = channels; - ao_data.samplerate = rate; - ao_data.format = format; - ao_data.bps = nBytesPerSample * rate; - ao_data.outburst = nBytesPerSample * OUTBURST_SAMPLES; - ao_data.buffersize = m_kaiSpec.ulBufferSize; - - m_nBufSize = (m_kaiSpec.ulBufferSize * m_kaiSpec.ulNumBuffers) << 2; - - // multiple of CHUNK_SIZE - m_nBufSize = (m_nBufSize / CHUNK_SIZE) * CHUNK_SIZE; - - // and one more chunk plus round up - m_nBufSize += 2 * CHUNK_SIZE; - - mp_msg(MSGT_AO, MSGL_V, "KAI: internal audio buffer size = %d bytes\n", - m_nBufSize); - - m_audioBuf = av_fifo_alloc(m_nBufSize); - - kaiPlay(m_hkai); - - // might cause PM DLLs to be loaded which incorrectly enable SIG_FPE, - // which AAC decoding might trigger. - // so, mask off all floating-point exceptions. - _control87(MCW_EM, MCW_EM); - - return 1; -} - -// close audio device -static void uninit(int immed) -{ - m_fQuit = TRUE; - - if (!immed) - while (kaiStatus(m_hkai) & KAIS_PLAYING) - DosSleep(1); - - kaiClose(m_hkai); - - kaiDone(); - - av_fifo_free(m_audioBuf); -} - -// stop playing and empty buffers (for seeking/pause) -static void reset(void) -{ - kaiPause(m_hkai); - - // Reset ring-buffer state - av_fifo_reset(m_audioBuf); - - kaiResume(m_hkai); -} - -// stop playing, keep buffers (for pause) -static void audio_pause(void) -{ - kaiPause(m_hkai); -} - -// resume playing, after audio_pause() -static void audio_resume(void) -{ - kaiResume(m_hkai); -} - -// return: how many bytes can be played without blocking -static int get_space(void) -{ - return av_fifo_space(m_audioBuf); -} - -// plays 'len' bytes of 'data' -// it should round it down to outburst*n -// return: number of bytes played -static int play(void *data, int len, int flags) -{ - - if (!(flags & AOPLAY_FINAL_CHUNK)) - len = (len / ao_data.outburst) * ao_data.outburst; - - return write_buffer(data, len); -} - -// return: delay in seconds between first and last sample in buffer -static float get_delay(void) -{ - int nBuffered = av_fifo_size(m_audioBuf); // could be less - - return (float)nBuffered / (float)ao_data.bps; -} diff -Nru mplayer2-2.0-426-gc32b3ed/libao2/ao_nas.c mplayer2-2.0-554-gf63dbad/libao2/ao_nas.c --- mplayer2-2.0-426-gc32b3ed/libao2/ao_nas.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libao2/ao_nas.c 2012-05-17 14:38:00.000000000 +0000 @@ -424,6 +424,8 @@ (void)flags; /* shut up 'unused parameter' warning */ + global_ao->no_persistent_volume = true; + nas_data=malloc(sizeof(struct ao_nas_data)); memset(nas_data, 0, sizeof(struct ao_nas_data)); diff -Nru mplayer2-2.0-426-gc32b3ed/libao2/ao_openal.c mplayer2-2.0-554-gf63dbad/libao2/ao_openal.c --- mplayer2-2.0-426-gc32b3ed/libao2/ao_openal.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libao2/ao_openal.c 2012-05-17 14:38:00.000000000 +0000 @@ -108,6 +108,7 @@ const opt_t subopts[] = { {NULL} }; + global_ao->no_persistent_volume = true; if (subopt_parse(ao_subdevice, subopts) != 0) { print_help(); return 0; diff -Nru mplayer2-2.0-426-gc32b3ed/libao2/ao_oss.c mplayer2-2.0-554-gf63dbad/libao2/ao_oss.c --- mplayer2-2.0-426-gc32b3ed/libao2/ao_oss.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libao2/ao_oss.c 2012-05-17 14:38:00.000000000 +0000 @@ -179,22 +179,6 @@ // to set/get/query special features/parameters static int control(int cmd,void *arg){ switch(cmd){ - case AOCONTROL_SET_DEVICE: - dsp=(char*)arg; - return CONTROL_OK; - case AOCONTROL_GET_DEVICE: - *(char**)arg=dsp; - return CONTROL_OK; -#ifdef SNDCTL_DSP_GETFMTS - case AOCONTROL_QUERY_FORMAT: - { - int format; - if (!ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &format)) - if ((unsigned int)format & (unsigned long)arg) - return CONTROL_TRUE; - return CONTROL_FALSE; - } -#endif case AOCONTROL_GET_VOLUME: case AOCONTROL_SET_VOLUME: { diff -Nru mplayer2-2.0-426-gc32b3ed/libao2/ao_portaudio.c mplayer2-2.0-554-gf63dbad/libao2/ao_portaudio.c --- mplayer2-2.0-426-gc32b3ed/libao2/ao_portaudio.c 1970-01-01 00:00:00.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libao2/ao_portaudio.c 2012-05-17 14:38:00.000000000 +0000 @@ -0,0 +1,431 @@ +/* + * This file is part of mplayer2. + * + * mplayer2 is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * mplayer2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with mplayer2. If not, see . + */ + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "config.h" +#include "subopt-helper.h" +#include "libaf/af_format.h" +#include "mp_msg.h" +#include "audio_out.h" + +struct priv { + PaStream *stream; + int framelen; + + pthread_mutex_t ring_mutex; + + // protected by ring_mutex + unsigned char *ring; + int ring_size; // max size of the ring + int read_pos; // points to first byte that can be read + int read_len; // number of bytes that can be read + double play_time; // time when last packet returned to PA is on speaker + // 0 is N/A (0 is not a valid PA time value) + int play_silence; // play this many bytes of silence, before real data + bool play_remaining;// play what's left in the buffer, then stop stream +}; + +struct format_map { + int mp_format; + PaSampleFormat pa_format; +}; + +static const struct format_map format_maps[] = { + // first entry is the default format + {AF_FORMAT_S16_NE, paInt16}, + {AF_FORMAT_S24_NE, paInt24}, + {AF_FORMAT_S32_NE, paInt32}, + {AF_FORMAT_S8, paInt8}, + {AF_FORMAT_U8, paUInt8}, + {AF_FORMAT_FLOAT_NE, paFloat32}, + {AF_FORMAT_UNKNOWN, 0} +}; + +static void print_help(void) +{ + mp_msg(MSGT_AO, MSGL_FATAL, + "\n-ao portaudio commandline help:\n" + "Example: mplayer -ao portaudio:device=subdevice\n" + "\nOptions:\n" + " device=subdevice\n" + " Audio device PortAudio should use. Devices can be listed\n" + " with -ao portaudio:device=help\n" + " The subdevice can be passed as index, or as complete name.\n"); +} + +static bool check_pa_ret(int ret) +{ + if (ret < 0) { + mp_msg(MSGT_AO, MSGL_ERR, "[portaudio] %s\n", + Pa_GetErrorText(ret)); + if (ret == paUnanticipatedHostError) { + const PaHostErrorInfo* hosterr = Pa_GetLastHostErrorInfo(); + mp_msg(MSGT_AO, MSGL_ERR, "[portaudio] Host error: %s\n", + hosterr->errorText); + } + return false; + } + return true; +} + +// Amount of bytes that contain audio of the given duration, aligned to frames. +static int seconds_to_bytes(struct ao *ao, double duration_seconds) +{ + struct priv *priv = ao->priv; + + int bytes = duration_seconds * ao->bps; + if (bytes % priv->framelen) + bytes += priv->framelen - (bytes % priv->framelen); + return bytes; +} + +static int to_int(const char *s, int return_on_error) +{ + char *endptr; + int res = strtol(s, &endptr, 10); + return (s[0] && !endptr[0]) ? res : return_on_error; +} + +static int find_device(struct ao *ao, const char *name) +{ + int help = strcmp(name, "help") == 0; + int count = Pa_GetDeviceCount(); + check_pa_ret(count); + int found = paNoDevice; + int index = to_int(name, -1); + if (help) + mp_msg(MSGT_AO, MSGL_INFO, "PortAudio devices:\n"); + for (int n = 0; n < count; n++) { + const PaDeviceInfo* info = Pa_GetDeviceInfo(n); + if (help) { + if (info->maxOutputChannels < 1) + continue; + mp_msg(MSGT_AO, MSGL_INFO, " %d '%s', %d channels, latency: %.2f " + "ms, sample rate: %.0f\n", n, info->name, + info->maxOutputChannels, + info->defaultHighOutputLatency * 1000, + info->defaultSampleRate); + } + if (strcmp(name, info->name) == 0 || n == index) { + found = n; + break; + } + } + if (found == paNoDevice && !help) + mp_msg(MSGT_AO, MSGL_FATAL, "[portaudio] Device '%s' not found!\n", + name); + return found; +} + +static int ring_write(struct ao *ao, unsigned char *data, int len) +{ + struct priv *priv = ao->priv; + + int free = priv->ring_size - priv->read_len; + int write_pos = (priv->read_pos + priv->read_len) % priv->ring_size; + int write_len = FFMIN(len, free); + int len1 = FFMIN(priv->ring_size - write_pos, write_len); + int len2 = write_len - len1; + + memcpy(priv->ring + write_pos, data, len1); + memcpy(priv->ring, data + len1, len2); + + priv->read_len += write_len; + + return write_len; +} + +static int ring_read(struct ao *ao, unsigned char *data, int len) +{ + struct priv *priv = ao->priv; + + int read_len = FFMIN(len, priv->read_len); + int len1 = FFMIN(priv->ring_size - priv->read_pos, read_len); + int len2 = read_len - len1; + + memcpy(data, priv->ring + priv->read_pos, len1); + memcpy(data + len1, priv->ring, len2); + + priv->read_len -= read_len; + priv->read_pos = (priv->read_pos + read_len) % priv->ring_size; + + return read_len; +} + +static void fill_silence(unsigned char *ptr, int len) +{ + memset(ptr, 0, len); +} + +static int stream_callback(const void *input, + void *output_v, + unsigned long frameCount, + const PaStreamCallbackTimeInfo *timeInfo, + PaStreamCallbackFlags statusFlags, + void *userData) +{ + struct ao *ao = userData; + struct priv *priv = ao->priv; + int res = paContinue; + unsigned char *output = output_v; + int len_bytes = frameCount * priv->framelen; + + pthread_mutex_lock(&priv->ring_mutex); + + // NOTE: PA + ALSA in dmix mode seems to pretend that there is no latency + // (outputBufferDacTime == currentTime) + priv->play_time = timeInfo->outputBufferDacTime + + len_bytes / (float)ao->bps; + + if (priv->play_silence > 0) { + int bytes = FFMIN(priv->play_silence, len_bytes); + fill_silence(output, bytes); + priv->play_silence -= bytes; + len_bytes -= bytes; + output += bytes; + } + int read = ring_read(ao, output, len_bytes); + len_bytes -= read; + output += read; + + if (len_bytes > 0) { + if (priv->play_remaining) { + res = paComplete; + priv->play_remaining = false; + } else { + mp_msg(MSGT_AO, MSGL_ERR, "[portaudio] Buffer underflow!\n"); + } + fill_silence(output, len_bytes); + } + + pthread_mutex_unlock(&priv->ring_mutex); + + return res; +} + +static void uninit(struct ao *ao, bool cut_audio) +{ + struct priv *priv = ao->priv; + + if (priv->stream) { + if (!cut_audio && Pa_IsStreamActive(priv->stream) == 1) { + pthread_mutex_lock(&priv->ring_mutex); + + priv->play_remaining = true; + + pthread_mutex_unlock(&priv->ring_mutex); + + check_pa_ret(Pa_StopStream(priv->stream)); + } + check_pa_ret(Pa_CloseStream(priv->stream)); + } + + pthread_mutex_destroy(&priv->ring_mutex); + Pa_Terminate(); +} + +static int init(struct ao *ao, char *params) +{ + struct priv *priv = talloc_zero(ao, struct priv); + ao->priv = priv; + + if (!check_pa_ret(Pa_Initialize())) + return -1; + + pthread_mutex_init(&priv->ring_mutex, NULL); + + char *device = NULL; + const opt_t subopts[] = { + {"device", OPT_ARG_MSTRZ, &device, NULL}, + {NULL} + }; + if (subopt_parse(params, subopts) != 0) { + print_help(); + goto error_exit; + } + + int pa_device = Pa_GetDefaultOutputDevice(); + if (device) + pa_device = find_device(ao, device); + if (pa_device == paNoDevice) + goto error_exit; + + PaStreamParameters sp = { + .device = pa_device, + .channelCount = ao->channels, + .suggestedLatency + = Pa_GetDeviceInfo(pa_device)->defaultHighOutputLatency, + }; + + const struct format_map *fmt = format_maps; + while (fmt->pa_format) { + if (fmt->mp_format == ao->format) { + PaStreamParameters test = sp; + test.sampleFormat = fmt->pa_format; + if (Pa_IsFormatSupported(NULL, &test, ao->samplerate) == paNoError) + break; + } + fmt++; + } + if (!fmt->pa_format) { + mp_msg(MSGT_AO, MSGL_V, + "[portaudio] Unsupported format, using default.\n"); + fmt = format_maps; + } + + ao->format = fmt->mp_format; + sp.sampleFormat = fmt->pa_format; + priv->framelen = ao->channels * (af_fmt2bits(ao->format) / 8); + ao->bps = ao->samplerate * priv->framelen; + + if (!check_pa_ret(Pa_IsFormatSupported(NULL, &sp, ao->samplerate))) + goto error_exit; + if (!check_pa_ret(Pa_OpenStream(&priv->stream, NULL, &sp, ao->samplerate, + paFramesPerBufferUnspecified, paNoFlag, + stream_callback, ao))) + goto error_exit; + + priv->ring_size = seconds_to_bytes(ao, 0.5); + priv->ring = talloc_zero_size(priv, priv->ring_size); + + free(device); + return 0; + +error_exit: + uninit(ao, true); + free(device); + return -1; +} + +static int play(struct ao *ao, void *data, int len, int flags) +{ + struct priv *priv = ao->priv; + + pthread_mutex_lock(&priv->ring_mutex); + + int write_len = ring_write(ao, data, len); + if (flags & AOPLAY_FINAL_CHUNK) + priv->play_remaining = true; + + pthread_mutex_unlock(&priv->ring_mutex); + + if (Pa_IsStreamStopped(priv->stream) == 1) + check_pa_ret(Pa_StartStream(priv->stream)); + + return write_len; +} + +static int get_space(struct ao *ao) +{ + struct priv *priv = ao->priv; + + pthread_mutex_lock(&priv->ring_mutex); + + int free = priv->ring_size - priv->read_len; + + pthread_mutex_unlock(&priv->ring_mutex); + + return free; +} + +static float get_delay(struct ao *ao) +{ + struct priv *priv = ao->priv; + + double stream_time = Pa_GetStreamTime(priv->stream); + + pthread_mutex_lock(&priv->ring_mutex); + + float frame_time = priv->play_time ? priv->play_time - stream_time : 0; + float buffer_latency = (priv->read_len + priv->play_silence) + / (float)ao->bps; + + pthread_mutex_unlock(&priv->ring_mutex); + + return buffer_latency + frame_time; +} + +static void reset(struct ao *ao) +{ + struct priv *priv = ao->priv; + + if (Pa_IsStreamStopped(priv->stream) != 1) + check_pa_ret(Pa_AbortStream(priv->stream)); + + pthread_mutex_lock(&priv->ring_mutex); + + priv->read_len = 0; + priv->read_pos = 0; + priv->play_remaining = false; + priv->play_time = 0; + priv->play_silence = 0; + + pthread_mutex_unlock(&priv->ring_mutex); +} + +static void pause(struct ao *ao) +{ + struct priv *priv = ao->priv; + + check_pa_ret(Pa_AbortStream(priv->stream)); + + double stream_time = Pa_GetStreamTime(priv->stream); + + pthread_mutex_lock(&priv->ring_mutex); + + // When playback resumes, replace the lost audio (due to dropping the + // portaudio/driver/hardware internal buffers) with silence. + float frame_time = priv->play_time ? priv->play_time - stream_time : 0; + priv->play_silence += seconds_to_bytes(ao, FFMAX(frame_time, 0)); + priv->play_time = 0; + + pthread_mutex_unlock(&priv->ring_mutex); +} + +static void resume(struct ao *ao) +{ + struct priv *priv = ao->priv; + + check_pa_ret(Pa_StartStream(priv->stream)); +} + +const struct ao_driver audio_out_portaudio = { + .is_new = true, + .info = &(const struct ao_info) { + "PortAudio", + "portaudio", + "wm4", + "", + }, + .init = init, + .uninit = uninit, + .reset = reset, + .get_space = get_space, + .play = play, + .get_delay = get_delay, + .pause = pause, + .resume = resume, +}; diff -Nru mplayer2-2.0-426-gc32b3ed/libao2/ao_pulse.c mplayer2-2.0-554-gf63dbad/libao2/ao_pulse.c --- mplayer2-2.0-426-gc32b3ed/libao2/ao_pulse.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libao2/ao_pulse.c 2012-05-17 14:38:00.000000000 +0000 @@ -20,6 +20,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include +#include #include #include @@ -28,67 +30,80 @@ #include "libaf/af_format.h" #include "mp_msg.h" #include "audio_out.h" -#include "audio_out_internal.h" +#include "input/input.h" -#define PULSE_CLIENT_NAME "MPlayer" +#define PULSE_CLIENT_NAME "mplayer2" -/** General driver info */ -static const ao_info_t info = { - "PulseAudio audio output", - "pulse", - "Lennart Poettering", - "" -}; -/** PulseAudio playback stream object */ -static struct pa_stream *stream; +struct priv { + // PulseAudio playback stream object + struct pa_stream *stream; -/** PulseAudio connection context */ -static struct pa_context *context; + // PulseAudio connection context + struct pa_context *context; -/** Main event loop object */ -static struct pa_threaded_mainloop *mainloop; + // Main event loop object + struct pa_threaded_mainloop *mainloop; -static int broken_pause; + // temporary during control() + struct pa_sink_input_info pi; -LIBAO_EXTERN(pulse) + bool broken_pause; + int retval; + bool did_reset; +}; #define GENERIC_ERR_MSG(ctx, str) \ mp_msg(MSGT_AO, MSGL_ERR, "AO: [pulse] "str": %s\n", \ - pa_strerror(pa_context_errno(ctx))) + pa_strerror(pa_context_errno(ctx))) -static void context_state_cb(pa_context *c, void *userdata) { +static void context_state_cb(pa_context *c, void *userdata) +{ + struct ao *ao = userdata; + struct priv *priv = ao->priv; switch (pa_context_get_state(c)) { - case PA_CONTEXT_READY: - case PA_CONTEXT_TERMINATED: - case PA_CONTEXT_FAILED: - pa_threaded_mainloop_signal(mainloop, 0); - break; + case PA_CONTEXT_READY: + case PA_CONTEXT_TERMINATED: + case PA_CONTEXT_FAILED: + pa_threaded_mainloop_signal(priv->mainloop, 0); + break; } } -static void stream_state_cb(pa_stream *s, void *userdata) { +static void stream_state_cb(pa_stream *s, void *userdata) +{ + struct ao *ao = userdata; + struct priv *priv = ao->priv; switch (pa_stream_get_state(s)) { - case PA_STREAM_READY: - case PA_STREAM_FAILED: - case PA_STREAM_TERMINATED: - pa_threaded_mainloop_signal(mainloop, 0); - break; + case PA_STREAM_READY: + case PA_STREAM_FAILED: + case PA_STREAM_TERMINATED: + pa_threaded_mainloop_signal(priv->mainloop, 0); + break; } } -static void stream_request_cb(pa_stream *s, size_t length, void *userdata) { - pa_threaded_mainloop_signal(mainloop, 0); -} - -static void stream_latency_update_cb(pa_stream *s, void *userdata) { - pa_threaded_mainloop_signal(mainloop, 0); -} - -static void success_cb(pa_stream *s, int success, void *userdata) { - if (userdata) - *(int *)userdata = success; - pa_threaded_mainloop_signal(mainloop, 0); +static void stream_request_cb(pa_stream *s, size_t length, void *userdata) +{ + struct ao *ao = userdata; + struct priv *priv = ao->priv; + mp_input_wakeup(ao->input_ctx); + pa_threaded_mainloop_signal(priv->mainloop, 0); +} + +static void stream_latency_update_cb(pa_stream *s, void *userdata) +{ + struct ao *ao = userdata; + struct priv *priv = ao->priv; + pa_threaded_mainloop_signal(priv->mainloop, 0); +} + +static void success_cb(pa_stream *s, int success, void *userdata) +{ + struct ao *ao = userdata; + struct priv *priv = ao->priv; + priv->retval = success; + pa_threaded_mainloop_signal(priv->mainloop, 0); } /** @@ -97,85 +112,116 @@ * \param op operation to wait for * \return 1 if operation has finished normally (DONE state), 0 otherwise */ -static int waitop(pa_operation *op) { - pa_operation_state_t state; +static int waitop(struct priv *priv, pa_operation *op) +{ if (!op) { - pa_threaded_mainloop_unlock(mainloop); + pa_threaded_mainloop_unlock(priv->mainloop); return 0; } - state = pa_operation_get_state(op); + pa_operation_state_t state = pa_operation_get_state(op); while (state == PA_OPERATION_RUNNING) { - pa_threaded_mainloop_wait(mainloop); + pa_threaded_mainloop_wait(priv->mainloop); state = pa_operation_get_state(op); } pa_operation_unref(op); - pa_threaded_mainloop_unlock(mainloop); + pa_threaded_mainloop_unlock(priv->mainloop); return state == PA_OPERATION_DONE; } -static const struct format_map_s { +static const struct format_map { int mp_format; pa_sample_format_t pa_format; } format_maps[] = { {AF_FORMAT_S16_LE, PA_SAMPLE_S16LE}, {AF_FORMAT_S16_BE, PA_SAMPLE_S16BE}, -#ifdef PA_SAMPLE_S32NE {AF_FORMAT_S32_LE, PA_SAMPLE_S32LE}, {AF_FORMAT_S32_BE, PA_SAMPLE_S32BE}, -#endif -#ifdef PA_SAMPLE_FLOAT32NE {AF_FORMAT_FLOAT_LE, PA_SAMPLE_FLOAT32LE}, {AF_FORMAT_FLOAT_BE, PA_SAMPLE_FLOAT32BE}, -#endif {AF_FORMAT_U8, PA_SAMPLE_U8}, {AF_FORMAT_MU_LAW, PA_SAMPLE_ULAW}, {AF_FORMAT_A_LAW, PA_SAMPLE_ALAW}, {AF_FORMAT_UNKNOWN, 0} }; -static int init(int rate_hz, int channels, int format, int flags) { +static void uninit(struct ao *ao, bool cut_audio) +{ + struct priv *priv = ao->priv; + if (priv->stream && !cut_audio) { + pa_threaded_mainloop_lock(priv->mainloop); + waitop(priv, pa_stream_drain(priv->stream, success_cb, ao)); + } + + if (priv->mainloop) + pa_threaded_mainloop_stop(priv->mainloop); + + if (priv->stream) { + pa_stream_disconnect(priv->stream); + pa_stream_unref(priv->stream); + priv->stream = NULL; + } + + if (priv->context) { + pa_context_disconnect(priv->context); + pa_context_unref(priv->context); + priv->context = NULL; + } + + if (priv->mainloop) { + pa_threaded_mainloop_free(priv->mainloop); + priv->mainloop = NULL; + } +} + +static int init(struct ao *ao, char *params) +{ struct pa_sample_spec ss; struct pa_channel_map map; - const struct format_map_s *fmt_map; char *devarg = NULL; char *host = NULL; char *sink = NULL; const char *version = pa_get_library_version(); - if (ao_subdevice) { - devarg = strdup(ao_subdevice); - sink = strchr(devarg, ':'); - if (sink) *sink++ = 0; - if (devarg[0]) host = devarg; - } + struct priv *priv = talloc_zero(ao, struct priv); + ao->priv = priv; - broken_pause = 0; - // not sure which versions are affected, assume 0.9.11* to 0.9.14* - // known bad: 0.9.14, 0.9.13 - // known good: 0.9.9, 0.9.10, 0.9.15 - // to test: pause, wait ca. 5 seconds framestep and see if MPlayer hangs somewhen - if (strncmp(version, "0.9.1", 5) == 0 && version[5] >= '1' && version[5] <= '4') { - mp_msg(MSGT_AO, MSGL_WARN, "[pulse] working around probably broken pause functionality,\n" - " see http://www.pulseaudio.org/ticket/440\n"); - broken_pause = 1; + if (params) { + devarg = strdup(params); + sink = strchr(devarg, ':'); + if (sink) + *sink++ = 0; + if (devarg[0]) + host = devarg; + } + + priv->broken_pause = false; + /* not sure which versions are affected, assume 0.9.11* to 0.9.14* + * known bad: 0.9.14, 0.9.13 + * known good: 0.9.9, 0.9.10, 0.9.15 + * To test: pause, wait ca. 5 seconds, framestep and see if MPlayer + * hangs somewhen. */ + if (strncmp(version, "0.9.1", 5) == 0 && version[5] >= '1' + && version[5] <= '4') { + mp_msg(MSGT_AO, MSGL_WARN, + "[pulse] working around probably broken pause functionality,\n" + " see http://www.pulseaudio.org/ticket/440\n"); + priv->broken_pause = true; } - ss.channels = channels; - ss.rate = rate_hz; + ss.channels = ao->channels; + ss.rate = ao->samplerate; - ao_data.samplerate = rate_hz; - ao_data.channels = channels; - - fmt_map = format_maps; - while (fmt_map->mp_format != format) { + const struct format_map *fmt_map = format_maps; + while (fmt_map->mp_format != ao->format) { if (fmt_map->mp_format == AF_FORMAT_UNKNOWN) { - mp_msg(MSGT_AO, MSGL_V, "AO: [pulse] Unsupported format, using default\n"); + mp_msg(MSGT_AO, MSGL_V, + "AO: [pulse] Unsupported format, using default\n"); fmt_map = format_maps; break; } fmt_map++; } - ao_data.format = fmt_map->mp_format; + ao->format = fmt_map->mp_format; ss.format = fmt_map->pa_format; if (!pa_sample_spec_valid(&ss)) { @@ -184,227 +230,293 @@ } pa_channel_map_init_auto(&map, ss.channels, PA_CHANNEL_MAP_ALSA); - ao_data.bps = pa_bytes_per_second(&ss); + ao->bps = pa_bytes_per_second(&ss); - if (!(mainloop = pa_threaded_mainloop_new())) { + if (!(priv->mainloop = pa_threaded_mainloop_new())) { mp_msg(MSGT_AO, MSGL_ERR, "AO: [pulse] Failed to allocate main loop\n"); goto fail; } - if (!(context = pa_context_new(pa_threaded_mainloop_get_api(mainloop), PULSE_CLIENT_NAME))) { + if (!(priv->context = pa_context_new(pa_threaded_mainloop_get_api( + priv->mainloop), PULSE_CLIENT_NAME))) { mp_msg(MSGT_AO, MSGL_ERR, "AO: [pulse] Failed to allocate context\n"); goto fail; } - pa_context_set_state_callback(context, context_state_cb, NULL); + pa_context_set_state_callback(priv->context, context_state_cb, ao); - if (pa_context_connect(context, host, 0, NULL) < 0) + if (pa_context_connect(priv->context, host, 0, NULL) < 0) goto fail; - pa_threaded_mainloop_lock(mainloop); + pa_threaded_mainloop_lock(priv->mainloop); - if (pa_threaded_mainloop_start(mainloop) < 0) + if (pa_threaded_mainloop_start(priv->mainloop) < 0) goto unlock_and_fail; /* Wait until the context is ready */ - pa_threaded_mainloop_wait(mainloop); + pa_threaded_mainloop_wait(priv->mainloop); - if (pa_context_get_state(context) != PA_CONTEXT_READY) + if (pa_context_get_state(priv->context) != PA_CONTEXT_READY) goto unlock_and_fail; - if (!(stream = pa_stream_new(context, "audio stream", &ss, &map))) + if (!(priv->stream = pa_stream_new(priv->context, "audio stream", &ss, + &map))) goto unlock_and_fail; - pa_stream_set_state_callback(stream, stream_state_cb, NULL); - pa_stream_set_write_callback(stream, stream_request_cb, NULL); - pa_stream_set_latency_update_callback(stream, stream_latency_update_cb, NULL); - - if (pa_stream_connect_playback(stream, sink, NULL, PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE, NULL, NULL) < 0) + pa_stream_set_state_callback(priv->stream, stream_state_cb, ao); + pa_stream_set_write_callback(priv->stream, stream_request_cb, ao); + pa_stream_set_latency_update_callback(priv->stream, + stream_latency_update_cb, ao); + pa_buffer_attr bufattr = { + .maxlength = -1, + .tlength = pa_usec_to_bytes(1000000, &ss), + .prebuf = -1, + .minreq = -1, + .fragsize = -1, + }; + if (pa_stream_connect_playback(priv->stream, sink, &bufattr, + PA_STREAM_INTERPOLATE_TIMING + | PA_STREAM_AUTO_TIMING_UPDATE, NULL, + NULL) < 0) goto unlock_and_fail; /* Wait until the stream is ready */ - pa_threaded_mainloop_wait(mainloop); + pa_threaded_mainloop_wait(priv->mainloop); - if (pa_stream_get_state(stream) != PA_STREAM_READY) + if (pa_stream_get_state(priv->stream) != PA_STREAM_READY) goto unlock_and_fail; - pa_threaded_mainloop_unlock(mainloop); + pa_threaded_mainloop_unlock(priv->mainloop); free(devarg); - return 1; + return 0; unlock_and_fail: - if (mainloop) - pa_threaded_mainloop_unlock(mainloop); + if (priv->mainloop) + pa_threaded_mainloop_unlock(priv->mainloop); fail: - if (context) - GENERIC_ERR_MSG(context, "Init failed"); + if (priv->context) + GENERIC_ERR_MSG(priv->context, "Init failed"); free(devarg); - uninit(1); - return 0; -} - -/** Destroy libao driver */ -static void uninit(int immed) { - if (stream && !immed) { - pa_threaded_mainloop_lock(mainloop); - waitop(pa_stream_drain(stream, success_cb, NULL)); - } - - if (mainloop) - pa_threaded_mainloop_stop(mainloop); - - if (stream) { - pa_stream_disconnect(stream); - pa_stream_unref(stream); - stream = NULL; - } - - if (context) { - pa_context_disconnect(context); - pa_context_unref(context); - context = NULL; - } - - if (mainloop) { - pa_threaded_mainloop_free(mainloop); - mainloop = NULL; - } + uninit(ao, true); + return -1; } -/** Play the specified data to the pulseaudio server */ -static int play(void* data, int len, int flags) { - pa_threaded_mainloop_lock(mainloop); - if (pa_stream_write(stream, data, len, NULL, 0, PA_SEEK_RELATIVE) < 0) { - GENERIC_ERR_MSG(context, "pa_stream_write() failed"); +static void cork(struct ao *ao, bool pause) +{ + struct priv *priv = ao->priv; + pa_threaded_mainloop_lock(priv->mainloop); + priv->retval = 0; + if (!waitop(priv, pa_stream_cork(priv->stream, pause, success_cb, ao)) || + !priv->retval) + GENERIC_ERR_MSG(priv->context, "pa_stream_cork() failed"); +} + +// Play the specified data to the pulseaudio server +static int play(struct ao *ao, void *data, int len, int flags) +{ + struct priv *priv = ao->priv; + /* For some reason Pulseaudio behaves worse if this is done after + * the write - rapidly repeated seeks result in bogus increasing + * reported latency. */ + if (priv->did_reset) + cork(ao, false); + pa_threaded_mainloop_lock(priv->mainloop); + if (pa_stream_write(priv->stream, data, len, NULL, 0, + PA_SEEK_RELATIVE) < 0) { + GENERIC_ERR_MSG(priv->context, "pa_stream_write() failed"); len = -1; } - pa_threaded_mainloop_unlock(mainloop); + if (priv->did_reset) { + priv->did_reset = false; + if (!waitop(priv, pa_stream_update_timing_info(priv->stream, + success_cb, ao)) + || !priv->retval) + GENERIC_ERR_MSG(priv->context, "pa_stream_UPP() failed"); + } else + pa_threaded_mainloop_unlock(priv->mainloop); return len; } -static void cork(int b) { - int success = 0; - pa_threaded_mainloop_lock(mainloop); - if (!waitop(pa_stream_cork(stream, b, success_cb, &success)) || - !success) - GENERIC_ERR_MSG(context, "pa_stream_cork() failed"); -} - -/** Pause the audio stream by corking it on the server */ -static void audio_pause(void) { - cork(1); -} - -/** Resume the audio stream by uncorking it on the server */ -static void audio_resume(void) { - // without this, certain versions will cause an infinite hang because - // pa_stream_writable_size returns 0 always. - // Note that this workaround causes A-V desync after pause - if (broken_pause) reset(); - cork(0); -} - -/** Reset the audio stream, i.e. flush the playback buffer on the server side */ -static void reset(void) { - int success = 0; - pa_threaded_mainloop_lock(mainloop); - if (!waitop(pa_stream_flush(stream, success_cb, &success)) || - !success) - GENERIC_ERR_MSG(context, "pa_stream_flush() failed"); -} - -/** Return number of bytes that may be written to the server without blocking */ -static int get_space(void) { - size_t l; - pa_threaded_mainloop_lock(mainloop); - l = pa_stream_writable_size(stream); - pa_threaded_mainloop_unlock(mainloop); - return l; -} - -/** Return the current latency in seconds */ -static float get_delay(void) { +// Reset the audio stream, i.e. flush the playback buffer on the server side +static void reset(struct ao *ao) +{ + // pa_stream_flush() works badly if not corked + cork(ao, true); + struct priv *priv = ao->priv; + pa_threaded_mainloop_lock(priv->mainloop); + priv->retval = 0; + if (!waitop(priv, pa_stream_flush(priv->stream, success_cb, ao)) || + !priv->retval) + GENERIC_ERR_MSG(priv->context, "pa_stream_flush() failed"); + priv->did_reset = true; +} + +// Pause the audio stream by corking it on the server +static void pause(struct ao *ao) +{ + cork(ao, true); +} + +// Resume the audio stream by uncorking it on the server +static void resume(struct ao *ao) +{ + struct priv *priv = ao->priv; + if (priv->did_reset) + return; + /* Without this, certain versions will cause an infinite hang because + * pa_stream_writable_size returns 0 always. + * Note that this workaround causes A-V desync after pause. */ + if (priv->broken_pause) + reset(ao); + cork(ao, false); +} + +// Return number of bytes that may be written to the server without blocking +static int get_space(struct ao *ao) +{ + struct priv *priv = ao->priv; + pa_threaded_mainloop_lock(priv->mainloop); + size_t space = pa_stream_writable_size(priv->stream); + pa_threaded_mainloop_unlock(priv->mainloop); + return space; +} + +// Return the current latency in seconds +static float get_delay(struct ao *ao) +{ + struct priv *priv = ao->priv; pa_usec_t latency = (pa_usec_t) -1; - pa_threaded_mainloop_lock(mainloop); - while (pa_stream_get_latency(stream, &latency, NULL) < 0) { - if (pa_context_errno(context) != PA_ERR_NODATA) { - GENERIC_ERR_MSG(context, "pa_stream_get_latency() failed"); + pa_threaded_mainloop_lock(priv->mainloop); + while (pa_stream_get_latency(priv->stream, &latency, NULL) < 0) { + if (pa_context_errno(priv->context) != PA_ERR_NODATA) { + GENERIC_ERR_MSG(priv->context, "pa_stream_get_latency() failed"); break; } /* Wait until latency data is available again */ - pa_threaded_mainloop_wait(mainloop); + pa_threaded_mainloop_wait(priv->mainloop); } - pa_threaded_mainloop_unlock(mainloop); + pa_threaded_mainloop_unlock(priv->mainloop); return latency == (pa_usec_t) -1 ? 0 : latency / 1000000.0; } -/** A callback function that is called when the +/* A callback function that is called when the * pa_context_get_sink_input_info() operation completes. Saves the - * volume field of the specified structure to the global variable volume. */ -static void info_func(struct pa_context *c, const struct pa_sink_input_info *i, int is_last, void *userdata) { - struct pa_cvolume *volume = userdata; + * volume field of the specified structure to the global variable volume. + */ +static void info_func(struct pa_context *c, const struct pa_sink_input_info *i, + int is_last, void *userdata) +{ + struct ao *ao = userdata; + struct priv *priv = ao->priv; if (is_last < 0) { - GENERIC_ERR_MSG(context, "Failed to get sink input info"); + GENERIC_ERR_MSG(priv->context, "Failed to get sink input info"); return; } if (!i) return; - *volume = i->volume; - pa_threaded_mainloop_signal(mainloop, 0); + priv->pi = *i; + pa_threaded_mainloop_signal(priv->mainloop, 0); } -static int control(int cmd, void *arg) { +static int control(struct ao *ao, enum aocontrol cmd, void *arg) +{ + struct priv *priv = ao->priv; switch (cmd) { - case AOCONTROL_GET_VOLUME: { + case AOCONTROL_GET_MUTE: + case AOCONTROL_GET_VOLUME: { + uint32_t devidx = pa_stream_get_index(priv->stream); + pa_threaded_mainloop_lock(priv->mainloop); + if (!waitop(priv, pa_context_get_sink_input_info(priv->context, devidx, + info_func, ao))) { + GENERIC_ERR_MSG(priv->context, + "pa_stream_get_sink_input_info() failed"); + return CONTROL_ERROR; + } + // Warning: some information in pi might be unaccessible, because + // we naively copied the struct, without updating pointers etc. + // Pointers might point to invalid data, accessors might fail. + if (cmd == AOCONTROL_GET_VOLUME) { ao_control_vol_t *vol = arg; - uint32_t devidx = pa_stream_get_index(stream); - struct pa_cvolume volume; - pa_threaded_mainloop_lock(mainloop); - if (!waitop(pa_context_get_sink_input_info(context, devidx, info_func, &volume))) { - GENERIC_ERR_MSG(context, "pa_stream_get_sink_input_info() failed"); - return CONTROL_ERROR; - } - - if (volume.channels != 2) - vol->left = vol->right = pa_cvolume_avg(&volume)*100/PA_VOLUME_NORM; + if (priv->pi.volume.channels != 2) + vol->left = vol->right = + pa_cvolume_avg(&priv->pi.volume) * 100 / PA_VOLUME_NORM; else { - vol->left = volume.values[0]*100/PA_VOLUME_NORM; - vol->right = volume.values[1]*100/PA_VOLUME_NORM; + vol->left = priv->pi.volume.values[0] * 100 / PA_VOLUME_NORM; + vol->right = priv->pi.volume.values[1] * 100 / PA_VOLUME_NORM; } - - return CONTROL_OK; + } else if (cmd == AOCONTROL_GET_MUTE) { + bool *mute = arg; + *mute = priv->pi.mute; } + return CONTROL_OK; + } + + case AOCONTROL_SET_MUTE: + case AOCONTROL_SET_VOLUME: { + pa_operation *o; - case AOCONTROL_SET_VOLUME: { + pa_threaded_mainloop_lock(priv->mainloop); + uint32_t stream_index = pa_stream_get_index(priv->stream); + if (cmd == AOCONTROL_SET_VOLUME) { const ao_control_vol_t *vol = arg; - pa_operation *o; struct pa_cvolume volume; - pa_cvolume_reset(&volume, ao_data.channels); + pa_cvolume_reset(&volume, ao->channels); if (volume.channels != 2) - pa_cvolume_set(&volume, volume.channels, (pa_volume_t)vol->left*PA_VOLUME_NORM/100); + pa_cvolume_set(&volume, volume.channels, + vol->left * PA_VOLUME_NORM / 100); else { - volume.values[0] = (pa_volume_t)vol->left*PA_VOLUME_NORM/100; - volume.values[1] = (pa_volume_t)vol->right*PA_VOLUME_NORM/100; + volume.values[0] = vol->left * PA_VOLUME_NORM / 100; + volume.values[1] = vol->right * PA_VOLUME_NORM / 100; } - - pa_threaded_mainloop_lock(mainloop); - o = pa_context_set_sink_input_volume(context, pa_stream_get_index(stream), &volume, NULL, NULL); + o = pa_context_set_sink_input_volume(priv->context, stream_index, + &volume, NULL, NULL); if (!o) { - pa_threaded_mainloop_unlock(mainloop); - GENERIC_ERR_MSG(context, "pa_context_set_sink_input_volume() failed"); + pa_threaded_mainloop_unlock(priv->mainloop); + GENERIC_ERR_MSG(priv->context, + "pa_context_set_sink_input_volume() failed"); return CONTROL_ERROR; } - /* We don't wait for completion here */ - pa_operation_unref(o); - pa_threaded_mainloop_unlock(mainloop); - return CONTROL_OK; - } - - default: - return CONTROL_UNKNOWN; + } else if (cmd == AOCONTROL_SET_MUTE) { + const bool *mute = arg; + o = pa_context_set_sink_input_mute(priv->context, stream_index, + *mute, NULL, NULL); + if (!o) { + pa_threaded_mainloop_unlock(priv->mainloop); + GENERIC_ERR_MSG(priv->context, + "pa_context_set_sink_input_mute() failed"); + return CONTROL_ERROR; + } + } else + abort(); + /* We don't wait for completion here */ + pa_operation_unref(o); + pa_threaded_mainloop_unlock(priv->mainloop); + return CONTROL_OK; + } + default: + return CONTROL_UNKNOWN; } } + +const struct ao_driver audio_out_pulse = { + .is_new = true, + .info = &(const struct ao_info) { + "PulseAudio audio output", + "pulse", + "Lennart Poettering", + "", + }, + .control = control, + .init = init, + .uninit = uninit, + .reset = reset, + .get_space = get_space, + .play = play, + .get_delay = get_delay, + .pause = pause, + .resume = resume, +}; diff -Nru mplayer2-2.0-426-gc32b3ed/libao2/ao_sdl.c mplayer2-2.0-554-gf63dbad/libao2/ao_sdl.c --- mplayer2-2.0-426-gc32b3ed/libao2/ao_sdl.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libao2/ao_sdl.c 2012-05-17 14:38:00.000000000 +0000 @@ -135,6 +135,8 @@ /* SDL Audio Specifications */ SDL_AudioSpec aspec, obtained; + global_ao->no_persistent_volume = true; + /* Allocate ring-buffer memory */ buffer = av_fifo_alloc(BUFFSIZE); diff -Nru mplayer2-2.0-426-gc32b3ed/libao2/ao_sgi.c mplayer2-2.0-554-gf63dbad/libao2/ao_sgi.c --- mplayer2-2.0-426-gc32b3ed/libao2/ao_sgi.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libao2/ao_sgi.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,308 +0,0 @@ -/* - * SGI/IRIX audio output driver - * - * copyright (c) 2001 oliver.schoenbrunner@jku.at - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include -#include -#include - -#include "audio_out.h" -#include "audio_out_internal.h" -#include "mp_msg.h" -#include "libaf/af_format.h" - -static const ao_info_t info = -{ - "sgi audio output", - "sgi", - "Oliver Schoenbrunner", - "" -}; - -LIBAO_EXTERN(sgi) - - -static ALconfig ao_config; -static ALport ao_port; -static int sample_rate; -static int queue_size; -static int bytes_per_frame; - -/** - * \param [in/out] format - * \param [out] width - * - * \return the closest matching SGI AL sample format - * - * \note width is set to required per-channel sample width - * format is updated to match the SGI AL sample format - */ -static int fmt2sgial(int *format, int *width) { - int smpfmt = AL_SAMPFMT_TWOSCOMP; - - /* SGI AL only supports float and signed integers in native - * endianness. If this is something else, we must rely on the audio - * filter to convert it to a compatible format. */ - - /* 24-bit audio is supported, but only with 32-bit alignment. - * mplayer's 24-bit format is packed, unfortunately. - * So we must upgrade 24-bit requests to 32 bits. Then we drop the - * lowest 8 bits during playback. */ - - switch(*format) { - case AF_FORMAT_U8: - case AF_FORMAT_S8: - *width = AL_SAMPLE_8; - *format = AF_FORMAT_S8; - break; - - case AF_FORMAT_U16_LE: - case AF_FORMAT_U16_BE: - case AF_FORMAT_S16_LE: - case AF_FORMAT_S16_BE: - *width = AL_SAMPLE_16; - *format = AF_FORMAT_S16_NE; - break; - - case AF_FORMAT_U24_LE: - case AF_FORMAT_U24_BE: - case AF_FORMAT_S24_LE: - case AF_FORMAT_S24_BE: - case AF_FORMAT_U32_LE: - case AF_FORMAT_U32_BE: - case AF_FORMAT_S32_LE: - case AF_FORMAT_S32_BE: - *width = AL_SAMPLE_24; - *format = AF_FORMAT_S32_NE; - break; - - case AF_FORMAT_FLOAT_LE: - case AF_FORMAT_FLOAT_BE: - *width = 4; - *format = AF_FORMAT_FLOAT_NE; - smpfmt = AL_SAMPFMT_FLOAT; - break; - - default: - *width = AL_SAMPLE_16; - *format = AF_FORMAT_S16_NE; - break; - - } - - return smpfmt; -} - -// to set/get/query special features/parameters -static int control(int cmd, void *arg){ - - mp_tmsg(MSGT_AO, MSGL_INFO, "[AO SGI] control.\n"); - - switch(cmd) { - case AOCONTROL_QUERY_FORMAT: - /* Do not reject any format: return the closest matching - * format if the request is not supported natively. */ - return CONTROL_TRUE; - } - - return CONTROL_UNKNOWN; -} - -// open & setup audio device -// return: 1=success 0=fail -static int init(int rate, int channels, int format, int flags) { - - int smpwidth, smpfmt; - int rv = AL_DEFAULT_OUTPUT; - - smpfmt = fmt2sgial(&format, &smpwidth); - - mp_tmsg(MSGT_AO, MSGL_INFO, "[AO SGI] init: Samplerate: %iHz Channels: %s Format %s\n", rate, (channels > 1) ? "Stereo" : "Mono", af_fmt2str_short(format)); - - { /* from /usr/share/src/dmedia/audio/setrate.c */ - - double frate, realrate; - ALpv x[2]; - - if(ao_subdevice) { - rv = alGetResourceByName(AL_SYSTEM, ao_subdevice, AL_OUTPUT_DEVICE_TYPE); - if (!rv) { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO SGI] play: invalid device.\n"); - return 0; - } - } - - frate = rate; - - x[0].param = AL_RATE; - x[0].value.ll = alDoubleToFixed(rate); - x[1].param = AL_MASTER_CLOCK; - x[1].value.i = AL_CRYSTAL_MCLK_TYPE; - - if (alSetParams(rv,x, 2)<0) { - mp_tmsg(MSGT_AO, MSGL_WARN, "[AO SGI] init: setparams failed: %s\nCould not set desired samplerate.\n", alGetErrorString(oserror())); - } - - if (x[0].sizeOut < 0) { - mp_tmsg(MSGT_AO, MSGL_WARN, "[AO SGI] init: AL_RATE was not accepted on the given resource.\n"); - } - - if (alGetParams(rv,x, 1)<0) { - mp_tmsg(MSGT_AO, MSGL_WARN, "[AO SGI] init: getparams failed: %s\n", alGetErrorString(oserror())); - } - - realrate = alFixedToDouble(x[0].value.ll); - if (frate != realrate) { - mp_tmsg(MSGT_AO, MSGL_INFO, "[AO SGI] init: samplerate is now %f (desired rate is %f)\n", realrate, frate); - } - sample_rate = (int)realrate; - } - - bytes_per_frame = channels * smpwidth; - - ao_data.samplerate = sample_rate; - ao_data.channels = channels; - ao_data.format = format; - ao_data.bps = sample_rate * bytes_per_frame; - ao_data.buffersize=131072; - ao_data.outburst = ao_data.buffersize/16; - - ao_config = alNewConfig(); - - if (!ao_config) { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO SGI] init: %s\n", alGetErrorString(oserror())); - return 0; - } - - if(alSetChannels(ao_config, channels) < 0 || - alSetWidth(ao_config, smpwidth) < 0 || - alSetSampFmt(ao_config, smpfmt) < 0 || - alSetQueueSize(ao_config, sample_rate) < 0 || - alSetDevice(ao_config, rv) < 0) { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO SGI] init: %s\n", alGetErrorString(oserror())); - return 0; - } - - ao_port = alOpenPort("mplayer", "w", ao_config); - - if (!ao_port) { - mp_tmsg(MSGT_AO, MSGL_ERR, "[AO SGI] init: Unable to open audio channel: %s\n", alGetErrorString(oserror())); - return 0; - } - - // printf("ao_sgi, init: port %d config %d\n", ao_port, ao_config); - queue_size = alGetQueueSize(ao_config); - return 1; - -} - -// close audio device -static void uninit(int immed) { - - /* TODO: samplerate should be set back to the value before mplayer was started! */ - - mp_tmsg(MSGT_AO, MSGL_INFO, "[AO SGI] uninit: ...\n"); - - if (ao_config) { - alFreeConfig(ao_config); - ao_config = NULL; - } - - if (ao_port) { - if (!immed) - while(alGetFilled(ao_port) > 0) sginap(1); - alClosePort(ao_port); - ao_port = NULL; - } - -} - -// stop playing and empty buffers (for seeking/pause) -static void reset(void) { - - mp_tmsg(MSGT_AO, MSGL_INFO, "[AO SGI] reset: ...\n"); - - alDiscardFrames(ao_port, queue_size); -} - -// stop playing, keep buffers (for pause) -static void audio_pause(void) { - - mp_tmsg(MSGT_AO, MSGL_INFO, "[AO SGI] audio_pause: ...\n"); - -} - -// resume playing, after audio_pause() -static void audio_resume(void) { - - mp_tmsg(MSGT_AO, MSGL_INFO, "[AO SGI] audio_resume: ...\n"); - -} - -// return: how many bytes can be played without blocking -static int get_space(void) { - - // printf("ao_sgi, get_space: (ao_outburst %d)\n", ao_data.outburst); - // printf("ao_sgi, get_space: alGetFillable [%d] \n", alGetFillable(ao_port)); - - return alGetFillable(ao_port) * bytes_per_frame; - -} - - -// plays 'len' bytes of 'data' -// it should round it down to outburst*n -// return: number of bytes played -static int play(void* data, int len, int flags) { - - /* Always process data in quadword-aligned chunks (64-bits). */ - const int plen = len / (sizeof(uint64_t) * bytes_per_frame); - const int framecount = plen * sizeof(uint64_t); - - // printf("ao_sgi, play: len %d flags %d (%d %d)\n", len, flags, ao_port, ao_config); - // printf("channels %d\n", ao_data.channels); - - if(ao_data.format == AF_FORMAT_S32_NE) { - /* The zen of this is explained in fmt2sgial() */ - int32_t *smpls = data; - const int32_t *smple = smpls + (framecount * ao_data.channels); - while(smpls < smple) - *smpls++ >>= 8; - } - - alWriteFrames(ao_port, data, framecount); - - return framecount * bytes_per_frame; - -} - -// return: delay in seconds between first and last sample in buffer -static float get_delay(void){ - - // printf("ao_sgi, get_delay: (ao_buffersize %d)\n", ao_buffersize); - - // return (float)queue_size/((float)sample_rate); - const int outstanding = alGetFilled(ao_port); - return (float)((outstanding < 0) ? queue_size : outstanding) / - ((float)sample_rate); -} diff -Nru mplayer2-2.0-426-gc32b3ed/libao2/ao_sun.c mplayer2-2.0-554-gf63dbad/libao2/ao_sun.c --- mplayer2-2.0-426-gc32b3ed/libao2/ao_sun.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libao2/ao_sun.c 2012-05-17 14:38:00.000000000 +0000 @@ -402,11 +402,6 @@ // to set/get/query special features/parameters static int control(int cmd,void *arg){ switch(cmd){ - case AOCONTROL_SET_DEVICE: - audio_dev=(char*)arg; - return CONTROL_OK; - case AOCONTROL_QUERY_FORMAT: - return CONTROL_TRUE; case AOCONTROL_GET_VOLUME: { int fd; diff -Nru mplayer2-2.0-426-gc32b3ed/libao2/audio_out.c mplayer2-2.0-554-gf63dbad/libao2/audio_out.c --- mplayer2-2.0-426-gc32b3ed/libao2/audio_out.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libao2/audio_out.c 2012-05-17 14:38:00.000000000 +0000 @@ -41,7 +41,6 @@ extern const struct ao_driver audio_out_jack; extern const struct ao_driver audio_out_openal; extern const struct ao_driver audio_out_null; -extern const struct ao_driver audio_out_alsa5; extern const struct ao_driver audio_out_alsa; extern const struct ao_driver audio_out_nas; extern const struct ao_driver audio_out_sdl; @@ -56,6 +55,7 @@ extern const struct ao_driver audio_out_mpegpes; extern const struct ao_driver audio_out_pcm; extern const struct ao_driver audio_out_pss; +extern const struct ao_driver audio_out_portaudio; static const struct ao_driver * const audio_out_drivers[] = { // native: @@ -74,43 +74,34 @@ #ifdef CONFIG_COREAUDIO &audio_out_coreaudio, #endif -#ifdef CONFIG_OSS_AUDIO - &audio_out_oss, +#ifdef CONFIG_PULSE + &audio_out_pulse, #endif #ifdef CONFIG_ALSA &audio_out_alsa, #endif -#ifdef CONFIG_ALSA5 - &audio_out_alsa5, +#ifdef CONFIG_OSS_AUDIO + &audio_out_oss, #endif -#ifdef CONFIG_SGI_AUDIO - &audio_out_sgi, +#ifdef CONFIG_PORTAUDIO + &audio_out_portaudio, #endif #ifdef CONFIG_SUN_AUDIO &audio_out_sun, #endif // wrappers: -#ifdef CONFIG_ARTS - &audio_out_arts, -#endif -#ifdef CONFIG_ESD - &audio_out_esd, -#endif -#ifdef CONFIG_PULSE - &audio_out_pulse, -#endif #ifdef CONFIG_JACK &audio_out_jack, #endif #ifdef CONFIG_NAS &audio_out_nas, #endif -#ifdef CONFIG_SDL - &audio_out_sdl, -#endif #ifdef CONFIG_OPENAL &audio_out_openal, #endif +#ifdef CONFIG_SDL + &audio_out_sdl, +#endif &audio_out_mpegpes, #ifdef CONFIG_IVTV &audio_out_ivtv, @@ -140,10 +131,11 @@ mp_msg(MSGT_GLOBAL, MSGL_INFO,"\n"); } -struct ao *ao_create(void) +struct ao *ao_create(struct MPOpts *opts, struct input_ctx *input) { struct ao *r = talloc(NULL, struct ao); - *r = (struct ao){.outburst = OUTBURST, .buffersize = -1}; + *r = (struct ao){.outburst = OUTBURST, .buffersize = -1, + .opts = opts, .input_ctx = input }; return r; } @@ -235,7 +227,7 @@ return ao->driver->play(ao, data, len, flags); } -int ao_control(struct ao *ao, int cmd, void *arg) +int ao_control(struct ao *ao, enum aocontrol cmd, void *arg) { if (ao->driver->control) return ao->driver->control(ao, cmd, arg); @@ -302,7 +294,7 @@ return ao->driver->old_functions->play(data, len, flags); } -int old_ao_control(struct ao *ao, int cmd, void *arg) +int old_ao_control(struct ao *ao, enum aocontrol cmd, void *arg) { return ao->driver->old_functions->control(cmd, arg); } diff -Nru mplayer2-2.0-426-gc32b3ed/libao2/audio_out.h mplayer2-2.0-554-gf63dbad/libao2/audio_out.h --- mplayer2-2.0-426-gc32b3ed/libao2/audio_out.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libao2/audio_out.h 2012-05-17 14:38:00.000000000 +0000 @@ -23,6 +23,30 @@ #include "bstr.h" +#define CONTROL_OK 1 +#define CONTROL_TRUE 1 +#define CONTROL_FALSE 0 +#define CONTROL_UNKNOWN -1 +#define CONTROL_ERROR -2 +#define CONTROL_NA -3 + +enum aocontrol { + // _VOLUME commands take struct ao_control_vol pointer for input/output. + // If there's only one volume, SET should use average of left/right. + AOCONTROL_GET_VOLUME, + AOCONTROL_SET_VOLUME, + // _MUTE commands take a pointer to bool + AOCONTROL_GET_MUTE, + AOCONTROL_SET_MUTE, +}; + +#define AOPLAY_FINAL_CHUNK 1 + +typedef struct ao_control_vol { + float left; + float right; +} ao_control_vol_t; + typedef struct ao_info { /* driver name ("Matrox Millennium G200/G400" */ const char *name; @@ -53,7 +77,7 @@ bool is_new; const struct ao_info *info; const struct ao_old_functions *old_functions; - int (*control)(struct ao *ao, int cmd, void *arg); + int (*control)(struct ao *ao, enum aocontrol cmd, void *arg); int (*init)(struct ao *ao, char *params); void (*uninit)(struct ao *ao, bool cut_audio); void (*reset)(struct ao*ao); @@ -78,48 +102,29 @@ int buffer_playable_size; bool initialized; bool untimed; + bool no_persistent_volume; const struct ao_driver *driver; void *priv; + struct MPOpts *opts; + struct input_ctx *input_ctx; }; extern char *ao_subdevice; void list_audio_out(void); -#define CONTROL_OK 1 -#define CONTROL_TRUE 1 -#define CONTROL_FALSE 0 -#define CONTROL_UNKNOWN -1 -#define CONTROL_ERROR -2 -#define CONTROL_NA -3 - -#define AOCONTROL_SET_DEVICE 1 -#define AOCONTROL_GET_DEVICE 2 -#define AOCONTROL_QUERY_FORMAT 3 /* test for availabilty of a format */ -#define AOCONTROL_GET_VOLUME 4 -#define AOCONTROL_SET_VOLUME 5 -#define AOCONTROL_SET_PLUGIN_DRIVER 6 -#define AOCONTROL_SET_PLUGIN_LIST 7 - -#define AOPLAY_FINAL_CHUNK 1 - -typedef struct ao_control_vol { - float left; - float right; -} ao_control_vol_t; - -struct ao *ao_create(void); +struct ao *ao_create(struct MPOpts *opts, struct input_ctx *input); void ao_init(struct ao *ao, char **ao_list); void ao_uninit(struct ao *ao, bool cut_audio); int ao_play(struct ao *ao, void *data, int len, int flags); -int ao_control(struct ao *ao, int cmd, void *arg); +int ao_control(struct ao *ao, enum aocontrol cmd, void *arg); double ao_get_delay(struct ao *ao); int ao_get_space(struct ao *ao); void ao_reset(struct ao *ao); void ao_pause(struct ao *ao); void ao_resume(struct ao *ao); -int old_ao_control(struct ao *ao, int cmd, void *arg); +int old_ao_control(struct ao *ao, enum aocontrol cmd, void *arg); int old_ao_init(struct ao *ao, char *params); void old_ao_uninit(struct ao *ao, bool cut_audio); void old_ao_reset(struct ao*ao); diff -Nru mplayer2-2.0-426-gc32b3ed/libao2/audio_out_internal.h mplayer2-2.0-554-gf63dbad/libao2/audio_out_internal.h --- mplayer2-2.0-426-gc32b3ed/libao2/audio_out_internal.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libao2/audio_out_internal.h 2012-05-17 14:38:00.000000000 +0000 @@ -19,6 +19,8 @@ #ifndef MPLAYER_AUDIO_OUT_INTERNAL_H #define MPLAYER_AUDIO_OUT_INTERNAL_H +#include "options.h" + // prototypes: //static ao_info_t info; static int control(int cmd, void *arg); @@ -33,6 +35,8 @@ extern struct ao *global_ao; #define ao_data (*global_ao) +#define mixer_channel (global_ao->opts->mixer_channel) +#define mixer_device (global_ao->opts->mixer_device) #define LIBAO_EXTERN(x) const struct ao_driver audio_out_##x = { \ .info = &info, \ diff -Nru mplayer2-2.0-426-gc32b3ed/libmpcodecs/ad_dk3adpcm.c mplayer2-2.0-554-gf63dbad/libmpcodecs/ad_dk3adpcm.c --- mplayer2-2.0-426-gc32b3ed/libmpcodecs/ad_dk3adpcm.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpcodecs/ad_dk3adpcm.c 2012-05-17 14:38:00.000000000 +0000 @@ -32,8 +32,9 @@ #include #include +#include + #include "config.h" -#include "ffmpeg_files/intreadwrite.h" #include "ad_internal.h" static const ad_info_t info = diff -Nru mplayer2-2.0-426-gc32b3ed/libmpcodecs/ad_ffmpeg.c mplayer2-2.0-554-gf63dbad/libmpcodecs/ad_ffmpeg.c --- mplayer2-2.0-426-gc32b3ed/libmpcodecs/ad_ffmpeg.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpcodecs/ad_ffmpeg.c 2012-05-17 14:38:00.000000000 +0000 @@ -20,8 +20,10 @@ #include #include #include +#include #include +#include #include "talloc.h" @@ -47,12 +49,15 @@ struct priv { AVCodecContext *avctx; - bool old_packet; + AVFrame *avframe; + char *output; + int output_left; + int unitsize; + int previous_data_left; // input demuxer packet data }; static int preinit(sh_audio_t *sh) { - sh->audio_out_minsize = AVCODEC_MAX_AUDIO_FRAME_SIZE; return 1; } @@ -66,12 +71,13 @@ { int sample_format = sh_audio->sample_format; switch (lavc_context->sample_fmt) { - case SAMPLE_FMT_U8: sample_format = AF_FORMAT_U8; break; - case SAMPLE_FMT_S16: sample_format = AF_FORMAT_S16_NE; break; - case SAMPLE_FMT_S32: sample_format = AF_FORMAT_S32_NE; break; - case SAMPLE_FMT_FLT: sample_format = AF_FORMAT_FLOAT_NE; break; + case AV_SAMPLE_FMT_U8: sample_format = AF_FORMAT_U8; break; + case AV_SAMPLE_FMT_S16: sample_format = AF_FORMAT_S16_NE; break; + case AV_SAMPLE_FMT_S32: sample_format = AF_FORMAT_S32_NE; break; + case AV_SAMPLE_FMT_FLT: sample_format = AF_FORMAT_FLOAT_NE; break; default: mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Unsupported sample format\n"); + sample_format = AF_FORMAT_UNKNOWN; } bool broken_srate = false; @@ -118,10 +124,13 @@ struct priv *ctx = talloc_zero(NULL, struct priv); sh_audio->context = ctx; - lavc_context = avcodec_alloc_context(); + lavc_context = avcodec_alloc_context3(lavc_codec); ctx->avctx = lavc_context; + ctx->avframe = avcodec_alloc_frame(); - lavc_context->drc_scale = opts->drc_level; + // Always try to set - option only exists for AC3 at the moment + av_opt_set_double(lavc_context, "drc_scale", opts->drc_level, + AV_OPT_SEARCH_CHILDREN); lavc_context->sample_rate = sh_audio->samplerate; lavc_context->bit_rate = sh_audio->i_bps * 8; if (sh_audio->wf) { @@ -155,7 +164,7 @@ } /* open it */ - if (avcodec_open(lavc_context, lavc_codec) < 0) { + if (avcodec_open2(lavc_context, lavc_codec, NULL) < 0) { mp_tmsg(MSGT_DECAUDIO, MSGL_ERR, "Could not open codec.\n"); uninit(sh_audio); return 0; @@ -194,10 +203,10 @@ sh_audio->i_bps = sh_audio->wf->nAvgBytesPerSec; switch (lavc_context->sample_fmt) { - case SAMPLE_FMT_U8: - case SAMPLE_FMT_S16: - case SAMPLE_FMT_S32: - case SAMPLE_FMT_FLT: + case AV_SAMPLE_FMT_U8: + case AV_SAMPLE_FMT_S16: + case AV_SAMPLE_FMT_S32: + case AV_SAMPLE_FMT_FLT: break; default: uninit(sh_audio); @@ -214,11 +223,12 @@ AVCodecContext *lavc_context = ctx->avctx; if (lavc_context) { - if (lavc_context->codec && avcodec_close(lavc_context) < 0) + if (avcodec_close(lavc_context) < 0) mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "Could not close codec.\n"); av_freep(&lavc_context->extradata); av_freep(&lavc_context); } + av_free(ctx->avframe); talloc_free(ctx); sh->context = NULL; } @@ -230,75 +240,124 @@ case ADCTRL_RESYNC_STREAM: avcodec_flush_buffers(ctx->avctx); ds_clear_parser(sh->ds); - ctx->old_packet = false; + ctx->previous_data_left = 0; + ctx->output_left = 0; return CONTROL_TRUE; } return CONTROL_UNKNOWN; } +static int decode_new_packet(struct sh_audio *sh) +{ + struct priv *priv = sh->context; + AVCodecContext *avctx = priv->avctx; + double pts = MP_NOPTS_VALUE; + int insize; + bool packet_already_used = priv->previous_data_left; + struct demux_packet *mpkt = ds_get_packet2(sh->ds, + priv->previous_data_left); + unsigned char *start; + if (!mpkt) { + assert(!priv->previous_data_left); + start = NULL; + insize = 0; + ds_parse(sh->ds, &start, &insize, pts, 0); + if (insize <= 0) + return -1; // error or EOF + } else { + assert(mpkt->len >= priv->previous_data_left); + if (!priv->previous_data_left) { + priv->previous_data_left = mpkt->len; + pts = mpkt->pts; + } + insize = priv->previous_data_left; + start = mpkt->buffer + mpkt->len - priv->previous_data_left; + int consumed = ds_parse(sh->ds, &start, &insize, pts, 0); + priv->previous_data_left -= consumed; + } + + AVPacket pkt; + av_init_packet(&pkt); + pkt.data = start; + pkt.size = insize; + if (mpkt && mpkt->avpacket) { + pkt.side_data = mpkt->avpacket->side_data; + pkt.side_data_elems = mpkt->avpacket->side_data_elems; + } + if (pts != MP_NOPTS_VALUE && !packet_already_used) { + sh->pts = pts; + sh->pts_bytes = 0; + } + int got_frame = 0; + int ret = avcodec_decode_audio4(avctx, priv->avframe, &got_frame, &pkt); + // LATM may need many packets to find mux info + if (ret == AVERROR(EAGAIN)) + return 0; + if (ret < 0) { + mp_msg(MSGT_DECAUDIO, MSGL_V, "lavc_audio: error\n"); + return -1; + } + if (!sh->parser) + priv->previous_data_left += insize - ret; + if (!got_frame) + return 0; + /* An error is reported later from output format checking, but make + * sure we don't crash by overreading first plane. */ + if (av_sample_fmt_is_planar(avctx->sample_fmt) && avctx->channels > 1) + return 0; + uint64_t unitsize = (uint64_t)av_get_bytes_per_sample(avctx->sample_fmt) * + avctx->channels; + if (unitsize > 100000) + abort(); + priv->unitsize = unitsize; + uint64_t output_left = unitsize * priv->avframe->nb_samples; + if (output_left > 500000000) + abort(); + priv->output_left = output_left; + priv->output = priv->avframe->data[0]; + mp_dbg(MSGT_DECAUDIO, MSGL_DBG2, "Decoded %d -> %d \n", insize, + priv->output_left); + return 0; +} + + static int decode_audio(sh_audio_t *sh_audio, unsigned char *buf, int minlen, int maxlen) { - struct priv *ctx = sh_audio->context; - AVCodecContext *avctx = ctx->avctx; + struct priv *priv = sh_audio->context; + AVCodecContext *avctx = priv->avctx; - unsigned char *start = NULL; - int y, len = -1; + int len = -1; while (len < minlen) { - AVPacket pkt; - int len2 = maxlen; - double pts; - int x = ds_get_packet_pts(sh_audio->ds, &start, &pts); - if (x <= 0) { - start = NULL; - x = 0; - ds_parse(sh_audio->ds, &start, &x, MP_NOPTS_VALUE, 0); - if (x <= 0) - break; // error - } else { - int in_size = x; - int consumed = ds_parse(sh_audio->ds, &start, &x, pts, 0); - sh_audio->ds->buffer_pos -= in_size - consumed; - } - av_init_packet(&pkt); - pkt.data = start; - pkt.size = x; - if (pts != MP_NOPTS_VALUE && !ctx->old_packet) { - sh_audio->pts = pts; - sh_audio->pts_bytes = 0; - } - y = avcodec_decode_audio3(avctx, (int16_t *)buf, &len2, &pkt); - // LATM may need many packets to find mux info - if (y == AVERROR(EAGAIN)) + if (!priv->output_left) { + if (decode_new_packet(sh_audio) < 0) + break; continue; - if (y < 0) { - mp_msg(MSGT_DECAUDIO, MSGL_V, "lavc_audio: error\n"); - break; - } - if (!sh_audio->parser && y < x) { - sh_audio->ds->buffer_pos += y - x; // put back data (HACK!) - ctx->old_packet = true; } - if (len2 > 0) { - if (avctx->channels >= 5) { - int samplesize = av_get_bytes_per_sample(avctx->sample_fmt); - reorder_channel_nch(buf, AF_CHANNEL_LAYOUT_LAVC_DEFAULT, - AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT, - avctx->channels, - len2 / samplesize, samplesize); - } - if (len < 0) - len = len2; - else - len += len2; - buf += len2; - maxlen -= len2; - sh_audio->pts_bytes += len2; - } - mp_dbg(MSGT_DECAUDIO, MSGL_DBG2, "Decoded %d -> %d \n", y, len2); - if (setup_format(sh_audio, avctx)) - break; + return len; + int size = (minlen - len + priv->unitsize - 1); + size -= size % priv->unitsize; + size = FFMIN(size, priv->output_left); + if (size > maxlen) + abort(); + memcpy(buf, priv->output, size); + priv->output += size; + priv->output_left -= size; + if (avctx->channels >= 5) { + int samplesize = av_get_bytes_per_sample(avctx->sample_fmt); + reorder_channel_nch(buf, AF_CHANNEL_LAYOUT_LAVC_DEFAULT, + AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT, + avctx->channels, + size / samplesize, samplesize); + } + if (len < 0) + len = size; + else + len += size; + buf += size; + maxlen -= size; + sh_audio->pts_bytes += size; } return len; } diff -Nru mplayer2-2.0-426-gc32b3ed/libmpcodecs/ad_hwac3.c mplayer2-2.0-554-gf63dbad/libmpcodecs/ad_hwac3.c --- mplayer2-2.0-426-gc32b3ed/libmpcodecs/ad_hwac3.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpcodecs/ad_hwac3.c 2012-05-17 14:38:00.000000000 +0000 @@ -26,11 +26,12 @@ #include #include +#include +#include + #include "config.h" #include "mp_msg.h" #include "mpbswap.h" -#include "libavutil/common.h" -#include "ffmpeg_files/intreadwrite.h" #include "ad_internal.h" diff -Nru mplayer2-2.0-426-gc32b3ed/libmpcodecs/ad_imaadpcm.c mplayer2-2.0-554-gf63dbad/libmpcodecs/ad_imaadpcm.c --- mplayer2-2.0-426-gc32b3ed/libmpcodecs/ad_imaadpcm.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpcodecs/ad_imaadpcm.c 2012-05-17 14:38:00.000000000 +0000 @@ -38,8 +38,9 @@ #include #include +#include + #include "config.h" -#include "ffmpeg_files/intreadwrite.h" #include "mpbswap.h" #include "ad_internal.h" diff -Nru mplayer2-2.0-426-gc32b3ed/libmpcodecs/ad_mpg123.c mplayer2-2.0-554-gf63dbad/libmpcodecs/ad_mpg123.c --- mplayer2-2.0-426-gc32b3ed/libmpcodecs/ad_mpg123.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpcodecs/ad_mpg123.c 2012-05-17 14:38:00.000000000 +0000 @@ -1,7 +1,7 @@ /* * MPEG 1.0/2.0/2.5 audio layer I, II, III decoding with libmpg123 * - * Copyright (C) 2010 Thomas Orgis + * Copyright (C) 2010-2012 Thomas Orgis * * MPlayer is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,36 +38,20 @@ #include "libvo/fastmemcpy.h" -/* We avoid any usage of mpg123 API that is sensitive to the large file - * support setting. This ensures compatibility with a wide range of libmpg123 - * installs. This code is intended to work with version 1.0.0 of libmpg123. - * - * Though the chosen API subset is not affected by the choice of large file - * support, the mpg123 header (old versions of which) might include a check - * for matching _FILE_OFFSET_BITS. Since MPlayer does always define this one - * for large file support, we are safe for any default mpg123 install that - * either doesn't have such checks or defaults to the large value of - * _FILE_OFFSET_BITS . - * So, in short: There's no worry unless you have a non-default libmpg123 - * with intentionally disabled large file support. */ -/* You might need to #undef _FILE_OFFSET_BITS here on a 64 bit system - with released mpg123 1.12 when using callback API. SVN snapshots - should work fine. */ +/* Reducing the ifdeffery to two main variants: + * 1. most compatible to any libmpg123 version + * 2. fastest variant with recent libmpg123 (>=1.14) + * Running variant 2 on older libmpg123 versions may work in + * principle, but is not supported. + * So, please leave the check for MPG123_API_VERSION there, m-kay? + */ #include -/* Selection of mpg123 usage patterns: - * AD_MPG123_CALLBACK: Use callback API instead of feeding of memory buffers. - * That needs mpg123>=1.12, on x86-64 SVN snapshot because of - * _FILE_OFFSET_BITS being defined (see above). - * AD_MPG123_PACKET: Use packet-based input (including pts handling). - * AD_MPG123_SEEKBUFFER: Use internal mpg123 buffer to enhance stream parsing. - * Makes sense with callback API only. - * Any of those might affect I/O performance, might be significant compared - * to the excessively optimized decoding. - */ -/* #define AD_MPG123_CALLBACK */ -#define AD_MPG123_PACKET -/* #define AD_MPG123_SEEKBUFFER */ +/* Enable faster mode of operation with newer libmpg123, avoiding + * unnecessary memcpy() calls. */ +#if (defined MPG123_API_VERSION) && (MPG123_API_VERSION >= 33) +#define AD_MPG123_FRAMEWISE +#endif /* Switch for updating bitrate info of VBR files. Not essential. */ #define AD_MPG123_MEAN_BITRATE @@ -87,77 +71,8 @@ #endif /* If the stream is actually VBR. */ char vbr; -#if (defined AD_MPG123_CALLBACK) && (defined AD_MPG123_PACKET) - unsigned char *packet; - int packleft; -#endif }; -static void context_reset(struct ad_mpg123_context *con) -{ -#ifdef AD_MPG123_MEAN_BITRATE - con->mean_rate = 0.; - con->mean_count = 0; - con->delay = 1; -#endif -#if (defined AD_MPG123_CALLBACK) && (defined AD_MPG123_PACKET) - con->packet = NULL; - con->packleft = 0; -#endif -} - - -#ifdef AD_MPG123_CALLBACK -/* Mpg123 calls that for retrieving data. - * This wrapper is at least needed for the call frame (ssize_t vs. int). */ -static ssize_t read_callback(void *ash, void *buf, size_t count) -{ - sh_audio_t *sh = ash; -#ifdef AD_MPG123_PACKET - struct ad_mpg123_context *con = sh->context; - unsigned char *target = buf; - int need = count; - ssize_t got = 0; - while (need > 0) { - if (con->packleft > 0) { - int get = need > con->packleft ? con->packleft : need; - /* Any difference to normal memcpy? */ - fast_memcpy(target, con->packet, get); - /* OK, that does look redundant. */ - con->packet += get; - con->packleft -= get; - target += get; - need -= get; - got += get; - } else { - double pts; - /* Feed more input data. */ - con->packleft = ds_get_packet_pts(sh->ds, &con->packet, &pts); - if (con->packleft <= 0) - break; /* Apparently that's it. EOF. */ - - /* Next bytes from that presentation time. */ - if (pts != MP_NOPTS_VALUE) { - sh->pts = pts; - sh->pts_bytes = 0; - } - } - } - return got; -#else - /* It returns int... with the meaning of byte count. */ - return (ssize_t) demux_read_data(sh->ds, buf, count); -#endif -} - -/* Arbitrary input seeking is not supported with this MPlayer API(?). - That also means that we won't read any ID3v1 tags. */ -static off_t seek_callback(void *sh, off_t pos, int whence) -{ - return -1; -} -#endif - /* This initializes libmpg123 and prepares the handle, including funky * parameters. */ static int preinit(sh_audio_t *sh) @@ -173,8 +88,6 @@ sh->context = malloc(sizeof(struct ad_mpg123_context)); con = sh->context; - context_reset(con); - /* Auto-choice of optimized decoder (first argument NULL). */ con->handle = mpg123_new(NULL, &err); if (!con->handle) @@ -188,17 +101,6 @@ if (mpg123_param(con->handle, MPG123_ADD_FLAGS, flag, 0.0) != MPG123_OK) goto bad_end; #endif -#ifdef AD_MPG123_CALLBACK - /* The I/O is handled via callbacks to MPlayer stream functions, - * actually only the reading, as general seeking does not seem to be available */ - if (mpg123_replace_reader_handle(con->handle, read_callback, - seek_callback, NULL) != MPG123_OK) { - mp_msg(MSGT_DECAUDIO, MSGL_ERR, "mpg123 error: %s\n", - mpg123_strerror(con->handle)); - mpg123_exit(); - return 0; - } -#endif /* Basic settings. * Don't spill messages, enable better resync with non-seekable streams. @@ -206,10 +108,6 @@ * old libmpg123. Generally, it is not fatal if the flags are not * honored */ mpg123_param(con->handle, MPG123_ADD_FLAGS, MPG123_QUIET, 0.0); - /* Old headers don't know MPG123_SEEKBUFFER yet, so use the plain 0x100. */ -#ifdef AD_MPG123_SEEKBUFFER - mpg123_param(con->handle, MPG123_ADD_FLAGS, 0x100, 0.0); -#endif /* Do not bail out on malformed streams at all. * MPlayer does not handle a decoder throwing the towel on crappy input. */ mpg123_param(con->handle, MPG123_RESYNC_LIMIT, -1, 0.0); @@ -220,9 +118,25 @@ * Don't forget to eventually enable ReplayGain/RVA support, too. * Let's try to run with the default for now. */ + /* That would produce floating point output. + * You can get 32 and 24 bit ints, even 8 bit via format matrix. */ + /* mpg123_param(con->handle, MPG123_ADD_FLAGS, MPG123_FORCE_FLOAT, 0.); */ + /* Example for RVA choice (available since libmpg123 1.0.0): mpg123_param(con->handle, MPG123_RVA, MPG123_RVA_MIX, 0.0) */ +#ifdef AD_MPG123_FRAMEWISE + /* Prevent funky automatic resampling. + * This way, we can be sure that one frame will never produce + * more than 1152 stereo samples. */ + mpg123_param(con->handle, MPG123_REMOVE_FLAGS, MPG123_AUTO_RESAMPLE, 0.); +#else + /* Older mpg123 is vulnerable to concatenated streams when gapless cutting + * is enabled (will only play the jingle of a badly constructed radio + * stream). The versions using framewise decoding are fine with that. */ + mpg123_param(con->handle, MPG123_REMOVE_FLAGS, MPG123_GAPLESS, 0.); +#endif + return 1; bad_end: @@ -294,7 +208,6 @@ smodes[i->mode]); } -#ifndef AD_MPG123_CALLBACK /* This tries to extract a requested amount of decoded data. * Even when you request 0 bytes, it will feed enough input so that * the decoder _could_ have delivered something. @@ -321,19 +234,13 @@ struct ad_mpg123_context *con = sh->context; /* There will be one MPG123_NEW_FORMAT message on first open. - * This will be implicitly handled in reopen_stream(). */ + * This will be handled in init(). */ do { size_t got_now = 0; - ret = mpg123_decode(con->handle, NULL, 0, buf + got, count - got, - &got_now); - got += got_now; -#ifdef AD_MPG123_PACKET - sh->pts_bytes += got_now; -#endif + /* Feed the decoder. This will only fire from the second round on. */ if (ret == MPG123_NEED_MORE) { int incount; -#ifdef AD_MPG123_PACKET double pts; unsigned char *inbuf; /* Feed more input data. */ @@ -346,26 +253,45 @@ sh->pts = pts; sh->pts_bytes = 0; } -#else - const int inbufsize = 4096; - unsigned char inbuf[inbufsize]; - /* Feed more input data. */ - incount = demux_read_data(((sh_audio_t *) sh)->ds, - inbuf, inbufsize); - if (incount == 0) - break; /* Apparently that's it. EOF. */ -#endif +#ifdef AD_MPG123_FRAMEWISE + /* Have to use mpg123_feed() to avoid decoding here. */ + ret = mpg123_feed(con->handle, inbuf, incount); +#else /* Do not use mpg123_feed(), added in later libmpg123 versions. */ ret = mpg123_decode(con->handle, inbuf, incount, NULL, 0, NULL); - /* Return value is checked in the loop condition. - * It could be MPG12_OK now, it could need more. */ +#endif + if (ret == MPG123_ERR) + break; } - /* Older mpg123 versions might indicate MPG123_DONE, so be prepared. */ + /* Theoretically, mpg123 could return MPG123_DONE, so be prepared. + * Should not happen in our usage, but it is a valid return code. */ else if (ret == MPG123_ERR || ret == MPG123_DONE) break; + /* Try to decode a bit. This is the return value that counts + * for the loop condition. */ +#ifdef AD_MPG123_FRAMEWISE + if (!buf) { /* fake call just for feeding to get format */ + ret = mpg123_getformat(con->handle, NULL, NULL, NULL); + } else { /* This is the decoding. One frame at a time. */ + ret = mpg123_replace_buffer(con->handle, buf, count); + if (ret == MPG123_OK) + ret = mpg123_decode_frame(con->handle, NULL, NULL, &got_now); + } +#else + ret = mpg123_decode(con->handle, NULL, 0, buf + got, count - got, + &got_now); +#endif + + got += got_now; + sh->pts_bytes += got_now; + +#ifdef AD_MPG123_FRAMEWISE + } while (ret == MPG123_NEED_MORE || (got == 0 && count != 0)); +#else } while (ret == MPG123_NEED_MORE || got < count); +#endif if (ret == MPG123_ERR) { mp_msg(MSGT_DECAUDIO, MSGL_ERR, "mpg123 decoding failed: %s\n", @@ -376,29 +302,21 @@ return got; } -#endif /* Close, reopen stream. Feed data until we know the format of the stream. * 1 on success, 0 on error */ static int reopen_stream(sh_audio_t *sh) { - long rate; - int chan, enc; struct ad_mpg123_context *con = (struct ad_mpg123_context*) sh->context; mpg123_close(con->handle); - context_reset(con); + /* No resetting of the context: + * We do not want to loose the mean bitrate data. */ -#ifdef AD_MPG123_CALLBACK - if (MPG123_OK == mpg123_open_handle(con->handle, sh) && -#else - if (/* Open and make sure we have fed enough data to get stream properties. */ - MPG123_OK == mpg123_open_feed(con->handle) && + /* Open and make sure we have fed enough data to get stream properties. */ + if (MPG123_OK == mpg123_open_feed(con->handle) && /* Feed data until mpg123 is ready (has found stream beginning). */ - !decode_a_bit(sh, NULL, 0) && -#endif - /* Not handing NULL pointers for compatibility with old libmpg123. */ - MPG123_OK == mpg123_getformat(con->handle, &rate, &chan, &enc)) { + !decode_a_bit(sh, NULL, 0)) { return 1; } else { mp_msg(MSGT_DECAUDIO, MSGL_ERR, @@ -446,7 +364,11 @@ * For VBR, the first frame will be a bad estimate. */ sh->i_bps = (finfo.bitrate ? finfo.bitrate : compute_bitrate(&finfo)) * 1000 / 8; - context_reset(con); +#ifdef AD_MPG123_MEAN_BITRATE + con->delay = 1; + con->mean_rate = 0.; + con->mean_count = 0; +#endif con->vbr = (finfo.vbr != MPG123_CBR); sh->channels = channels; sh->samplerate = rate; @@ -480,6 +402,12 @@ mpg123_close(con->handle); return 0; } +#ifdef AD_MPG123_FRAMEWISE + /* Going to decode directly to MPlayer's memory. It is important + * to have MPG123_AUTO_RESAMPLE disabled for the buffer size + * being an all-time limit. */ + sh->audio_out_minsize = 1152 * 2 * sh->samplesize; +#endif return 1; } else { @@ -529,29 +457,13 @@ { int bytes; -#ifdef AD_MPG123_CALLBACK - struct ad_mpg123_context *con = sh->context; - size_t got_bytes = 0; - if (MPG123_ERR == mpg123_read(con->handle, buf, minlen, &got_bytes)) { - mp_msg(MSGT_DECAUDIO, MSGL_ERR, "Decoding error in mpg123: %s\n", - mpg123_strerror(con->handle)); - return -1; - } -#ifdef AD_MPG123_PACKET - sh->pts_bytes += got_bytes; -#endif - bytes = got_bytes; -#else - bytes = decode_a_bit(sh, buf, minlen); -#endif - + bytes = decode_a_bit(sh, buf, maxlen); if (bytes == 0) return -1; /* EOF */ #ifdef AD_MPG123_MEAN_BITRATE update_info(sh); #endif - return bytes; } @@ -569,6 +481,8 @@ #endif return CONTROL_TRUE; } else { + /* MPlayer ignores this case! It just keeps on decoding. + * So we have to make sure resync never fails ... */ mp_msg(MSGT_DECAUDIO, MSGL_ERR, "mpg123 cannot reopen stream for resync.\n"); return CONTROL_FALSE; diff -Nru mplayer2-2.0-426-gc32b3ed/libmpcodecs/ad_msadpcm.c mplayer2-2.0-554-gf63dbad/libmpcodecs/ad_msadpcm.c --- mplayer2-2.0-426-gc32b3ed/libmpcodecs/ad_msadpcm.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpcodecs/ad_msadpcm.c 2012-05-17 14:38:00.000000000 +0000 @@ -28,9 +28,10 @@ #include #include +#include +#include + #include "config.h" -#include "libavutil/common.h" -#include "ffmpeg_files/intreadwrite.h" #include "mpbswap.h" #include "ad_internal.h" diff -Nru mplayer2-2.0-426-gc32b3ed/libmpcodecs/ad_qtaudio.c mplayer2-2.0-554-gf63dbad/libmpcodecs/ad_qtaudio.c --- mplayer2-2.0-426-gc32b3ed/libmpcodecs/ad_qtaudio.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpcodecs/ad_qtaudio.c 2012-05-17 14:38:00.000000000 +0000 @@ -300,7 +300,6 @@ } static int decode_audio(sh_audio_t *sh,unsigned char *buf,int minlen,int maxlen){ - int error; unsigned long FramesToGet=0; //how many frames the demuxer has to get unsigned long InputBufferSize=0; //size of the input buffer unsigned long ConvertedFrames=0; @@ -331,7 +330,7 @@ // printf("\nSoundConverterConvertBuffer(myConv=%p,inbuf=%p,frames=%d,outbuf=%p,&convframes=%p,&convbytes=%p)\n", // myConverter,sh->a_in_buffer,FramesToGet,buf,&ConvertedFrames,&ConvertedBytes); - error = SoundConverterConvertBuffer(myConverter,sh->a_in_buffer, + SoundConverterConvertBuffer(myConverter,sh->a_in_buffer, FramesToGet,buf,&ConvertedFrames,&ConvertedBytes); // printf("SoundConverterConvertBuffer:%i\n",error); // printf("ConvertedFrames = %li\n",ConvertedFrames); diff -Nru mplayer2-2.0-426-gc32b3ed/libmpcodecs/ad_twin.c mplayer2-2.0-554-gf63dbad/libmpcodecs/ad_twin.c --- mplayer2-2.0-426-gc32b3ed/libmpcodecs/ad_twin.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpcodecs/ad_twin.c 2012-05-17 14:38:00.000000000 +0000 @@ -54,8 +54,8 @@ static int (*TvqCheckVersion)(char *versionID); static void (*TvqGetConfInfo)(tvqConfInfo *cf); -static int (*TvqGetFrameSize)(); -static int (*TvqGetNumFixedBitsPerFrame)(); +static int (*TvqGetFrameSize)(void); +static int (*TvqGetNumFixedBitsPerFrame)(void); #define BYTE_BIT 8 #define BBUFSIZ 1024 /* Bit buffer size (bytes) */ diff -Nru mplayer2-2.0-426-gc32b3ed/libmpcodecs/img_format.c mplayer2-2.0-554-gf63dbad/libmpcodecs/img_format.c --- mplayer2-2.0-426-gc32b3ed/libmpcodecs/img_format.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpcodecs/img_format.c 2012-05-17 14:38:00.000000000 +0000 @@ -102,9 +102,6 @@ case IMGFMT_YUVP: return "Packed YUVP"; case IMGFMT_UYVP: return "Packed UYVP"; case IMGFMT_MPEGPES: return "Mpeg PES"; - case IMGFMT_ZRMJPEGNI: return "Zoran MJPEG non-interlaced"; - case IMGFMT_ZRMJPEGIT: return "Zoran MJPEG top field first"; - case IMGFMT_ZRMJPEGIB: return "Zoran MJPEG bottom field first"; case IMGFMT_XVMC_MOCO_MPEG2: return "MPEG1/2 Motion Compensation"; case IMGFMT_XVMC_IDCT_MPEG2: return "MPEG1/2 Motion Compensation and IDCT"; case IMGFMT_VDPAU_MPEG1: return "MPEG1 VDPAU acceleration"; diff -Nru mplayer2-2.0-426-gc32b3ed/libmpcodecs/img_format.h mplayer2-2.0-554-gf63dbad/libmpcodecs/img_format.h --- mplayer2-2.0-426-gc32b3ed/libmpcodecs/img_format.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpcodecs/img_format.h 2012-05-17 14:38:00.000000000 +0000 @@ -190,11 +190,6 @@ /* Compressed Formats */ #define IMGFMT_MPEGPES (('M'<<24)|('P'<<16)|('E'<<8)|('S')) #define IMGFMT_MJPEG (('M')|('J'<<8)|('P'<<16)|('G'<<24)) -/* Formats that are understood by zoran chips, we include - * non-interlaced, interlaced top-first, interlaced bottom-first */ -#define IMGFMT_ZRMJPEGNI (('Z'<<24)|('R'<<16)|('N'<<8)|('I')) -#define IMGFMT_ZRMJPEGIT (('Z'<<24)|('R'<<16)|('I'<<8)|('T')) -#define IMGFMT_ZRMJPEGIB (('Z'<<24)|('R'<<16)|('I'<<8)|('B')) // I think that this code could not be used by any other codec/format #define IMGFMT_XVMC 0x1DC70000 diff -Nru mplayer2-2.0-426-gc32b3ed/libmpcodecs/mp_image.c mplayer2-2.0-554-gf63dbad/libmpcodecs/mp_image.c --- mplayer2-2.0-426-gc32b3ed/libmpcodecs/mp_image.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpcodecs/mp_image.c 2012-05-17 14:38:00.000000000 +0000 @@ -99,9 +99,7 @@ mpi->flags&=~(MP_IMGFLAG_PLANAR|MP_IMGFLAG_YUV|MP_IMGFLAG_SWAPPED); mpi->imgfmt=out_fmt; // compressed formats - if(out_fmt == IMGFMT_MPEGPES || - out_fmt == IMGFMT_ZRMJPEGNI || out_fmt == IMGFMT_ZRMJPEGIT || out_fmt == IMGFMT_ZRMJPEGIB || - IMGFMT_IS_HWACCEL(out_fmt)){ + if(out_fmt == IMGFMT_MPEGPES || IMGFMT_IS_HWACCEL(out_fmt)){ mpi->bpp=0; return; } diff -Nru mplayer2-2.0-426-gc32b3ed/libmpcodecs/vd_ffmpeg.c mplayer2-2.0-554-gf63dbad/libmpcodecs/vd_ffmpeg.c --- mplayer2-2.0-426-gc32b3ed/libmpcodecs/vd_ffmpeg.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpcodecs/vd_ffmpeg.c 2012-05-17 14:38:00.000000000 +0000 @@ -22,14 +22,16 @@ #include #include +#include +#include +#include + #include "talloc.h" #include "config.h" #include "mp_msg.h" #include "options.h" #include "av_opts.h" -#include "libavutil/common.h" -#include "ffmpeg_files/intreadwrite.h" #include "mpbswap.h" #include "fmt-conversion.h" @@ -62,8 +64,6 @@ int do_dr1; int vo_initialized; int best_csp; - int b_age; - int ip_age[2]; int qp_stat[32]; double qp_sum; double inv_qp_sum; @@ -86,7 +86,6 @@ const m_option_t lavc_decode_opts_conf[] = { OPT_INTRANGE("bug", lavc_param.workaround_bugs, 0, -1, 999999), - OPT_INTRANGE("er", lavc_param.error_resilience, 0, 0, 99), OPT_FLAG_ON("gray", lavc_param.gray, 0), OPT_INTRANGE("idct", lavc_param.idct_algo, 0, 0, 99), OPT_INTRANGE("ec", lavc_param.error_concealment, 0, 0, 99), @@ -149,11 +148,10 @@ && lavc_codec->id != CODEC_ID_ROQ && lavc_codec->id != CODEC_ID_VP8 && lavc_codec->id != CODEC_ID_LAGARITH) ctx->do_dr1 = 1; - ctx->b_age = ctx->ip_age[0] = ctx->ip_age[1] = 256 * 256 * 256 * 64; ctx->ip_count = ctx->b_count = 0; ctx->pic = avcodec_alloc_frame(); - ctx->avctx = avcodec_alloc_context(); + ctx->avctx = avcodec_alloc_context3(lavc_codec); avctx = ctx->avctx; avctx->opaque = sh; avctx->codec_type = AVMEDIA_TYPE_VIDEO; @@ -209,7 +207,6 @@ avctx->coded_width = sh->disp_w; avctx->coded_height = sh->disp_h; avctx->workaround_bugs = lavc_param->workaround_bugs; - avctx->error_recognition = lavc_param->error_resilience; if (lavc_param->gray) avctx->flags |= CODEC_FLAG_GRAY; avctx->flags2 |= lavc_param->fast; @@ -272,7 +269,7 @@ * MJPG fourcc :( */ if (!sh->bih || sh->bih->biSize <= sizeof(*sh->bih)) break; - avctx->flags |= CODEC_FLAG_EXTERN_HUFF; + av_opt_set_int(avctx, "extern_huff", 1, AV_OPT_SEARCH_CHILDREN); avctx->extradata_size = sh->bih->biSize - sizeof(*sh->bih); avctx->extradata = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); @@ -315,11 +312,10 @@ if (sh->bih) avctx->bits_per_coded_sample = sh->bih->biBitCount; - if (lavc_param->threads > 1) - avctx->thread_count = lavc_param->threads; + avctx->thread_count = lavc_param->threads; /* open it */ - if (avcodec_open(avctx, lavc_codec) < 0) { + if (avcodec_open2(avctx, lavc_codec, NULL) < 0) { mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "Could not open codec.\n"); uninit(sh); return 0; @@ -551,19 +547,6 @@ pic->opaque = mpi; - if (pic->reference) { - pic->age = ctx->ip_age[0]; - - ctx->ip_age[0] = ctx->ip_age[1] + 1; - ctx->ip_age[1] = 1; - ctx->b_age++; - } else { - pic->age = ctx->b_age; - - ctx->ip_age[0]++; - ctx->ip_age[1]++; - ctx->b_age = 1; - } pic->type = FF_BUFFER_TYPE_USER; /* The libavcodec reordered_opaque functionality is implemented by @@ -627,9 +610,6 @@ int dr1 = ctx->do_dr1; AVPacket pkt; - if (len <= 0) - return NULL; // skipped frame - if (!dr1) avctx->draw_horiz_band = NULL; @@ -709,16 +689,16 @@ all_frametime, (double)(len * 8) / sh->frametime / 1000.0, (double)(all_len * 8) / all_frametime / 1000.0); switch (pic->pict_type) { - case FF_I_TYPE: + case AV_PICTURE_TYPE_I: fprintf(fvstats, "type= I\n"); break; - case FF_P_TYPE: + case AV_PICTURE_TYPE_P: fprintf(fvstats, "type= P\n"); break; - case FF_S_TYPE: + case AV_PICTURE_TYPE_S: fprintf(fvstats, "type= S\n"); break; - case FF_B_TYPE: + case AV_PICTURE_TYPE_B: fprintf(fvstats, "type= B\n"); break; default: @@ -838,6 +818,8 @@ return CONTROL_TRUE; case VDCTRL_QUERY_UNSEEN_FRAMES:; int delay = avctx->has_b_frames; + if (avctx->active_thread_type & FF_THREAD_FRAME) + delay += avctx->thread_count - 1; return delay + 10; case VDCTRL_RESET_ASPECT: if (ctx->vo_initialized) diff -Nru mplayer2-2.0-426-gc32b3ed/libmpcodecs/vd_mtga.c mplayer2-2.0-554-gf63dbad/libmpcodecs/vd_mtga.c --- mplayer2-2.0-426-gc32b3ed/libmpcodecs/vd_mtga.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpcodecs/vd_mtga.c 2012-05-17 14:38:00.000000000 +0000 @@ -26,10 +26,11 @@ #include #include +#include + #include "config.h" #include "mp_msg.h" -#include "ffmpeg_files/intreadwrite.h" #include "libvo/fastmemcpy.h" #include "vd_internal.h" diff -Nru mplayer2-2.0-426-gc32b3ed/libmpcodecs/vd_qtvideo.c mplayer2-2.0-554-gf63dbad/libmpcodecs/vd_qtvideo.c --- mplayer2-2.0-426-gc32b3ed/libmpcodecs/vd_qtvideo.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpcodecs/vd_qtvideo.c 2012-05-17 14:38:00.000000000 +0000 @@ -129,7 +129,7 @@ DecompressSequenceFrameS = (OSErr (*)(ImageSequence,Ptr,long,CodecFlags,CodecFlags*,ICMCompletionProcRecordPtr))GetProcAddress(handler, "DecompressSequenceFrameS"); GetGWorldPixMap = (PixMapHandle (*)(GWorldPtr))GetProcAddress(handler, "GetGWorldPixMap"); QTNewGWorldFromPtr = (OSErr(*)(GWorldPtr *,OSType,const Rect *,CTabHandle,void*,GWorldFlags,void *,long))GetProcAddress(handler, "QTNewGWorldFromPtr"); - NewHandleClear = (OSErr(*)(Size))GetProcAddress(handler, "NewHandleClear"); + NewHandleClear = (Handle(*)(Size))GetProcAddress(handler, "NewHandleClear"); DisposeHandle = (void (*)(Handle))GetProcAddress(handler, "DisposeHandle"); DisposeGWorld = (void (*)(GWorldPtr))GetProcAddress(handler, "DisposeGWorld"); CDSequenceEnd = (OSErr (*)(ImageSequence))GetProcAddress(handler, "CDSequenceEnd"); diff -Nru mplayer2-2.0-426-gc32b3ed/libmpcodecs/vd_realvid.c mplayer2-2.0-554-gf63dbad/libmpcodecs/vd_realvid.c --- mplayer2-2.0-426-gc32b3ed/libmpcodecs/vd_realvid.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpcodecs/vd_realvid.c 2012-05-17 14:38:00.000000000 +0000 @@ -19,6 +19,8 @@ #include #include +#include + #include "config.h" #ifdef HAVE_LIBDL @@ -26,7 +28,6 @@ #endif #include "mp_msg.h" -#include "ffmpeg_files/intreadwrite.h" #include "path.h" #include "vd_internal.h" diff -Nru mplayer2-2.0-426-gc32b3ed/libmpcodecs/vd_sgi.c mplayer2-2.0-554-gf63dbad/libmpcodecs/vd_sgi.c --- mplayer2-2.0-426-gc32b3ed/libmpcodecs/vd_sgi.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpcodecs/vd_sgi.c 2012-05-17 14:38:00.000000000 +0000 @@ -21,9 +21,10 @@ #include #include +#include + #include "config.h" #include "mp_msg.h" -#include "ffmpeg_files/intreadwrite.h" #include "mpbswap.h" #include "vd_internal.h" diff -Nru mplayer2-2.0-426-gc32b3ed/libmpcodecs/vd_theora.c mplayer2-2.0-554-gf63dbad/libmpcodecs/vd_theora.c --- mplayer2-2.0-426-gc32b3ed/libmpcodecs/vd_theora.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpcodecs/vd_theora.c 2012-05-17 14:38:00.000000000 +0000 @@ -21,12 +21,13 @@ #include #include +#include + #include "config.h" #include "mp_msg.h" #include "vd_internal.h" -#include "ffmpeg_files/intreadwrite.h" static const vd_info_t info = { "Theora/VP3", diff -Nru mplayer2-2.0-426-gc32b3ed/libmpcodecs/vd_vfw.c mplayer2-2.0-554-gf63dbad/libmpcodecs/vd_vfw.c --- mplayer2-2.0-426-gc32b3ed/libmpcodecs/vd_vfw.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpcodecs/vd_vfw.c 2012-05-17 14:38:00.000000000 +0000 @@ -153,7 +153,7 @@ static int init(sh_video_t *sh){ HRESULT ret; // unsigned int outfmt=sh->codec->outfmt[sh->outfmtidx]; - int i, o_bih_len; + int o_bih_len; vd_vfw_ctx *priv; /* Hack for VSSH codec: new dll can't decode old files @@ -198,7 +198,7 @@ ret = ICDecompressGetFormat(priv->handle, sh->bih, priv->o_bih); if(ret < 0){ mp_msg(MSGT_WIN32,MSGL_ERR,"ICDecompressGetFormat failed: Error %d\n", (int)ret); - for (i=0; i < o_bih_len; i++) mp_msg(MSGT_WIN32, MSGL_DBG2, "%02x ", priv->o_bih[i]); + //for (i=0; i < o_bih_len; i++) mp_msg(MSGT_WIN32, MSGL_DBG2, "%02x ", priv->o_bih[i]); return 0; } mp_msg(MSGT_WIN32,MSGL_V,"ICDecompressGetFormat OK\n"); diff -Nru mplayer2-2.0-426-gc32b3ed/libmpcodecs/vf.c mplayer2-2.0-554-gf63dbad/libmpcodecs/vf.c --- mplayer2-2.0-426-gc32b3ed/libmpcodecs/vf.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpcodecs/vf.c 2012-05-17 14:38:00.000000000 +0000 @@ -134,7 +134,9 @@ &vf_info_palette, &vf_info_pp7, +#ifdef CONFIG_LIBPOSTPROC &vf_info_pp, +#endif &vf_info_lavc, &vf_info_lavcdeint, &vf_info_screenshot, diff -Nru mplayer2-2.0-426-gc32b3ed/libmpcodecs/vf_ass.c mplayer2-2.0-554-gf63dbad/libmpcodecs/vf_ass.c --- mplayer2-2.0-426-gc32b3ed/libmpcodecs/vf_ass.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpcodecs/vf_ass.c 2012-05-17 14:38:00.000000000 +0000 @@ -374,7 +374,7 @@ } osd->ass_force_reload = false; images = ass_render_frame(renderer, osd->ass_track, - (pts + sub_delay) * 1000 + .5, NULL); + (pts - osd->sub_offset + sub_delay) * 1000 + .5, NULL); } prepare_image(vf, mpi); diff -Nru mplayer2-2.0-426-gc32b3ed/libmpcodecs/vf_lavc.c mplayer2-2.0-554-gf63dbad/libmpcodecs/vf_lavc.c --- mplayer2-2.0-426-gc32b3ed/libmpcodecs/vf_lavc.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpcodecs/vf_lavc.c 2012-05-17 14:38:00.000000000 +0000 @@ -71,7 +71,7 @@ vf->priv->outbuf_size=10000+width*height; // must be enough! vf->priv->outbuf = malloc(vf->priv->outbuf_size); - if (avcodec_open(&lavc_venc_context, vf->priv->codec) != 0) { + if (avcodec_open2(&lavc_venc_context, vf->priv->codec, NULL) != 0) { mp_tmsg(MSGT_VFILTER,MSGL_ERR,"Could not open codec.\n"); return 0; } @@ -143,7 +143,7 @@ return 0; } - vf->priv->context=avcodec_alloc_context(); + vf->priv->context=avcodec_alloc_context3(vf->priv->codec); vf->priv->pic = avcodec_alloc_frame(); // TODO: parse args -> diff -Nru mplayer2-2.0-426-gc32b3ed/libmpcodecs/vf_remove_logo.c mplayer2-2.0-554-gf63dbad/libmpcodecs/vf_remove_logo.c --- mplayer2-2.0-426-gc32b3ed/libmpcodecs/vf_remove_logo.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpcodecs/vf_remove_logo.c 2012-05-17 14:38:00.000000000 +0000 @@ -86,6 +86,8 @@ #include #include +#include "osdep/io.h" + #include "config.h" #include "mp_msg.h" #include "libvo/fastmemcpy.h" diff -Nru mplayer2-2.0-426-gc32b3ed/libmpcodecs/vf_uspp.c mplayer2-2.0-554-gf63dbad/libmpcodecs/vf_uspp.c --- mplayer2-2.0-426-gc32b3ed/libmpcodecs/vf_uspp.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpcodecs/vf_uspp.c 2012-05-17 14:38:00.000000000 +0000 @@ -222,8 +222,7 @@ for(i=0; i< (1<priv->log2_count); i++){ AVCodecContext *avctx_enc; - avctx_enc= - vf->priv->avctx_enc[i]= avcodec_alloc_context(); + avctx_enc = vf->priv->avctx_enc[i] = avcodec_alloc_context3(enc); avctx_enc->width = width + BLOCK; avctx_enc->height = height + BLOCK; avctx_enc->time_base= (AVRational){1,25}; // meaningless @@ -233,8 +232,8 @@ avctx_enc->flags = CODEC_FLAG_QSCALE | CODEC_FLAG_LOW_DELAY; avctx_enc->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL; avctx_enc->global_quality= 123; - avcodec_open(avctx_enc, enc); - assert(avctx_enc->codec); + int res = avcodec_open2(avctx_enc, enc, NULL); + assert(res >= 0); } vf->priv->frame= avcodec_alloc_frame(); vf->priv->frame_dec= avcodec_alloc_frame(); diff -Nru mplayer2-2.0-426-gc32b3ed/libmpcodecs/vf_vo.c mplayer2-2.0-554-gf63dbad/libmpcodecs/vf_vo.c --- mplayer2-2.0-426-gc32b3ed/libmpcodecs/vf_vo.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpcodecs/vf_vo.c 2012-05-17 14:38:00.000000000 +0000 @@ -33,8 +33,6 @@ #include "sub/ass_mp.h" #include "sub/sub.h" -//===========================================================================// - extern float sub_delay; struct vf_priv_s { @@ -48,47 +46,49 @@ }; #define video_out (vf->priv->vo) -static int query_format(struct vf_instance *vf, unsigned int fmt); /* forward declaration */ -static void draw_slice(struct vf_instance *vf, unsigned char** src, int* stride, int w,int h, int x, int y); +static int query_format(struct vf_instance *vf, unsigned int fmt); +static void draw_slice(struct vf_instance *vf, unsigned char **src, + int *stride, int w, int h, int x, int y); static int config(struct vf_instance *vf, - int width, int height, int d_width, int d_height, - unsigned int flags, unsigned int outfmt){ + int width, int height, int d_width, int d_height, + unsigned int flags, unsigned int outfmt) +{ - if ((width <= 0) || (height <= 0) || (d_width <= 0) || (d_height <= 0)) - { - mp_msg(MSGT_CPLAYER, MSGL_ERR, "VO: invalid dimensions!\n"); - return 0; + if ((width <= 0) || (height <= 0) || (d_width <= 0) || (d_height <= 0)) { + mp_msg(MSGT_CPLAYER, MSGL_ERR, "VO: invalid dimensions!\n"); + return 0; } const vo_info_t *info = video_out->driver->info; - mp_msg(MSGT_CPLAYER,MSGL_INFO,"VO: [%s] %dx%d => %dx%d %s %s%s%s%s\n",info->short_name, - width, height, - d_width, d_height, - vo_format_name(outfmt), - (flags&VOFLAG_FULLSCREEN)?" [fs]":"", - (flags&VOFLAG_MODESWITCHING)?" [vm]":"", - (flags&VOFLAG_SWSCALE)?" [zoom]":"", - (flags&VOFLAG_FLIPPING)?" [flip]":""); - mp_msg(MSGT_CPLAYER,MSGL_V,"VO: Description: %s\n",info->name); - mp_msg(MSGT_CPLAYER,MSGL_V,"VO: Author: %s\n", info->author); - if(info->comment && strlen(info->comment) > 0) - mp_msg(MSGT_CPLAYER,MSGL_V,"VO: Comment: %s\n", info->comment); + mp_msg(MSGT_CPLAYER, MSGL_INFO, "VO: [%s] %dx%d => %dx%d %s %s%s%s%s\n", + info->short_name, + width, height, + d_width, d_height, + vo_format_name(outfmt), + (flags & VOFLAG_FULLSCREEN) ? " [fs]" : "", + (flags & VOFLAG_MODESWITCHING) ? " [vm]" : "", + (flags & VOFLAG_SWSCALE) ? " [zoom]" : "", + (flags & VOFLAG_FLIPPING) ? " [flip]" : ""); + mp_msg(MSGT_CPLAYER, MSGL_V, "VO: Description: %s\n", info->name); + mp_msg(MSGT_CPLAYER, MSGL_V, "VO: Author: %s\n", info->author); + if (info->comment && strlen(info->comment) > 0) + mp_msg(MSGT_CPLAYER, MSGL_V, "VO: Comment: %s\n", info->comment); // save vo's stride capability for the wanted colorspace: - vf->default_caps=query_format(vf,outfmt); + vf->default_caps = query_format(vf, outfmt); vf->draw_slice = (vf->default_caps & VOCAP_NOSLICES) ? NULL : draw_slice; if (vo_config(video_out, width, height, d_width, d_height, flags, outfmt)) - return 0; + return 0; #ifdef CONFIG_ASS vf->priv->scale_ratio = (double) d_width / d_height * height / width; if (vf->priv->renderer_realaspect) { - mp_ass_configure(vf->priv->renderer_realaspect, vf->opts, width, height, + mp_ass_configure(vf->priv->renderer_realaspect, vf->opts, width, height, vf->default_caps & VFCAP_EOSD_UNSCALED); - mp_ass_configure(vf->priv->renderer_vsfilter, vf->opts, width, height, + mp_ass_configure(vf->priv->renderer_vsfilter, vf->opts, width, height, vf->default_caps & VFCAP_EOSD_UNSCALED); } @@ -99,44 +99,46 @@ return 1; } -static int control(struct vf_instance *vf, int request, void* data) +static int control(struct vf_instance *vf, int request, void *data) { - switch(request){ + switch (request) { case VFCTRL_GET_DEINTERLACE: - { - if(!video_out) return CONTROL_FALSE; // vo not configured? + if (!video_out) + return CONTROL_FALSE; // vo not configured? return vo_control(video_out, VOCTRL_GET_DEINTERLACE, data) == VO_TRUE; - } case VFCTRL_SET_DEINTERLACE: - { - if(!video_out) return CONTROL_FALSE; // vo not configured? + if (!video_out) + return CONTROL_FALSE; // vo not configured? return vo_control(video_out, VOCTRL_SET_DEINTERLACE, data) == VO_TRUE; - } case VFCTRL_GET_YUV_COLORSPACE: return vo_control(video_out, VOCTRL_GET_YUV_COLORSPACE, data) == true; case VFCTRL_SET_YUV_COLORSPACE: return vo_control(video_out, VOCTRL_SET_YUV_COLORSPACE, data) == true; case VFCTRL_DRAW_OSD: - if(!video_out->config_ok) return CONTROL_FALSE; // vo not configured? - vo_draw_osd(video_out, data); - return CONTROL_TRUE; - case VFCTRL_SET_EQUALIZER: - { - vf_equalizer_t *eq=data; - if(!video_out->config_ok) return CONTROL_FALSE; // vo not configured? - struct voctrl_set_equalizer_args param = {eq->item, eq->value}; - return vo_control(video_out, VOCTRL_SET_EQUALIZER, ¶m) == VO_TRUE; + if (!video_out->config_ok) + return CONTROL_FALSE; // vo not configured? + vo_draw_osd(video_out, data); + return CONTROL_TRUE; + case VFCTRL_SET_EQUALIZER: { + vf_equalizer_t *eq = data; + if (!video_out->config_ok) + return CONTROL_FALSE; // vo not configured? + struct voctrl_set_equalizer_args param = { + eq->item, eq->value + }; + return vo_control(video_out, VOCTRL_SET_EQUALIZER, ¶m) == VO_TRUE; } - case VFCTRL_GET_EQUALIZER: - { - vf_equalizer_t *eq=data; - if(!video_out->config_ok) return CONTROL_FALSE; // vo not configured? - struct voctrl_get_equalizer_args param = {eq->item, &eq->value}; - return vo_control(video_out, VOCTRL_GET_EQUALIZER, ¶m) == VO_TRUE; + case VFCTRL_GET_EQUALIZER: { + vf_equalizer_t *eq = data; + if (!video_out->config_ok) + return CONTROL_FALSE; // vo not configured? + struct voctrl_get_equalizer_args param = { + eq->item, &eq->value + }; + return vo_control(video_out, VOCTRL_GET_EQUALIZER, ¶m) == VO_TRUE; } #ifdef CONFIG_ASS - case VFCTRL_INIT_EOSD: - { + case VFCTRL_INIT_EOSD: { vf->priv->renderer_realaspect = ass_renderer_init(data); if (!vf->priv->renderer_realaspect) return CONTROL_FALSE; @@ -150,10 +152,9 @@ vf->priv->prev_visibility = false; return CONTROL_TRUE; } - case VFCTRL_DRAW_EOSD: - { + case VFCTRL_DRAW_EOSD: { struct osd_state *osd = data; - mp_eosd_images_t images = {NULL, 2}; + mp_eosd_images_t images = { NULL, 2 }; ASS_Renderer *renderer; double scale; if (osd->vsfilter_aspect && vf->opts->ass_vsfilter_aspect_compat) { @@ -169,7 +170,7 @@ vf->priv->prev_visibility = false; osd->ass_track_changed = false; if (sub_visibility && osd->ass_track && (osd->pts != MP_NOPTS_VALUE)) { - struct mp_eosd_res res = {0}; + struct mp_eosd_res res = { 0 }; if (vo_control(video_out, VOCTRL_GET_EOSD_RES, &res) == VO_TRUE) { ass_set_frame_size(renderer, res.w, res.h); ass_set_margins(renderer, res.mt, res.mb, res.ml, res.mr); @@ -181,7 +182,7 @@ mp_ass_reload_options(vf->priv->renderer_vsfilter, vf->opts); } images.imgs = ass_render_frame(renderer, osd->ass_track, - (osd->pts+sub_delay) * 1000 + .5, + (osd->pts + sub_delay) * 1000 + .5, &images.changed); if (!vf->priv->prev_visibility || osd->ass_force_reload) images.changed = 2; @@ -196,53 +197,58 @@ return CONTROL_UNKNOWN; } -static int query_format(struct vf_instance *vf, unsigned int fmt){ +static int query_format(struct vf_instance *vf, unsigned int fmt) +{ int flags = vo_control(video_out, VOCTRL_QUERY_FORMAT, &fmt); // draw_slice() accepts stride, draw_frame() doesn't: - if(flags) - if(fmt==IMGFMT_YV12 || fmt==IMGFMT_I420 || fmt==IMGFMT_IYUV) - flags|=VFCAP_ACCEPT_STRIDE; + if (flags) + if (fmt == IMGFMT_YV12 || fmt == IMGFMT_I420 || fmt == IMGFMT_IYUV) + flags |= VFCAP_ACCEPT_STRIDE; return flags; } static void get_image(struct vf_instance *vf, - mp_image_t *mpi){ + mp_image_t *mpi) +{ if (!video_out->config_ok) return; // GET_IMAGE is required for hardware-accelerated formats - if(vo_directrendering || - IMGFMT_IS_HWACCEL(mpi->imgfmt)) - vo_control(video_out, VOCTRL_GET_IMAGE, mpi); + if (vo_directrendering || IMGFMT_IS_HWACCEL(mpi->imgfmt)) + vo_control(video_out, VOCTRL_GET_IMAGE, mpi); } -static int put_image(struct vf_instance *vf, - mp_image_t *mpi, double pts){ - if(!video_out->config_ok) return 0; // vo not configured? - // first check, maybe the vo/vf plugin implements draw_image using mpi: - if (vo_draw_image(video_out, mpi, pts) >= 0) - return 1; - // nope, fallback to old draw_frame/draw_slice: - if(!(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK))){ - // blit frame: -// if(mpi->flags&MP_IMGFLAG_PLANAR) - if(vf->default_caps&VFCAP_ACCEPT_STRIDE) - vo_draw_slice(video_out, mpi->planes,mpi->stride,mpi->w,mpi->h,mpi->x,mpi->y); - else - vo_draw_frame(video_out, mpi->planes); - } - return 1; +static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts) +{ + if (!video_out->config_ok) + return 0; + // first check, maybe the vo/vf plugin implements draw_image using mpi: + if (vo_draw_image(video_out, mpi, pts) >= 0) + return 1; + // nope, fallback to old draw_frame/draw_slice: + if (!(mpi->flags & (MP_IMGFLAG_DIRECT | MP_IMGFLAG_DRAW_CALLBACK))) { + // blit frame: + if (vf->default_caps & VFCAP_ACCEPT_STRIDE) + vo_draw_slice(video_out, mpi->planes, mpi->stride, mpi->w, mpi->h, + mpi->x, mpi->y); + else + vo_draw_frame(video_out, mpi->planes); + } + return 1; } -static void start_slice(struct vf_instance *vf, - mp_image_t *mpi) { - if(!video_out->config_ok) return; // vo not configured? - vo_control(video_out, VOCTRL_START_SLICE,mpi); +static void start_slice(struct vf_instance *vf, mp_image_t *mpi) +{ + if (!video_out->config_ok) + return; + vo_control(video_out, VOCTRL_START_SLICE, mpi); } -static void draw_slice(struct vf_instance *vf, - unsigned char** src, int* stride, int w,int h, int x, int y){ - if(!video_out->config_ok) return; // vo not configured? - vo_draw_slice(video_out, src,stride,w,h,x,y); +static void draw_slice(struct vf_instance *vf, unsigned char **src, + int *stride, int w, int h, int x, int y) +{ + if (!video_out->config_ok) + return; + vo_draw_slice(video_out, src, stride, w, h, x, y); } static void uninit(struct vf_instance *vf) @@ -260,20 +266,21 @@ free(vf->priv); } } -//===========================================================================// -static int vf_open(vf_instance_t *vf, char *args){ - vf->config=config; - vf->control=control; - vf->query_format=query_format; - vf->get_image=get_image; - vf->put_image=put_image; - vf->draw_slice=draw_slice; - vf->start_slice=start_slice; - vf->uninit=uninit; - vf->priv=calloc(1, sizeof(struct vf_priv_s)); +static int vf_open(vf_instance_t *vf, char *args) +{ + vf->config = config; + vf->control = control; + vf->query_format = query_format; + vf->get_image = get_image; + vf->put_image = put_image; + vf->draw_slice = draw_slice; + vf->start_slice = start_slice; + vf->uninit = uninit; + vf->priv = calloc(1, sizeof(struct vf_priv_s)); vf->priv->vo = (struct vo *)args; - if(!video_out) return 0; // no vo ? + if (!video_out) + return 0; return 1; } @@ -285,5 +292,3 @@ vf_open, NULL }; - -//===========================================================================// diff -Nru mplayer2-2.0-426-gc32b3ed/libmpdemux/asfheader.c mplayer2-2.0-554-gf63dbad/libmpdemux/asfheader.c --- mplayer2-2.0-426-gc32b3ed/libmpdemux/asfheader.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpdemux/asfheader.c 2012-05-17 14:38:00.000000000 +0000 @@ -22,9 +22,10 @@ #include #include +#include +#include + #include "config.h" -#include "libavutil/common.h" -#include "ffmpeg_files/intreadwrite.h" #include "mp_msg.h" #include "stream/stream.h" diff -Nru mplayer2-2.0-426-gc32b3ed/libmpdemux/aviheader.c mplayer2-2.0-554-gf63dbad/libmpdemux/aviheader.c --- mplayer2-2.0-426-gc32b3ed/libmpdemux/aviheader.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpdemux/aviheader.c 2012-05-17 14:38:00.000000000 +0000 @@ -21,6 +21,9 @@ #include #include +#include +#include + #include "config.h" #include "mp_msg.h" @@ -29,7 +32,6 @@ #include "stheader.h" #include "aviprint.h" #include "aviheader.h" -#include "libavutil/common.h" static MainAVIHeader avih; @@ -232,7 +234,7 @@ s->bIndexSubType = stream_read_char(demuxer->stream); s->bIndexType = stream_read_char(demuxer->stream); s->nEntriesInUse = stream_read_dword_le(demuxer->stream); - *(uint32_t *)s->dwChunkId = stream_read_dword_le(demuxer->stream); + AV_WN32(s->dwChunkId, stream_read_dword_le(demuxer->stream)); stream_read(demuxer->stream, (char *)s->dwReserved, 3*4); memset(s->dwReserved, 0, 3*4); diff -Nru mplayer2-2.0-426-gc32b3ed/libmpdemux/aviheader.h mplayer2-2.0-554-gf63dbad/libmpdemux/aviheader.h --- mplayer2-2.0-426-gc32b3ed/libmpdemux/aviheader.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpdemux/aviheader.h 2012-05-17 14:38:00.000000000 +0000 @@ -128,8 +128,10 @@ #define AVIIF_NOTIME 0x00000100L // this frame doesn't take any time #define AVIIF_COMPUSE 0x0FFF0000L // these bits are for compressor use +#ifndef FOURCC_RIFF #define FOURCC_RIFF mmioFOURCC('R', 'I', 'F', 'F') #define FOURCC_LIST mmioFOURCC('L', 'I', 'S', 'T') +#endif typedef struct { diff -Nru mplayer2-2.0-426-gc32b3ed/libmpdemux/demux_asf.c mplayer2-2.0-554-gf63dbad/libmpdemux/demux_asf.c --- mplayer2-2.0-426-gc32b3ed/libmpdemux/demux_asf.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpdemux/demux_asf.c 2012-05-17 14:38:00.000000000 +0000 @@ -24,6 +24,8 @@ #include #include +#include + #include "config.h" #include "mp_msg.h" @@ -33,7 +35,6 @@ #include "demuxer.h" #include "libmpcodecs/dec_audio.h" #include "libvo/fastmemcpy.h" -#include "ffmpeg_files/intreadwrite.h" // based on asf file-format doc by Eugene [http://divx.euro.ru] diff -Nru mplayer2-2.0-426-gc32b3ed/libmpdemux/demux_audio.c mplayer2-2.0-554-gf63dbad/libmpdemux/demux_audio.c --- mplayer2-2.0-426-gc32b3ed/libmpdemux/demux_audio.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpdemux/demux_audio.c 2012-05-17 14:38:00.000000000 +0000 @@ -16,21 +16,22 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include +#include +#include + +#include + #include "config.h" #include "options.h" #include "mp_msg.h" -#include -#include #include "stream/stream.h" #include "aviprint.h" #include "demuxer.h" #include "stheader.h" #include "genres.h" #include "mp3_hdr.h" -#include "ffmpeg_files/intreadwrite.h" - -#include #define MP3 1 #define WAV 2 diff -Nru mplayer2-2.0-426-gc32b3ed/libmpdemux/demux_lavf.c mplayer2-2.0-554-gf63dbad/libmpdemux/demux_lavf.c --- mplayer2-2.0-426-gc32b3ed/libmpdemux/demux_lavf.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpdemux/demux_lavf.c 2012-05-17 14:38:00.000000000 +0000 @@ -25,6 +25,13 @@ #include #include +#include +#include +#include +#include +#include +#include + #include "config.h" #include "options.h" #include "mp_msg.h" @@ -38,13 +45,6 @@ #include "m_option.h" #include "sub/sub.h" -#include "libavformat/avformat.h" -#include "libavformat/avio.h" -#include "libavutil/avutil.h" -#include "libavutil/avstring.h" -#include -#include "libavcodec/opt.h" - #include "mp_taglists.h" #define INITIAL_PROBE_SIZE STREAM_BUFFER_SIZE @@ -109,9 +109,12 @@ pos += stream->end_pos; else if (whence == SEEK_SET) pos += stream->start_pos; - else if (whence == AVSEEK_SIZE && stream->end_pos > 0) + else if (whence == AVSEEK_SIZE && stream->end_pos > 0) { + off_t size; + if (stream_control(stream, STREAM_CTRL_GET_SIZE, &size) == STREAM_OK) + return size; return stream->end_pos - stream->start_pos; - else + } else return -1; if (pos < 0) @@ -293,8 +296,7 @@ if (matches_avinputformat_name(priv, "mpeg") || matches_avinputformat_name(priv, "mpegts")) codec->codec_tag = 0; - int override_tag = mp_av_codec_get_tag(mp_codecid_override_taglists, - codec->codec_id); + int override_tag = mp_taglist_override(codec->codec_id); // For some formats (like PCM) always trust CODEC_ID_* more than codec_tag if (override_tag) codec->codec_tag = override_tag; @@ -313,8 +315,7 @@ if (codec->codec_tag == MKTAG('m', 'p', '4', 'a')) codec->codec_tag = 0; if (!codec->codec_tag) - codec->codec_tag = mp_av_codec_get_tag(mp_wav_taglists, - codec->codec_id); + codec->codec_tag = mp_taglist_audio(codec->codec_id); wf->wFormatTag = codec->codec_tag; wf->nChannels = codec->channels; wf->nSamplesPerSec = codec->sample_rate; @@ -399,8 +400,7 @@ codec->codec_tag = avcodec_pix_fmt_to_codec_tag(codec->pix_fmt); } if (!codec->codec_tag) - codec->codec_tag = mp_av_codec_get_tag(mp_bmp_taglists, - codec->codec_id); + codec->codec_tag = mp_taglist_video(codec->codec_id); bih->biSize = sizeof(*bih) + codec->extradata_size; bih->biWidth = codec->width; bih->biHeight = codec->height; @@ -417,8 +417,22 @@ sh_video->video.dwRate = codec->time_base.den; sh_video->video.dwScale = codec->time_base.num; } - sh_video->fps = av_q2d(st->r_frame_rate); - sh_video->frametime = 1 / av_q2d(st->r_frame_rate); + /* Try to make up some frame rate value, even if it's not reliable. + * FPS information is needed to support subtitle formats which base + * timing on frame numbers. + * Libavformat seems to report no "reliable" FPS value for AVI files, + * while they are typically constant enough FPS that the value this + * heuristic makes up works with subtitles in practice. + */ + double fps; + if (st->r_frame_rate.num) + fps = av_q2d(st->r_frame_rate); + else + fps = 1.0 / FFMAX(av_q2d(st->time_base), + av_q2d(st->codec->time_base) * + st->codec->ticks_per_frame); + sh_video->fps = fps; + sh_video->frametime = 1 / fps; sh_video->format = bih->biCompression; if (st->sample_aspect_ratio.num) sh_video->aspect = codec->width * st->sample_aspect_ratio.num @@ -517,7 +531,7 @@ AVCodec *avc = avcodec_find_decoder(codec->codec_id); const char *codec_name = avc ? avc->name : "unknown"; if (!avc && *stream_type == 's' && demuxer->s_streams[i]) - codec_name = sh_sub_type2str(((sh_sub_t *)demuxer->s_streams[i])->type); + codec_name = sh_sub_type2str((demuxer->s_streams[i])->type); mp_msg(MSGT_DEMUX, MSGL_INFO, "[lavf] stream %d: %s (%s), -%cid %d", i, stream_type, codec_name, *stream_type, stream_id); if (lang && lang->value && *stream_type != 'v') @@ -534,7 +548,6 @@ struct MPOpts *opts = demuxer->opts; struct lavfdopts *lavfdopts = &opts->lavfdopts; AVFormatContext *avfc; - const AVOption *opt; AVDictionaryEntry *t = NULL; lavf_priv_t *priv = demuxer->priv; int i; @@ -559,16 +572,14 @@ avfc->flags |= AVFMT_FLAG_IGNIDX; if (lavfdopts->probesize) { - opt = av_set_int(avfc, "probesize", lavfdopts->probesize); - if (!opt) + if (av_opt_set_int(avfc, "probesize", lavfdopts->probesize, 0) < 0) mp_msg(MSGT_HEADER, MSGL_ERR, "demux_lavf, couldn't set option probesize to %u\n", lavfdopts->probesize); } if (lavfdopts->analyzeduration) { - opt = av_set_int(avfc, "analyzeduration", - lavfdopts->analyzeduration * AV_TIME_BASE); - if (!opt) + if (av_opt_set_int(avfc, "analyzeduration", + lavfdopts->analyzeduration * AV_TIME_BASE, 0) < 0) mp_msg(MSGT_HEADER, MSGL_ERR, "demux_lavf, couldn't set option " "analyzeduration to %u\n", lavfdopts->analyzeduration); } @@ -609,7 +620,7 @@ priv->avfc = avfc; - if (av_find_stream_info(avfc) < 0) { + if (avformat_find_stream_info(avfc, NULL) < 0) { mp_msg(MSGT_HEADER, MSGL_ERR, "LAVF_header: av_find_stream_info() failed\n"); return NULL; @@ -617,7 +628,7 @@ /* Add metadata. */ while ((t = av_dict_get(avfc->metadata, "", t, - AV_METADATA_IGNORE_SUFFIX))) + AV_DICT_IGNORE_SUFFIX))) demux_info_add(demuxer, t->key, t->value); for (i = 0; i < avfc->nb_chapters; i++) { @@ -708,7 +719,7 @@ AVDictionaryEntry *t = NULL; AVStream *stream = avfc->streams[avfc->nb_streams - 1]; while ((t = av_dict_get(stream->metadata, "", t, - AV_METADATA_IGNORE_SUFFIX))) + AV_DICT_IGNORE_SUFFIX))) demux_info_add(demuxer, t->key, t->value); } else { if (priv->internet_radio_hack) @@ -995,7 +1006,7 @@ if (priv) { if (priv->avfc) { av_freep(&priv->avfc->key); - av_close_input_file(priv->avfc); + avformat_close_input(&priv->avfc); } av_freep(&priv->pb); free(priv); diff -Nru mplayer2-2.0-426-gc32b3ed/libmpdemux/demux_mf.c mplayer2-2.0-554-gf63dbad/libmpdemux/demux_mf.c --- mplayer2-2.0-426-gc32b3ed/libmpdemux/demux_mf.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpdemux/demux_mf.c 2012-05-17 14:38:00.000000000 +0000 @@ -23,6 +23,8 @@ #include #include +#include "osdep/io.h" + #include "talloc.h" #include "config.h" #include "mp_msg.h" @@ -49,20 +51,19 @@ // 1 = successfully read a packet static int demux_mf_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds){ mf_t * mf; - struct stat fs; FILE * f; mf=(mf_t*)demuxer->priv; if ( mf->curr_frame >= mf->nr_of_files ) return 0; - stat( mf->names[mf->curr_frame],&fs ); -// printf( "[demux_mf] frame: %d (%s,%d)\n",mf->curr_frame,mf->names[mf->curr_frame],fs.st_size ); - if ( !( f=fopen( mf->names[mf->curr_frame],"rb" ) ) ) return 0; { sh_video_t * sh_video = demuxer->video->sh; - demux_packet_t * dp = new_demux_packet( fs.st_size ); - if ( !fread( dp->buffer,fs.st_size,1,f ) ) return 0; + fseek(f, 0, SEEK_END); + long file_size = ftell(f); + fseek(f, 0, SEEK_SET); + demux_packet_t * dp = new_demux_packet( file_size ); + if ( !fread( dp->buffer,file_size,1,f ) ) return 0; dp->pts=mf->curr_frame / sh_video->fps; dp->pos=mf->curr_frame; dp->flags=0; diff -Nru mplayer2-2.0-426-gc32b3ed/libmpdemux/demux_mkv.c mplayer2-2.0-554-gf63dbad/libmpdemux/demux_mkv.c --- mplayer2-2.0-426-gc32b3ed/libmpdemux/demux_mkv.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpdemux/demux_mkv.c 2012-05-17 14:38:00.000000000 +0000 @@ -21,14 +21,23 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "config.h" - #include #include #include #include #include +#include +#include +#include +#include + +#include "config.h" + +#if CONFIG_ZLIB +#include +#endif + #include "talloc.h" #include "options.h" #include "bstr.h" @@ -43,20 +52,11 @@ #include "sub/sub.h" -#include "libavutil/common.h" #ifdef CONFIG_QTX_CODECS #include "loader/qtx/qtxsdk/components.h" #endif -#if CONFIG_ZLIB -#include -#endif - -#include "libavutil/lzo.h" -#include "ffmpeg_files/intreadwrite.h" -#include "libavutil/avstring.h" - static const unsigned char sipr_swaps[38][2] = { {0,63},{1,22},{2,44},{3,90},{5,81},{7,31},{8,86},{9,58},{10,36},{12,68}, {13,39},{14,73},{15,53},{16,69},{17,57},{19,88},{20,34},{21,71},{24,46}, diff -Nru mplayer2-2.0-426-gc32b3ed/libmpdemux/demux_mov.c mplayer2-2.0-554-gf63dbad/libmpdemux/demux_mov.c --- mplayer2-2.0-426-gc32b3ed/libmpdemux/demux_mov.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpdemux/demux_mov.c 2012-05-17 14:38:00.000000000 +0000 @@ -44,6 +44,9 @@ #include #include +#include +#include + #include "config.h" #ifdef CONFIG_QUICKTIME @@ -54,6 +57,14 @@ #include "loader/qtx/qtxsdk/components.h" #endif +#if CONFIG_ZLIB +#include +#endif + +#ifndef _FCNTL_H +#include +#endif + #include "mp_msg.h" #include "stream/stream.h" @@ -61,8 +72,6 @@ #include "stheader.h" #include "libmpcodecs/img_format.h" -#include "libavutil/common.h" -#include "ffmpeg_files/intreadwrite.h" #include "sub/sub.h" @@ -70,14 +79,6 @@ #include "qtpalette.h" #include "parse_mp4.h" // .MP4 specific stuff -#if CONFIG_ZLIB -#include -#endif - -#ifndef _FCNTL_H -#include -#endif - #define char2short(x,y) AV_RB16(&(x)[(y)]) #define char2int(x,y) AV_RB32(&(x)[(y)]) diff -Nru mplayer2-2.0-426-gc32b3ed/libmpdemux/demux_ogg.c mplayer2-2.0-554-gf63dbad/libmpdemux/demux_ogg.c --- mplayer2-2.0-426-gc32b3ed/libmpdemux/demux_ogg.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpdemux/demux_ogg.c 2012-05-17 14:38:00.000000000 +0000 @@ -25,13 +25,14 @@ #include #include +#include + #include "options.h" #include "mp_msg.h" #include "talloc.h" #include "stream/stream.h" #include "demuxer.h" #include "stheader.h" -#include "ffmpeg_files/intreadwrite.h" #include "aviprint.h" #include "demux_mov.h" #include "demux_ogg.h" diff -Nru mplayer2-2.0-426-gc32b3ed/libmpdemux/demux_real.c mplayer2-2.0-554-gf63dbad/libmpdemux/demux_real.c --- mplayer2-2.0-426-gc32b3ed/libmpdemux/demux_real.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpdemux/demux_real.c 2012-05-17 14:38:00.000000000 +0000 @@ -39,11 +39,12 @@ #include #include +#include +#include + #include "config.h" #include "mp_msg.h" #include "mpbswap.h" -#include "libavutil/common.h" -#include "ffmpeg_files/intreadwrite.h" #include "stream/stream.h" #include "aviprint.h" #include "demuxer.h" diff -Nru mplayer2-2.0-426-gc32b3ed/libmpdemux/demux_rtp_codec.cpp mplayer2-2.0-554-gf63dbad/libmpdemux/demux_rtp_codec.cpp --- mplayer2-2.0-426-gc32b3ed/libmpdemux/demux_rtp_codec.cpp 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpdemux/demux_rtp_codec.cpp 2012-05-17 14:38:00.000000000 +0000 @@ -135,7 +135,7 @@ int fooLen; const uint8_t* fooData; h264parserctx = av_parser_init(CODEC_ID_H264); - avcctx = avcodec_alloc_context(); + avcctx = avcodec_alloc_context3(NULL); // Pass the config to the parser h264parserctx->parser->parser_parse(h264parserctx, avcctx, &fooData, &fooLen, configData, configLen); diff -Nru mplayer2-2.0-426-gc32b3ed/libmpdemux/demux_ty.c mplayer2-2.0-554-gf63dbad/libmpdemux/demux_ty.c --- mplayer2-2.0-426-gc32b3ed/libmpdemux/demux_ty.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpdemux/demux_ty.c 2012-05-17 14:38:00.000000000 +0000 @@ -35,6 +35,9 @@ #include #include +#include +#include + #include "config.h" #include "mp_msg.h" @@ -47,8 +50,6 @@ #include "parse_es.h" #include "stheader.h" #include "sub/sub_cc.h" -#include "libavutil/avstring.h" -#include "ffmpeg_files/intreadwrite.h" extern int sub_justify; diff -Nru mplayer2-2.0-426-gc32b3ed/libmpdemux/demux_vqf.c mplayer2-2.0-554-gf63dbad/libmpdemux/demux_vqf.c --- mplayer2-2.0-426-gc32b3ed/libmpdemux/demux_vqf.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpdemux/demux_vqf.c 2012-05-17 14:38:00.000000000 +0000 @@ -20,9 +20,8 @@ #include #include -#include "libavutil/common.h" -#include "ffmpeg_files/intreadwrite.h" -#include "mpbswap.h" +#include +#include #include "stream/stream.h" #include "demuxer.h" diff -Nru mplayer2-2.0-426-gc32b3ed/libmpdemux/demuxer.c mplayer2-2.0-554-gf63dbad/libmpdemux/demuxer.c --- mplayer2-2.0-426-gc32b3ed/libmpdemux/demuxer.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpdemux/demuxer.c 2012-05-17 14:38:00.000000000 +0000 @@ -547,7 +547,7 @@ break; } if (codec_id != CODEC_ID_NONE) { - *avctx = avcodec_alloc_context(); + *avctx = avcodec_alloc_context3(NULL); if (!*avctx) return; *parser = av_parser_init(codec_id); @@ -831,11 +831,12 @@ return len; } -struct demux_packet *ds_get_packet2(struct demux_stream *ds) +struct demux_packet *ds_get_packet2(struct demux_stream *ds, bool repeat_last) { // This shouldn't get used together with partial reads - assert(ds->buffer_pos >= ds->buffer_size); - ds_fill_buffer(ds); + assert(ds->buffer_pos == 0 || ds->buffer_pos >= ds->buffer_size); + if (!repeat_last) + ds_fill_buffer(ds); ds->buffer_pos = ds->buffer_size; return ds->current; } diff -Nru mplayer2-2.0-426-gc32b3ed/libmpdemux/demuxer.h mplayer2-2.0-554-gf63dbad/libmpdemux/demuxer.h --- mplayer2-2.0-426-gc32b3ed/libmpdemux/demuxer.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpdemux/demuxer.h 2012-05-17 14:38:00.000000000 +0000 @@ -346,7 +346,7 @@ int ds_get_packet_pts(struct demux_stream *ds, unsigned char **start, double *pts); int ds_get_packet_sub(struct demux_stream *ds, unsigned char **start); -struct demux_packet *ds_get_packet2(struct demux_stream *ds); +struct demux_packet *ds_get_packet2(struct demux_stream *ds, bool repeat_last); double ds_get_next_pts(struct demux_stream *ds); int ds_parse(struct demux_stream *sh, uint8_t **buffer, int *len, double pts, off_t pos); diff -Nru mplayer2-2.0-426-gc32b3ed/libmpdemux/ebml.c mplayer2-2.0-554-gf63dbad/libmpdemux/ebml.c --- mplayer2-2.0-426-gc32b3ed/libmpdemux/ebml.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpdemux/ebml.c 2012-05-17 14:38:00.000000000 +0000 @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include "talloc.h" #include "ebml.h" @@ -191,11 +191,11 @@ len = ebml_read_length(s, &l); switch (len) { case 4: - value = av_int2flt(stream_read_dword(s)); + value = av_int2float(stream_read_dword(s)); break; case 8: - value = av_int2dbl(stream_read_qword(s)); + value = av_int2double(stream_read_qword(s)); break; default: @@ -382,9 +382,9 @@ assert(length == 4 || length == 8); uint64_t i = ebml_parse_uint(data, length); if (length == 4) - return av_int2flt(i); + return av_int2float(i); else - return av_int2dbl(i); + return av_int2double(i); } diff -Nru mplayer2-2.0-426-gc32b3ed/libmpdemux/mf.c mplayer2-2.0-554-gf63dbad/libmpdemux/mf.c --- mplayer2-2.0-426-gc32b3ed/libmpdemux/mf.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpdemux/mf.c 2012-05-17 14:38:00.000000000 +0000 @@ -25,7 +25,8 @@ #include #include #include -#include + +#include "osdep/io.h" #include "config.h" @@ -38,6 +39,7 @@ #include "mp_msg.h" #include "stream/stream.h" +#include "path.h" #include "mf.h" @@ -49,7 +51,6 @@ mf_t* open_mf(char * filename){ #if defined(HAVE_GLOB) || defined(__MINGW32__) glob_t gg; - struct stat fs; int i; char * fname; mf_t * mf; @@ -63,13 +64,13 @@ FILE *lst_f=fopen(filename + 1,"r"); if ( lst_f ) { - fname=malloc(PATH_MAX); - while ( fgets( fname,PATH_MAX,lst_f ) ) + fname=malloc(MP_PATH_MAX); + while ( fgets( fname,MP_PATH_MAX,lst_f ) ) { /* remove spaces from end of fname */ char *t=fname + strlen( fname ) - 1; while ( t > fname && isspace( *t ) ) *(t--)=0; - if ( stat( fname,&fs ) ) + if ( !mp_path_exists( fname ) ) { mp_msg( MSGT_STREAM,MSGL_V,"[mf] file not found: '%s'\n",fname ); } @@ -94,7 +95,7 @@ while ( ( fname=strsep( &filename,"," ) ) ) { - if ( stat( fname,&fs ) ) + if ( !mp_path_exists( fname ) ) { mp_msg( MSGT_STREAM,MSGL_V,"[mf] file not found: '%s'\n",fname ); } @@ -130,8 +131,8 @@ for( i=0;i < gg.gl_pathc;i++ ) { - stat( gg.gl_pathv[i],&fs ); - if( S_ISDIR( fs.st_mode ) ) continue; + if (mp_path_isdir(gg.gl_pathv[i])) + continue; mf->names[i]=strdup( gg.gl_pathv[i] ); // mp_msg( MSGT_STREAM,MSGL_DBG2,"[mf] added file %d.: %s\n",i,mf->names[i] ); } @@ -144,7 +145,7 @@ while ( error_count < 5 ) { sprintf( fname,filename,count++ ); - if ( stat( fname,&fs ) ) + if ( !mp_path_exists( fname ) ) { error_count++; mp_msg( MSGT_STREAM,MSGL_V,"[mf] file not found: '%s'\n",fname ); diff -Nru mplayer2-2.0-426-gc32b3ed/libmpdemux/mp_taglists.c mplayer2-2.0-554-gf63dbad/libmpdemux/mp_taglists.c --- mplayer2-2.0-426-gc32b3ed/libmpdemux/mp_taglists.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpdemux/mp_taglists.c 2012-05-17 14:38:00.000000000 +0000 @@ -16,16 +16,17 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "config.h" - -#include "libavformat/avformat.h" -#include +#include +#include "config.h" #include "mp_taglists.h" -#include "ffmpeg_files/taglists.c" +struct tag { + enum CodecID id; + unsigned int tag; +}; -static const struct mp_AVCodecTag mp_wav_tags[] = { +static const struct tag mp_wav_tags[] = { { CODEC_ID_ADPCM_4XM, MKTAG('4', 'X', 'M', 'A')}, { CODEC_ID_ADPCM_ADX, MKTAG('S', 'a', 'd', 'x')}, { CODEC_ID_ADPCM_EA, MKTAG('A', 'D', 'E', 'A')}, @@ -60,9 +61,7 @@ { 0, 0 }, }; -const struct mp_AVCodecTag * const mp_wav_taglists[] = {mp_ff_codec_wav_tags, mp_wav_tags, 0}; - -static const struct mp_AVCodecTag mp_codecid_override_tags[] = { +static const struct tag mp_codecid_override_tags[] = { { CODEC_ID_AAC, MKTAG('M', 'P', '4', 'A')}, { CODEC_ID_AAC_LATM, MKTAG('M', 'P', '4', 'L')}, { CODEC_ID_AC3, 0x2000}, @@ -89,9 +88,7 @@ { 0, 0 }, }; -const struct mp_AVCodecTag * const mp_codecid_override_taglists[] = {mp_codecid_override_tags, 0}; - -static const struct mp_AVCodecTag mp_bmp_tags[] = { +static const struct tag mp_bmp_tags[] = { { CODEC_ID_AMV, MKTAG('A', 'M', 'V', 'V')}, { CODEC_ID_ANM, MKTAG('A', 'N', 'M', ' ')}, { CODEC_ID_AVS, MKTAG('A', 'V', 'S', ' ')}, @@ -127,4 +124,35 @@ { 0, 0 }, }; -const struct mp_AVCodecTag * const mp_bmp_taglists[] = {mp_ff_codec_bmp_tags, mp_bmp_tags, 0}; +static unsigned int codec_get_tag(const struct tag *tags, enum CodecID id) +{ + while (tags->id != CODEC_ID_NONE) { + if (tags->id == id) + return tags->tag; + tags++; + } + return 0; +} + +unsigned int mp_taglist_override(enum CodecID id) +{ + return codec_get_tag(mp_codecid_override_tags, id); +} + +unsigned int mp_taglist_video(enum CodecID id) +{ + const struct AVCodecTag *tags[] = {avformat_get_riff_video_tags(), NULL }; + unsigned int tag = av_codec_get_tag(tags, id); + if (tag) + return tag; + return codec_get_tag(mp_bmp_tags, id); +} + +unsigned int mp_taglist_audio(enum CodecID id) +{ + const struct AVCodecTag *tags[] = {avformat_get_riff_audio_tags(), NULL }; + unsigned int tag = av_codec_get_tag(tags, id); + if (tag) + return tag; + return codec_get_tag(mp_wav_tags, id); +} diff -Nru mplayer2-2.0-426-gc32b3ed/libmpdemux/mp_taglists.h mplayer2-2.0-554-gf63dbad/libmpdemux/mp_taglists.h --- mplayer2-2.0-426-gc32b3ed/libmpdemux/mp_taglists.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libmpdemux/mp_taglists.h 2012-05-17 14:38:00.000000000 +0000 @@ -21,12 +21,8 @@ #include -#include "ffmpeg_files/taglists.h" - -extern const struct mp_AVCodecTag * const mp_wav_taglists[]; - -extern const struct mp_AVCodecTag * const mp_codecid_override_taglists[]; - -extern const struct mp_AVCodecTag * const mp_bmp_taglists[]; +unsigned int mp_taglist_override(enum CodecID id); +unsigned int mp_taglist_video(enum CodecID id); +unsigned int mp_taglist_audio(enum CodecID id); #endif /* MPLAYER_MP_TAGLISTS_H */ diff -Nru mplayer2-2.0-426-gc32b3ed/libvo/cocoa_common.h mplayer2-2.0-554-gf63dbad/libvo/cocoa_common.h --- mplayer2-2.0-426-gc32b3ed/libvo/cocoa_common.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libvo/cocoa_common.h 2012-05-17 14:38:00.000000000 +0000 @@ -1,8 +1,30 @@ +/* + * Cocoa OpenGL Backend + * + * This file is part of mplayer2. + * + * mplayer2 is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * mplayer2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with mplayer2. If not, see . + */ + #ifndef MPLAYER_COCOA_COMMON_H #define MPLAYER_COCOA_COMMON_H #include "video_out.h" +bool vo_cocoa_gui_running(void); +void *vo_cocoa_glgetaddr(const char *s); + int vo_cocoa_init(struct vo *vo); void vo_cocoa_uninit(struct vo *vo); @@ -15,8 +37,12 @@ void vo_cocoa_swap_buffers(void); int vo_cocoa_check_events(struct vo *vo); void vo_cocoa_fullscreen(struct vo *vo); +void vo_cocoa_ontop(struct vo *vo); // returns an int to conform to the gl extensions from other platforms int vo_cocoa_swap_interval(int enabled); +void *vo_cocoa_cgl_context(void); +void *vo_cocoa_cgl_pixel_format(void); + #endif /* MPLAYER_COCOA_COMMON_H */ diff -Nru mplayer2-2.0-426-gc32b3ed/libvo/cocoa_common.m mplayer2-2.0-554-gf63dbad/libvo/cocoa_common.m --- mplayer2-2.0-426-gc32b3ed/libvo/cocoa_common.m 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libvo/cocoa_common.m 2012-05-17 14:38:00.000000000 +0000 @@ -1,7 +1,28 @@ +/* + * Cocoa OpenGL Backend + * + * This file is part of mplayer2. + * + * mplayer2 is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * mplayer2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with mplayer2. If not, see . + */ + #import #import #import #import // for CGDisplayHideCursor +#include + #include "cocoa_common.h" #include "options.h" @@ -35,6 +56,7 @@ NSAutoreleasePool *pool; GLMPlayerWindow *window; NSOpenGLContext *glContext; + NSOpenGLPixelFormat *pixelFormat; NSSize current_video_size; NSSize previous_video_size; @@ -50,8 +72,15 @@ NSString *window_title; + NSInteger windowed_window_level; + NSInteger fullscreen_window_level; + int last_screensaver_update; + int display_cursor; + int cursor_timer; + int cursor_autohide_delay; + bool did_resize; bool out_fs_resize; }; @@ -62,8 +91,10 @@ // local function definitions struct vo_cocoa_state *vo_cocoa_init_state(void); +void vo_set_level(int ontop); void update_screen_info(void); void resize_window(struct vo *vo); +void vo_cocoa_display_cursor(int requested_state); void create_menu(void); struct vo_cocoa_state *vo_cocoa_init_state(void) @@ -75,16 +106,37 @@ .previous_video_size = {0,0}, .windowed_mask = NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask, .fullscreen_mask = NSBorderlessWindowMask, + .fullscreen_window_level = NSNormalWindowLevel + 1, .windowed_frame = {{0,0},{0,0}}, .out_fs_resize = NO, + .display_cursor = 1, }; return s; } +bool vo_cocoa_gui_running(void) +{ + return !!s; +} + +void *vo_cocoa_glgetaddr(const char *s) +{ + void *ret = NULL; + void *handle = dlopen( + "/System/Library/Frameworks/OpenGL.framework/OpenGL", + RTLD_LAZY | RTLD_LOCAL); + if (!handle) + return NULL; + ret = dlsym(handle, s); + dlclose(handle); + return ret; +} + int vo_cocoa_init(struct vo *vo) { s = vo_cocoa_init_state(); s->pool = [[NSAutoreleasePool alloc] init]; + s->cursor_autohide_delay = vo->opts->cursor_autohide_delay; NSApplicationLoad(); NSApp = [NSApplication sharedApplication]; [NSApp setActivationPolicy: NSApplicationActivationPolicyRegular]; @@ -95,6 +147,8 @@ void vo_cocoa_uninit(struct vo *vo) { CGDisplayShowCursor(kCGDirectMainDisplay); + [NSApp setPresentationOptions:NSApplicationPresentationDefault]; + [s->window release]; s->window = nil; [s->glContext release]; @@ -103,6 +157,7 @@ s->pool = nil; talloc_free(s); + s = nil; } void update_screen_info(void) @@ -141,9 +196,29 @@ [s->glContext update]; } +void vo_set_level(int ontop) +{ + if (ontop) { + s->windowed_window_level = NSNormalWindowLevel + 1; + } else { + s->windowed_window_level = NSNormalWindowLevel; + } + + if (!vo_fs) + [s->window setLevel:s->windowed_window_level]; +} + +void vo_cocoa_ontop(struct vo *vo) +{ + struct MPOpts *opts = vo->opts; + opts->vo_ontop = !opts->vo_ontop; + vo_set_level(opts->vo_ontop); +} + int vo_cocoa_create_window(struct vo *vo, uint32_t d_width, uint32_t d_height, uint32_t flags) { + struct MPOpts *opts = vo->opts; if (s->current_video_size.width > 0 || s->current_video_size.height > 0) s->previous_video_size = s->current_video_size; s->current_video_size = NSMakeSize(d_width, d_height); @@ -161,8 +236,8 @@ (NSOpenGLPixelFormatAttribute)0 }; - NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs]; - s->glContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil]; + s->pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attrs] autorelease]; + s->glContext = [[NSOpenGLContext alloc] initWithFormat:s->pixelFormat shareContext:nil]; create_menu(); @@ -187,6 +262,8 @@ if (flags & VOFLAG_FULLSCREEN) vo_cocoa_fullscreen(vo); + + vo_set_level(opts->vo_ontop); } else { if (s->current_video_size.width != s->previous_video_size.width || s->current_video_size.height != s->previous_video_size.height) { @@ -218,18 +295,42 @@ [s->glContext flushBuffer]; } +void vo_cocoa_display_cursor(int requested_state) +{ + if (requested_state) { + if (!vo_fs || s->cursor_autohide_delay > -2) { + s->display_cursor = requested_state; + CGDisplayShowCursor(kCGDirectMainDisplay); + } + } else { + if (s->cursor_autohide_delay != -1) { + s->display_cursor = requested_state; + CGDisplayHideCursor(kCGDirectMainDisplay); + } + } +} + int vo_cocoa_check_events(struct vo *vo) { + NSEvent *event; + float curTime = TickCount()/60; + int msCurTime = (int) (curTime * 1000); + + // automatically hide mouse cursor + if (vo_fs && s->display_cursor && + (msCurTime - s->cursor_timer >= s->cursor_autohide_delay)) { + vo_cocoa_display_cursor(0); + s->cursor_timer = msCurTime; + } + //update activity every 30 seconds to prevent //screensaver from starting up. - int curTime = TickCount()/60; - if (curTime - s->last_screensaver_update >= 30 || s->last_screensaver_update == 0) + if ((int)curTime - s->last_screensaver_update >= 30 || s->last_screensaver_update == 0) { UpdateSystemActivity(UsrActivity); - s->last_screensaver_update = curTime; + s->last_screensaver_update = (int)curTime; } - NSEvent *event; event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:nil inMode:NSEventTrackingRunLoopMode dequeue:YES]; if (event == nil) @@ -268,6 +369,16 @@ return 0; } +void *vo_cocoa_cgl_context(void) +{ + return [s->glContext CGLContextObj]; +} + +void *vo_cocoa_cgl_pixel_format(void) +{ + return [s->pixelFormat CGLPixelFormatObj]; +} + void create_menu() { NSMenu *menu; @@ -302,14 +413,16 @@ - (void) fullscreen { if (!vo_fs) { + update_screen_info(); [NSApp setPresentationOptions:NSApplicationPresentationHideDock|NSApplicationPresentationHideMenuBar]; s->windowed_frame = [self frame]; [self setHasShadow:NO]; [self setStyleMask:s->fullscreen_mask]; [self setFrame:s->screen_frame display:YES animate:NO]; - [self setLevel:NSNormalWindowLevel + 1]; - CGDisplayHideCursor(kCGDirectMainDisplay); + [self setLevel:s->fullscreen_window_level]; vo_fs = VO_TRUE; + vo_cocoa_display_cursor(0); + [self setMovableByWindowBackground: NO]; } else { [NSApp setPresentationOptions:NSApplicationPresentationDefault]; [self setHasShadow:YES]; @@ -321,9 +434,10 @@ s->out_fs_resize = NO; } [self setContentAspectRatio:s->current_video_size]; - [self setLevel:NSNormalWindowLevel]; - CGDisplayShowCursor(kCGDirectMainDisplay); + [self setLevel:s->windowed_window_level]; vo_fs = VO_FALSE; + vo_cocoa_display_cursor(1); + [self setMovableByWindowBackground: YES]; } } @@ -341,6 +455,12 @@ return NO; } +- (BOOL) isMovableByWindowBackground +{ + // this is only valid as a starting value. it will be rewritten in the -fullscreen method. + return !vo_fs; +} + - (void) handleQuitEvent:(NSAppleEventDescriptor*)e withReplyEvent:(NSAppleEventDescriptor*)r { mplayer_put_key(l_vo->key_fifo, KEY_CLOSE_WIN); @@ -369,6 +489,12 @@ } } +- (void) mouseMoved: (NSEvent *) theEvent +{ + if (vo_fs) + vo_cocoa_display_cursor(1); +} + - (void) mouseDragged:(NSEvent *)theEvent { [self mouseEvent: theEvent]; @@ -414,23 +540,23 @@ - (void) mouseEvent:(NSEvent *)theEvent { - if ( [theEvent buttonNumber] >= 0 && [theEvent buttonNumber] <= 9 ) - { + if ([theEvent buttonNumber] >= 0 && [theEvent buttonNumber] <= 9) { int buttonNumber = [theEvent buttonNumber]; // Fix to mplayer defined button order: left, middle, right - if (buttonNumber == 1) - buttonNumber = 2; - else if (buttonNumber == 2) - buttonNumber = 1; + if (buttonNumber == 1) buttonNumber = 2; + else if (buttonNumber == 2) buttonNumber = 1; switch ([theEvent type]) { case NSLeftMouseDown: - break; case NSRightMouseDown: case NSOtherMouseDown: mplayer_put_key(l_vo->key_fifo, (MOUSE_BTN0 + buttonNumber) | MP_KEY_DOWN); + // Looks like Cocoa doesn't create MouseUp events when we are + // doing the second click in a double click. Put in the key_fifo + // the key that would be put from the MouseUp handling code. + if([theEvent clickCount] == 2) + mplayer_put_key(l_vo->key_fifo, MOUSE_BTN0 + buttonNumber); break; case NSLeftMouseUp: - break; case NSRightMouseUp: case NSOtherMouseUp: mplayer_put_key(l_vo->key_fifo, MOUSE_BTN0 + buttonNumber); @@ -442,18 +568,19 @@ - (void) applicationWillBecomeActive:(NSNotification *)aNotification { if (vo_fs) { - [s->window setLevel:NSNormalWindowLevel + 1]; - [NSApp setPresentationOptions:NSApplicationPresentationHideDock|NSApplicationPresentationHideMenuBar]; - [s->window makeKeyAndOrderFront:nil]; - [NSApp activateIgnoringOtherApps: YES]; + [s->window makeKeyAndOrderFront:s->window]; + [s->window setLevel:s->fullscreen_window_level]; + [NSApp setPresentationOptions:NSApplicationPresentationHideDock| + NSApplicationPresentationHideMenuBar]; } } - (void) applicationWillResignActive:(NSNotification *)aNotification { if (vo_fs) { - [s->window setLevel:NSNormalWindowLevel]; [NSApp setPresentationOptions:NSApplicationPresentationDefault]; + [s->window setLevel:s->windowed_window_level]; + [s->window orderBack:s->window]; } } diff -Nru mplayer2-2.0-426-gc32b3ed/libvo/csputils.c mplayer2-2.0-554-gf63dbad/libvo/csputils.c --- mplayer2-2.0-426-gc32b3ed/libvo/csputils.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libvo/csputils.c 2012-05-17 14:38:00.000000000 +0000 @@ -143,10 +143,13 @@ int levels_in = params->colorspace.levels_in; if (levels_in <= MP_CSP_LEVELS_AUTO || levels_in >= MP_CSP_LEVELS_COUNT) levels_in = MP_CSP_LEVELS_TV; + assert(params->input_bits >= 8); + assert(params->texture_bits >= params->input_bits); + double s = (1 << params->input_bits-8) / ((1<texture_bits)-1.); // The values below are written in 0-255 scale struct yuvlevels { double ymin, ymax, cmin, cmid; } - yuvlim = { 16, 235, 16, 128 }, - yuvfull = { 0, 255, 1, 128 }, // '1' to make it symmetric around 128 + yuvlim = { 16*s, 235*s, 16*s, 128*s }, + yuvfull = { 0*s, 255*s, 1*s, 128*s }, // '1' for symmetry around 128 yuvlev; switch (levels_in) { case MP_CSP_LEVELS_TV: yuvlev = yuvlim; break; @@ -159,8 +162,8 @@ if (levels_out <= MP_CSP_LEVELS_AUTO || levels_out >= MP_CSP_LEVELS_COUNT) levels_out = MP_CSP_LEVELS_PC; struct rgblevels { double min, max; } - rgblim = { 16, 235 }, - rgbfull = { 0, 255 }, + rgblim = { 16/255., 235/255. }, + rgbfull = { 0, 1 }, rgblev; switch (levels_out) { case MP_CSP_LEVELS_TV: rgblev = rgblim; break; @@ -176,8 +179,8 @@ m[i][COL_U] *= cmul; m[i][COL_V] *= cmul; // Set COL_C so that Y=umin,UV=cmid maps to RGB=min (black to black) - m[i][COL_C] = (rgblev.min - m[i][COL_Y] * yuvlev.ymin - -(m[i][COL_U] + m[i][COL_V]) * yuvlev.cmid) / 255; + m[i][COL_C] = rgblev.min - m[i][COL_Y] * yuvlev.ymin + -(m[i][COL_U] + m[i][COL_V]) * yuvlev.cmid; } // Brightness adds a constant to output R,G,B. @@ -185,15 +188,8 @@ for (int i = 0; i < 3; i++) { m[i][COL_C] += params->brightness; m[i][COL_Y] *= params->contrast; - m[i][COL_C] += (rgblev.max-rgblev.min)/255 * (1 - params->contrast)/2; + m[i][COL_C] += (rgblev.max-rgblev.min) * (1 - params->contrast)/2; } - - float depth_multiplier = params->input_shift >= 0 ? - (1 << params->input_shift) : - (1.0 / (1 << -params->input_shift)); - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) - m[i][j] *= depth_multiplier; } //! size of gamma map use to avoid slow exp function in gen_yuv2rgb_map diff -Nru mplayer2-2.0-426-gc32b3ed/libvo/csputils.h mplayer2-2.0-554-gf63dbad/libvo/csputils.h --- mplayer2-2.0-426-gc32b3ed/libvo/csputils.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libvo/csputils.h 2012-05-17 14:38:00.000000000 +0000 @@ -68,7 +68,8 @@ float rgamma; float ggamma; float bgamma; - int input_shift; + int texture_bits; + int input_bits; }; enum mp_csp_equalizer_param { diff -Nru mplayer2-2.0-426-gc32b3ed/libvo/gl_common.c mplayer2-2.0-554-gf63dbad/libvo/gl_common.c --- mplayer2-2.0-426-gc32b3ed/libvo/gl_common.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libvo/gl_common.c 2012-05-17 14:38:00.000000000 +0000 @@ -350,6 +350,7 @@ DEF_FUNC_DESC(TexParameterf), DEF_FUNC_DESC(TexParameterfv), DEF_FUNC_DESC(TexCoord2f), + DEF_FUNC_DESC(TexCoord2fv), DEF_FUNC_DESC(Vertex2f), DEF_FUNC_DESC(Vertex3f), DEF_FUNC_DESC(Normal3f), @@ -595,6 +596,9 @@ return 4 * component_size; case GL_RED: return component_size; + case GL_RG: + case GL_LUMINANCE_ALPHA: + return 2 * component_size; } return 0; // unknown } @@ -1624,7 +1628,7 @@ static int setGlWindow_cocoa(MPGLContext *ctx) { vo_cocoa_change_attributes(ctx->vo); - getFunctions(ctx->gl, (void *)getdladdr, NULL); + getFunctions(ctx->gl, (void *)vo_cocoa_glgetaddr, NULL); if (!ctx->gl->SwapInterval) ctx->gl->SwapInterval = vo_cocoa_swap_interval; return SET_WINDOW_OK; @@ -2049,6 +2053,7 @@ ctx->check_events = cocoa_check_events; ctx->update_xinerama_info = cocoa_update_xinerama_info; ctx->fullscreen = cocoa_fullscreen; + ctx->ontop = vo_cocoa_ontop; if (vo_cocoa_init(vo)) return ctx; break; diff -Nru mplayer2-2.0-426-gc32b3ed/libvo/gl_common.h mplayer2-2.0-554-gf63dbad/libvo/gl_common.h --- mplayer2-2.0-426-gc32b3ed/libvo/gl_common.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libvo/gl_common.h 2012-05-17 14:38:00.000000000 +0000 @@ -452,6 +452,7 @@ void (GLAPIENTRY *TexParameterf)(GLenum, GLenum, GLfloat); void (GLAPIENTRY *TexParameterfv)(GLenum, GLenum, const GLfloat *); void (GLAPIENTRY *TexCoord2f)(GLfloat, GLfloat); + void (GLAPIENTRY *TexCoord2fv)(const GLfloat *); void (GLAPIENTRY *Vertex2f)(GLfloat, GLfloat); void (GLAPIENTRY *Vertex3f)(GLfloat, GLfloat, GLfloat); void (GLAPIENTRY *Normal3f)(GLfloat, GLfloat, GLfloat); diff -Nru mplayer2-2.0-426-gc32b3ed/libvo/video_out.c mplayer2-2.0-554-gf63dbad/libvo/video_out.c --- mplayer2-2.0-426-gc32b3ed/libvo/video_out.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libvo/video_out.c 2012-05-17 14:38:00.000000000 +0000 @@ -117,7 +117,7 @@ extern struct vo_driver video_out_xvr100; extern struct vo_driver video_out_tga; extern struct vo_driver video_out_corevideo; -extern struct vo_driver video_out_quartz; +extern struct vo_driver video_out_sharedbuffer; extern struct vo_driver video_out_pnm; extern struct vo_driver video_out_md5sum; @@ -138,12 +138,12 @@ #ifdef CONFIG_KVA &video_out_kva, #endif +#ifdef CONFIG_GL_COCOA + &video_out_gl, +#endif #ifdef CONFIG_COREVIDEO &video_out_corevideo, #endif -#ifdef CONFIG_QUARTZ - &video_out_quartz, -#endif #ifdef CONFIG_XMGA &video_out_xmga, #endif @@ -178,9 +178,12 @@ #ifdef CONFIG_SDL &video_out_sdl, #endif -#ifdef CONFIG_GL +#if (defined CONFIG_GL && !defined CONFIG_GL_COCOA) &video_out_gl, #endif +#ifdef CONFIG_SHAREDBUFFER + &video_out_sharedbuffer, +#endif #ifdef CONFIG_GL_SDL &video_out_gl_sdl, #endif @@ -285,7 +288,7 @@ int vo_redraw_frame(struct vo *vo) { - if (!vo->config_ok) + if (!vo->config_ok || !vo->hasframe) return -1; if (vo_control(vo, VOCTRL_REDRAW_FRAME, NULL) == true) { vo->redrawing = true; @@ -358,6 +361,7 @@ vo->driver->flip_page_timed(vo, pts_us, duration); else vo->driver->flip_page(vo); + vo->hasframe = true; } void vo_check_events(struct vo *vo) @@ -375,6 +379,7 @@ { vo_control(vo, VOCTRL_RESET, NULL); vo->frame_loaded = false; + vo->hasframe = false; } void vo_destroy(struct vo *vo) @@ -500,6 +505,7 @@ vo->frame_loaded = false; vo->waiting_mpi = NULL; vo->redrawing = false; + vo->hasframe = false; return ret; } diff -Nru mplayer2-2.0-426-gc32b3ed/libvo/video_out.h mplayer2-2.0-554-gf63dbad/libvo/video_out.h --- mplayer2-2.0-426-gc32b3ed/libvo/video_out.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libvo/video_out.h 2012-05-17 14:38:00.000000000 +0000 @@ -265,6 +265,7 @@ double next_pts2; // optional pts of frame after that bool want_redraw; // visible frame wrong (window resize), needs refresh bool redrawing; // between redrawing frame and flipping it + bool hasframe; // >= 1 frame has been drawn, so redraw is possible double flip_queue_offset; // queue flip events at most this much in advance @@ -377,7 +378,6 @@ void calc_src_dst_rects(struct vo *vo, int src_width, int src_height, struct vo_rect *src, struct vo_rect *dst, struct vo_rect *borders, const struct vo_rect *crop); -struct input_ctx; void vo_mouse_movement(struct vo *vo, int posx, int posy); static inline int aspect_scaling(void) diff -Nru mplayer2-2.0-426-gc32b3ed/libvo/vo_corevideo.h mplayer2-2.0-554-gf63dbad/libvo/vo_corevideo.h --- mplayer2-2.0-426-gc32b3ed/libvo/vo_corevideo.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libvo/vo_corevideo.h 2012-05-17 14:38:00.000000000 +0000 @@ -23,93 +23,6 @@ #ifndef MPLAYER_VO_COREVIDEO_H #define MPLAYER_VO_COREVIDEO_H -#import #import -#import - -// MPlayer OS X VO Protocol -@protocol MPlayerOSXVOProto -- (int) startWithWidth: (bycopy int)width - withHeight: (bycopy int)height - withBytes: (bycopy int)bytes - withAspect: (bycopy int)aspect; -- (void) stop; -- (void) render; -- (void) toggleFullscreen; -- (void) ontop; -@end - -@interface MPlayerOpenGLView : NSOpenGLView -{ - //Cocoa - NSWindow *window; - - //CoreVideo - CVPixelBufferRef frameBuffers[2]; - CVOpenGLTextureCacheRef textureCache; - CVOpenGLTextureRef texture; - NSRect textureFrame; - - GLfloat lowerLeft[2]; - GLfloat lowerRight[2]; - GLfloat upperRight[2]; - GLfloat upperLeft[2]; - - BOOL mouseHide; - - //menu command id - NSMenuItem *kHalfScreenCmd; - NSMenuItem *kNormalScreenCmd; - NSMenuItem *kDoubleScreenCmd; - NSMenuItem *kFullScreenCmd; - NSMenuItem *kKeepAspectCmd; - NSMenuItem *kAspectOrgCmd; - NSMenuItem *kAspectFullCmd; - NSMenuItem *kAspectWideCmd; - NSMenuItem *kPanScanCmd; - - //timestamps for disabling screensaver and mouse hiding - int lastMouseHide; - int lastScreensaverUpdate; -@public - float winSizeMult; -} - -- (BOOL) acceptsFirstResponder; -- (BOOL) becomeFirstResponder; -- (BOOL) resignFirstResponder; - -//window & rendering -- (void) preinit; -- (void) config; -- (void) prepareOpenGL; -- (void) render; -- (void) reshape; -- (void) setCurrentTexture; -- (void) drawRect: (NSRect *) bounds; - -//vo control -- (void) fullscreen: (BOOL) animate; -- (void) ontop; -- (void) panscan; -- (void) rootwin; - -//menu -- (void) initMenu; -- (void) menuAction:(id)sender; - -//event -- (void) keyDown: (NSEvent *) theEvent; -- (void) mouseMoved: (NSEvent *) theEvent; -- (void) mouseDown: (NSEvent *) theEvent; -- (void) mouseUp: (NSEvent *) theEvent; -- (void) rightMouseDown: (NSEvent *) theEvent; -- (void) rightMouseUp: (NSEvent *) theEvent; -- (void) otherMouseDown: (NSEvent *) theEvent; -- (void) otherMouseUp: (NSEvent *) theEvent; -- (void) scrollWheel: (NSEvent *) theEvent; -- (void) mouseEvent: (NSEvent *) theEvent; -- (void) check_events; -@end #endif /* MPLAYER_VO_COREVIDEO_H */ diff -Nru mplayer2-2.0-426-gc32b3ed/libvo/vo_corevideo.m mplayer2-2.0-554-gf63dbad/libvo/vo_corevideo.m --- mplayer2-2.0-426-gc32b3ed/libvo/vo_corevideo.m 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libvo/vo_corevideo.m 2012-05-17 14:38:00.000000000 +0000 @@ -20,1057 +20,448 @@ */ #import "vo_corevideo.h" -#include -#include -#include -#include -#include -//special workaround for Apple bug #6267445 -//(OSServices Power API disabled in OSServices.h for 64bit systems) -#ifndef __POWER__ -#include -#endif - -//MPLAYER -#include "config.h" -#include "fastmemcpy.h" -#include "video_out.h" -#include "video_out_internal.h" -#include "aspect.h" -#include "mp_msg.h" -#include "m_option.h" -#include "mp_fifo.h" -#include "sub/sub.h" -#include "subopt-helper.h" - -#include "input/input.h" -#include "input/keycodes.h" -#include "osx_common.h" - -//Cocoa -NSDistantObject *mplayerosxProxy; -id mplayerosxProto; -MPlayerOpenGLView *mpGLView; -NSAutoreleasePool *autoreleasepool; -OSType pixelFormat; - -//shared memory -BOOL shared_buffer = false; -#define DEFAULT_BUFFER_NAME "mplayerosx" -static char *buffer_name; - -//Screen -int screen_id = -1; -NSRect screen_frame; -NSScreen *screen_handle; -NSArray *screen_array; - -//image -unsigned char *image_data; -// For double buffering -static uint8_t image_page = 0; -static unsigned char *image_datas[2]; - -static uint32_t image_width; -static uint32_t image_height; -static uint32_t image_depth; -static uint32_t image_bytes; -static uint32_t image_format; - -//vo -static int isFullscreen; -static int isOntop; -static int isRootwin; - -static float winAlpha = 1; -static int int_pause = 0; -static BOOL isLeopardOrLater; +// mplayer includes +#import "fastmemcpy.h" +#import "talloc.h" +#import "video_out.h" +#import "aspect.h" +#import "sub/font_load.h" +#import "sub/sub.h" +#import "subopt-helper.h" + +#import "csputils.h" +#import "libmpcodecs/vfcap.h" +#import "libmpcodecs/mp_image.h" +#import "osd.h" + +#import "gl_common.h" +#import "cocoa_common.h" + +struct quad { + GLfloat lowerLeft[2]; + GLfloat lowerRight[2]; + GLfloat upperRight[2]; + GLfloat upperLeft[2]; +}; -#define NSLeftAlternateKeyMask (0x000020 | NSAlternateKeyMask) -#define NSRightAlternateKeyMask (0x000040 | NSAlternateKeyMask) +#define CV_VERTICES_PER_QUAD 6 +#define CV_MAX_OSD_PARTS 20 -static vo_info_t info = -{ - "Mac OS X Core Video", - "corevideo", - "Nicolas Plourde ", - "" +struct osd_p { + GLuint tex[CV_MAX_OSD_PARTS]; + NSRect tex_rect[CV_MAX_OSD_PARTS]; + int tex_cnt; }; -LIBVO_EXTERN(corevideo) +struct priv { + MPGLContext *mpglctx; + OSType pixelFormat; + unsigned int image_width; + unsigned int image_height; + struct mp_csp_details colorspace; + + CVPixelBufferRef pixelBuffer; + CVOpenGLTextureCacheRef textureCache; + CVOpenGLTextureRef texture; + struct quad *quad; -static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, unsigned char *srca, int stride) -{ - switch (image_format) - { - case IMGFMT_RGB24: - vo_draw_alpha_rgb24(w,h,src,srca,stride,image_data+3*(y0*image_width+x0),3*image_width); - break; - case IMGFMT_ARGB: - case IMGFMT_BGRA: - vo_draw_alpha_rgb32(w,h,src,srca,stride,image_data+4*(y0*image_width+x0),4*image_width); - break; - case IMGFMT_YUY2: - vo_draw_alpha_yuy2(w,h,src,srca,stride,image_data + (x0 + y0 * image_width) * 2,image_width*2); - break; - } -} - -static void update_screen_info(void) -{ - if (screen_id == -1 && xinerama_screen > -1) - screen_id = xinerama_screen; + struct osd_p *osd; +}; - screen_array = [NSScreen screens]; - if(screen_id >= (int)[screen_array count]) - { - mp_msg(MSGT_VO, MSGL_INFO, "[vo_corevideo] Device ID %d does not exist, falling back to main device\n", screen_id); - screen_id = -1; - } - if (screen_id < 0 && [mpGLView window]) - screen_handle = [[mpGLView window] screen]; - else - screen_handle = [screen_array objectAtIndex:(screen_id < 0 ? 0 : screen_id)]; - - screen_frame = [screen_handle frame]; - vo_screenwidth = screen_frame.size.width; - vo_screenheight = screen_frame.size.height; - xinerama_x = xinerama_y = 0; - aspect_save_screenres(vo_screenwidth, vo_screenheight); -} +static struct priv *p; -static void free_file_specific(void) +static void resize(struct vo *vo, int width, int height) { - if(shared_buffer) - { - [mplayerosxProto stop]; - mplayerosxProto = nil; - [mplayerosxProxy release]; - mplayerosxProxy = nil; - - if (munmap(image_data, image_width*image_height*image_bytes) == -1) - mp_msg(MSGT_VO, MSGL_FATAL, "[vo_corevideo] uninit: munmap failed. Error: %s\n", strerror(errno)); - - if (shm_unlink(buffer_name) == -1) - mp_msg(MSGT_VO, MSGL_FATAL, "[vo_corevideo] uninit: shm_unlink failed. Error: %s\n", strerror(errno)); - } else { - free(image_datas[0]); - if (vo_doublebuffering) - free(image_datas[1]); - image_datas[0] = NULL; - image_datas[1] = NULL; - image_data = NULL; + GL *gl = p->mpglctx->gl; + p->image_width = width; + p->image_height = height; + + mp_msg(MSGT_VO, MSGL_V, "[vo_corevideo] New OpenGL Viewport (0, 0, %d, " + "%d)\n", p->image_width, p->image_height); + + gl->Viewport(0, 0, p->image_width, p->image_height); + gl->MatrixMode(GL_PROJECTION); + gl->LoadIdentity(); + + if (aspect_scaling()) { + int new_w, new_h; + GLdouble scale_x, scale_y; + + aspect(vo, &new_w, &new_h, A_WINZOOM); + panscan_calc_windowed(vo); + new_w += vo->panscan_x; + new_h += vo->panscan_y; + scale_x = (GLdouble)new_w / (GLdouble)p->image_width; + scale_y = (GLdouble)new_h / (GLdouble)p->image_height; + gl->Scaled(scale_x, scale_y, 1); } -} -static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) -{ - free_file_specific(); + gl->Ortho(0, p->image_width, p->image_height, 0, -1.0, 1.0); + gl->MatrixMode(GL_MODELVIEW); + gl->LoadIdentity(); - //misc mplayer setup - image_width = width; - image_height = height; - switch (image_format) - { - case IMGFMT_RGB24: - image_depth = 24; - break; - case IMGFMT_ARGB: - case IMGFMT_BGRA: - image_depth = 32; - break; - case IMGFMT_YUY2: - image_depth = 16; - break; - } - image_bytes = (image_depth + 7) / 8; - - if(!shared_buffer) - { - config_movie_aspect((float)d_width/d_height); - - vo_dwidth = d_width *= mpGLView->winSizeMult; - vo_dheight = d_height *= mpGLView->winSizeMult; - - image_data = malloc(image_width*image_height*image_bytes); - image_datas[0] = image_data; - if (vo_doublebuffering) - image_datas[1] = malloc(image_width*image_height*image_bytes); - image_page = 0; - - vo_fs = flags & VOFLAG_FULLSCREEN; - - //config OpenGL View - [mpGLView config]; - [mpGLView reshape]; - } - else - { - int shm_fd; - mp_msg(MSGT_VO, MSGL_INFO, "[vo_corevideo] writing output to a shared buffer " - "named \"%s\"\n",buffer_name); - - // create shared memory - shm_fd = shm_open(buffer_name, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR); - if (shm_fd == -1) - { - mp_msg(MSGT_VO, MSGL_FATAL, - "[vo_corevideo] failed to open shared memory. Error: %s\n", strerror(errno)); - return 1; - } - - - if (ftruncate(shm_fd, image_width*image_height*image_bytes) == -1) - { - mp_msg(MSGT_VO, MSGL_FATAL, - "[vo_corevideo] failed to size shared memory, possibly already in use. Error: %s\n", strerror(errno)); - close(shm_fd); - shm_unlink(buffer_name); - return 1; - } - - image_data = mmap(NULL, image_width*image_height*image_bytes, - PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, 0); - close(shm_fd); - - if (image_data == MAP_FAILED) - { - mp_msg(MSGT_VO, MSGL_FATAL, - "[vo_corevideo] failed to map shared memory. Error: %s\n", strerror(errno)); - shm_unlink(buffer_name); - return 1; - } - - //connect to mplayerosx - mplayerosxProxy=[NSConnection rootProxyForConnectionWithRegisteredName:[NSString stringWithCString:buffer_name] host:nil]; - if ([mplayerosxProxy conformsToProtocol:@protocol(MPlayerOSXVOProto)]) { - [mplayerosxProxy setProtocolForProxy:@protocol(MPlayerOSXVOProto)]; - mplayerosxProto = (id )mplayerosxProxy; - [mplayerosxProto startWithWidth: image_width withHeight: image_height withBytes: image_bytes withAspect:d_width*100/d_height]; - } - else { - [mplayerosxProxy release]; - mplayerosxProxy = nil; - mplayerosxProto = nil; - } - } - return 0; -} + force_load_font = 1; + vo_osd_changed(OSDTYPE_OSD); -static void check_events(void) -{ - if (mpGLView) - [mpGLView check_events]; + gl->Clear(GL_COLOR_BUFFER_BIT); + vo->want_redraw = true; } -static void draw_osd(void) +static int init_gl(struct vo *vo, uint32_t d_width, uint32_t d_height) { - vo_draw_text(image_width, image_height, draw_alpha); -} + GL *gl = p->mpglctx->gl; -static void flip_page(void) -{ - if(shared_buffer) { - NSAutoreleasePool *pool = [NSAutoreleasePool new]; - [mplayerosxProto render]; - [pool release]; - } else { - [mpGLView setCurrentTexture]; - [mpGLView render]; - if (vo_doublebuffering) { - image_page = 1 - image_page; - image_data = image_datas[image_page]; - } - } -} + const char *vendor = gl->GetString(GL_VENDOR); + const char *version = gl->GetString(GL_VERSION); + const char *renderer = gl->GetString(GL_RENDERER); -static int draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y) -{ - return 0; -} + mp_msg(MSGT_VO, MSGL_V, "[vo_corevideo] Running on OpenGL '%s' by '%s'," + " version '%s'\n", renderer, vendor, version); + gl->Disable(GL_BLEND); + gl->Disable(GL_DEPTH_TEST); + gl->DepthMask(GL_FALSE); + gl->Disable(GL_CULL_FACE); + gl->Enable(GL_TEXTURE_2D); + gl->DrawBuffer(GL_BACK); + gl->TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); -static int draw_frame(uint8_t *src[]) -{ - return 0; -} - -static uint32_t draw_image(mp_image_t *mpi) -{ - memcpy_pic(image_data, mpi->planes[0], image_width*image_bytes, image_height, image_width*image_bytes, mpi->stride[0]); + resize(vo, d_width, d_height); - return 0; + gl->ClearColor(0.0f, 0.0f, 0.0f, 0.0f); + gl->Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + if (gl->SwapInterval) + gl->SwapInterval(1); + return 1; } -static int query_format(uint32_t format) -{ - const int supportflags = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN; - image_format = format; +static void release_cv_entities(void) { + CVPixelBufferRelease(p->pixelBuffer); + p->pixelBuffer = NULL; + CVOpenGLTextureRelease(p->texture); + p->texture = NULL; + CVOpenGLTextureCacheRelease(p->textureCache); + p->textureCache = NULL; - switch(format) - { - case IMGFMT_YUY2: - pixelFormat = kYUVSPixelFormat; - return supportflags; - - case IMGFMT_RGB24: - pixelFormat = k24RGBPixelFormat; - return supportflags; - - case IMGFMT_ARGB: - pixelFormat = k32ARGBPixelFormat; - return supportflags; - - case IMGFMT_BGRA: - pixelFormat = k32BGRAPixelFormat; - return supportflags; - } - return 0; } -static void uninit(void) +static int config(struct vo *vo, uint32_t width, uint32_t height, + uint32_t d_width, uint32_t d_height, uint32_t flags, + uint32_t format) { - SetSystemUIMode( kUIModeNormal, 0); - CGDisplayShowCursor(kCGDirectMainDisplay); - - free_file_specific(); - - if(mpGLView) - { - NSAutoreleasePool *finalPool; - mpGLView = nil; - [autoreleasepool release]; - finalPool = [[NSAutoreleasePool alloc] init]; - [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES]; - [finalPool release]; - } - - free(buffer_name); - buffer_name = NULL; -} + release_cv_entities(); + p->image_width = width; + p->image_height = height; -static const opt_t subopts[] = { -{"device_id", OPT_ARG_INT, &screen_id, NULL}, -{"shared_buffer", OPT_ARG_BOOL, &shared_buffer, NULL}, -{"buffer_name", OPT_ARG_MSTRZ,&buffer_name, NULL}, -{NULL} -}; - -static int preinit(const char *arg) -{ + if (p->mpglctx->create_window(p->mpglctx, d_width, d_height, flags) < 0) + return -1; + if (p->mpglctx->setGlWindow(p->mpglctx) == SET_WINDOW_FAILED) + return -1; - // set defaults - screen_id = -1; - shared_buffer = false; - buffer_name = NULL; - - if (subopt_parse(arg, subopts) != 0) { - mp_msg(MSGT_VO, MSGL_FATAL, - "\n-vo corevideo command line help:\n" - "Example: mplayer -vo corevideo:device_id=1:shared_buffer:buffer_name=mybuff\n" - "\nOptions:\n" - " device_id=<0-...>\n" - " Set screen device ID for fullscreen.\n" - " shared_buffer\n" - " Write output to a shared memory buffer instead of displaying it.\n" - " buffer_name=\n" - " Name of the shared buffer created with shm_open() as well as\n" - " the name of the NSConnection MPlayer will try to open.\n" - " Setting buffer_name implicitly enables shared_buffer.\n" - "\n" ); - return -1; - } - - autoreleasepool = [[NSAutoreleasePool alloc] init]; - - if (!buffer_name) - buffer_name = strdup(DEFAULT_BUFFER_NAME); - else - shared_buffer = true; - - if(!shared_buffer) - { - NSApplicationLoad(); - NSApp = [NSApplication sharedApplication]; - isLeopardOrLater = floor(NSAppKitVersionNumber) > 824; - - osx_foreground_hack(); - - if(!mpGLView) - { - mpGLView = [[MPlayerOpenGLView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) pixelFormat:[MPlayerOpenGLView defaultPixelFormat]]; - [mpGLView autorelease]; - } - // Install an event handler so the Quit menu entry works - // The proper way using NSApp setDelegate: and - // applicationShouldTerminate: does not work, - // probably NSApplication never installs its handler. - [[NSAppleEventManager sharedAppleEventManager] - setEventHandler:mpGLView - andSelector:@selector(handleQuitEvent:withReplyEvent:) - forEventClass:kCoreEventClass - andEventID:kAEQuitApplication]; - - [mpGLView display]; - [mpGLView preinit]; - } + init_gl(vo, vo->dwidth, vo->dheight); return 0; } -static int control(uint32_t request, void *data) +static void check_events(struct vo *vo) { - switch (request) - { - case VOCTRL_DRAW_IMAGE: return draw_image(data); - case VOCTRL_PAUSE: return int_pause = 1; - case VOCTRL_RESUME: return int_pause = 0; - case VOCTRL_QUERY_FORMAT: return query_format(*(uint32_t*)data); - case VOCTRL_ONTOP: vo_ontop = !vo_ontop; if(!shared_buffer){ [mpGLView ontop]; } else { [mplayerosxProto ontop]; } return VO_TRUE; - case VOCTRL_ROOTWIN: vo_rootwin = !vo_rootwin; [mpGLView rootwin]; return VO_TRUE; - case VOCTRL_FULLSCREEN: vo_fs = !vo_fs; if(!shared_buffer){ [mpGLView fullscreen: NO]; } else { [mplayerosxProto toggleFullscreen]; } return VO_TRUE; - case VOCTRL_GET_PANSCAN: return VO_TRUE; - case VOCTRL_SET_PANSCAN: [mpGLView panscan]; return VO_TRUE; - case VOCTRL_UPDATE_SCREENINFO: update_screen_info(); return VO_TRUE; - } - return VO_NOTIMPL; + int e = p->mpglctx->check_events(vo); + if (e & VO_EVENT_RESIZE) + resize(vo, vo->dwidth, vo->dheight); } -////////////////////////////////////////////////////////////////////////// -// NSOpenGLView Subclass -////////////////////////////////////////////////////////////////////////// -@implementation MPlayerOpenGLView -- (void) preinit +static void create_osd_texture(void *ctx, int x0, int y0, int w, int h, + unsigned char *src, unsigned char *srca, + int stride) { - NSOpenGLContext *glContext; - GLint swapInterval = 1; - CVReturn error; - - //init menu - [self initMenu]; - - //create window - window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 100, 100) - styleMask:NSTitledWindowMask|NSTexturedBackgroundWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask - backing:NSBackingStoreBuffered defer:NO]; - - [window autorelease]; - [window setDelegate:mpGLView]; - [window setContentView:mpGLView]; - [window setInitialFirstResponder:mpGLView]; - [window setAcceptsMouseMovedEvents:YES]; - [window setTitle:@"MPlayer - The Movie Player"]; - - isFullscreen = 0; - winSizeMult = 1; - - //create OpenGL Context - glContext = [[NSOpenGLContext alloc] initWithFormat:[NSOpenGLView defaultPixelFormat] shareContext:nil]; - - [self setOpenGLContext:glContext]; - [glContext setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval]; - [glContext setView:self]; - [glContext makeCurrentContext]; - [glContext release]; - - error = CVOpenGLTextureCacheCreate(NULL, 0, [glContext CGLContextObj], [[self pixelFormat] CGLPixelFormatObj], 0, &textureCache); - if(error != kCVReturnSuccess) - mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create OpenGL texture Cache(%d)\n", error); -} - -- (void) releaseVideoSpecific -{ - CVPixelBufferRelease(frameBuffers[0]); - frameBuffers[0] = NULL; - CVPixelBufferRelease(frameBuffers[1]); - frameBuffers[1] = NULL; - CVOpenGLTextureRelease(texture); - texture = NULL; -} - -- (void) dealloc -{ - [self releaseVideoSpecific]; - CVOpenGLTextureCacheRelease(textureCache); - textureCache = NULL; - [self setOpenGLContext:nil]; - [super dealloc]; -} - -- (void) config -{ - NSRect visibleFrame; - CVReturn error = kCVReturnSuccess; - - //config window - [window setContentSize:NSMakeSize(vo_dwidth, vo_dheight)]; - - // Use visibleFrame to position the window taking the menu bar and dock into account. - // Also flip vo_dy since the screen origin is in the bottom left on OSX. - update_screen_info(); - visibleFrame = [screen_handle visibleFrame]; - [window setFrameTopLeftPoint:NSMakePoint( - visibleFrame.origin.x + vo_dx, - visibleFrame.origin.y + visibleFrame.size.height - vo_dy)]; - - [self releaseVideoSpecific]; - error = CVPixelBufferCreateWithBytes(NULL, image_width, image_height, pixelFormat, image_datas[0], image_width*image_bytes, NULL, NULL, NULL, &frameBuffers[0]); - if(error != kCVReturnSuccess) - mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create Pixel Buffer(%d)\n", error); - if (vo_doublebuffering) { - error = CVPixelBufferCreateWithBytes(NULL, image_width, image_height, pixelFormat, image_datas[1], image_width*image_bytes, NULL, NULL, NULL, &frameBuffers[1]); - if(error != kCVReturnSuccess) - mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create Pixel Double Buffer(%d)\n", error); - } - - error = CVOpenGLTextureCacheCreateTextureFromImage(NULL, textureCache, frameBuffers[image_page], 0, &texture); - if(error != kCVReturnSuccess) - mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create OpenGL texture(%d)\n", error); - - //show window - [window makeKeyAndOrderFront:mpGLView]; - - if(vo_rootwin) - [mpGLView rootwin]; - - if(vo_fs) - [mpGLView fullscreen: NO]; - - if(vo_ontop) - [mpGLView ontop]; -} - -/* - Init Menu -*/ -- (void)initMenu -{ - NSMenu *menu, *aspectMenu; - NSMenuItem *menuItem; - - menu = [[NSMenu new] autorelease]; - menuItem = [[NSMenuItem new] autorelease]; - [menu addItem: menuItem]; - [NSApp setMainMenu: menu]; - -//Create Movie Menu - menu = [[NSMenu alloc] initWithTitle:@"Movie"]; - menuItem = [[NSMenuItem alloc] initWithTitle:@"Half Size" action:@selector(menuAction:) keyEquivalent:@"0"]; [menu addItem:menuItem]; - kHalfScreenCmd = menuItem; - menuItem = [[NSMenuItem alloc] initWithTitle:@"Normal Size" action:@selector(menuAction:) keyEquivalent:@"1"]; [menu addItem:menuItem]; - kNormalScreenCmd = menuItem; - menuItem = [[NSMenuItem alloc] initWithTitle:@"Double Size" action:@selector(menuAction:) keyEquivalent:@"2"]; [menu addItem:menuItem]; - kDoubleScreenCmd = menuItem; - menuItem = [[NSMenuItem alloc] initWithTitle:@"Full Size" action:@selector(menuAction:) keyEquivalent:@"f"]; [menu addItem:menuItem]; - kFullScreenCmd = menuItem; - menuItem = [NSMenuItem separatorItem]; [menu addItem:menuItem]; - - aspectMenu = [[NSMenu alloc] initWithTitle:@"Aspect Ratio"]; - menuItem = [[NSMenuItem alloc] initWithTitle:@"Keep" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem]; - if(vo_keepaspect) [menuItem setState:NSOnState]; - kKeepAspectCmd = menuItem; - menuItem = [[NSMenuItem alloc] initWithTitle:@"Pan-Scan" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem]; - if(vo_panscan) [menuItem setState:NSOnState]; - kPanScanCmd = menuItem; - menuItem = [NSMenuItem separatorItem]; [aspectMenu addItem:menuItem]; - menuItem = [[NSMenuItem alloc] initWithTitle:@"Original" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem]; - kAspectOrgCmd = menuItem; - menuItem = [[NSMenuItem alloc] initWithTitle:@"4:3" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem]; - kAspectFullCmd = menuItem; - menuItem = [[NSMenuItem alloc] initWithTitle:@"16:9" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem]; - kAspectWideCmd = menuItem; - menuItem = [[NSMenuItem alloc] initWithTitle:@"Aspect Ratio" action:nil keyEquivalent:@""]; - [menuItem setSubmenu:aspectMenu]; - [menu addItem:menuItem]; - [aspectMenu release]; - - //Add to menubar - menuItem = [[NSMenuItem alloc] initWithTitle:@"Movie" action:nil keyEquivalent:@""]; - [menuItem setSubmenu:menu]; - [[NSApp mainMenu] addItem:menuItem]; - -//Create Window Menu - menu = [[NSMenu alloc] initWithTitle:@"Window"]; - - menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"]; [menu addItem:menuItem]; - menuItem = [[NSMenuItem alloc] initWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""]; [menu addItem:menuItem]; - - //Add to menubar - menuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""]; - [menuItem setSubmenu:menu]; - [[NSApp mainMenu] addItem:menuItem]; - [NSApp setWindowsMenu:menu]; - - [menu release]; - [menuItem release]; -} + struct osd_p *osd = p->osd; + GL *gl = p->mpglctx->gl; -- (void)set_winSizeMult:(float)mult -{ - NSRect frame; - int d_width, d_height; - aspect(&d_width, &d_height, A_NOZOOM); - - if (isFullscreen) { - vo_fs = !vo_fs; - [self fullscreen:NO]; + if (w <= 0 || h <= 0 || stride < w) { + mp_msg(MSGT_VO, MSGL_V, "Invalid dimensions OSD for part!\n"); + return; } - winSizeMult = mult; - frame.size.width = d_width * mult; - frame.size.height = d_height * mult; - [window setContentSize: frame.size]; - [self reshape]; -} - -/* - Menu Action - */ -- (void)menuAction:(id)sender -{ - if(sender == kHalfScreenCmd) - [self set_winSizeMult: 0.5]; - if(sender == kNormalScreenCmd) - [self set_winSizeMult: 1]; - if(sender == kDoubleScreenCmd) - [self set_winSizeMult: 2]; - if(sender == kFullScreenCmd) - { - vo_fs = !vo_fs; - [self fullscreen:NO]; - } - - if(sender == kKeepAspectCmd) - { - vo_keepaspect = !vo_keepaspect; - if(vo_keepaspect) - [kKeepAspectCmd setState:NSOnState]; - else - [kKeepAspectCmd setState:NSOffState]; - - [self reshape]; - } - - if(sender == kPanScanCmd) - { - vo_panscan = !vo_panscan; - if(vo_panscan) - [kPanScanCmd setState:NSOnState]; - else - [kPanScanCmd setState:NSOffState]; - - [self panscan]; - } - - if(sender == kAspectOrgCmd) - change_movie_aspect(-1); + if (osd->tex_cnt >= CV_MAX_OSD_PARTS) { + mp_msg(MSGT_VO, MSGL_ERR, "Too many OSD parts, contact the" + " developers!\n"); + return; + } - if(sender == kAspectFullCmd) - change_movie_aspect(4.0f/3.0f); + gl->GenTextures(1, &osd->tex[osd->tex_cnt]); + gl->BindTexture(GL_TEXTURE_2D, osd->tex[osd->tex_cnt]); + glCreateClearTex(gl, GL_TEXTURE_2D, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, + GL_UNSIGNED_BYTE, GL_LINEAR, w, h, 0); + { + int i; + unsigned char *tmp = malloc(stride * h * 2); + // convert alpha from weird MPlayer scale. + for (i = 0; i < h * stride; i++) { + tmp[i*2+0] = src[i]; + tmp[i*2+1] = -srca[i]; + } + glUploadTex(gl, GL_TEXTURE_2D, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, + tmp, stride * 2, 0, 0, w, h, 0); + free(tmp); + } - if(sender == kAspectWideCmd) - change_movie_aspect(16.0f/9.0f); -} + osd->tex_rect[osd->tex_cnt] = NSMakeRect(x0, y0, w, h); -/* - Setup OpenGL -*/ -- (void)prepareOpenGL -{ - glEnable(GL_BLEND); - glDisable(GL_DEPTH_TEST); - glDepthMask(GL_FALSE); - glDisable(GL_CULL_FACE); - [self reshape]; + gl->BindTexture(GL_TEXTURE_2D, 0); + osd->tex_cnt++; } -/* - reshape OpenGL viewport -*/ -- (void)reshape +static void clearOSD(struct vo *vo) { - int d_width, d_height; + struct osd_p *osd = p->osd; + GL *gl = p->mpglctx->gl; - NSRect frame = [self frame]; - vo_dwidth = frame.size.width; - vo_dheight = frame.size.height; - - glViewport(0, 0, frame.size.width, frame.size.height); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0, frame.size.width, frame.size.height, 0, -1.0, 1.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - //set texture frame - if(vo_keepaspect) - { - aspect(&d_width, &d_height, A_WINZOOM); - - textureFrame = NSMakeRect((vo_dwidth - d_width) / 2, (vo_dheight - d_height) / 2, d_width, d_height); - } - else - { - textureFrame = frame; - } + if (!osd->tex_cnt) + return; + gl->DeleteTextures(osd->tex_cnt, osd->tex); + osd->tex_cnt = 0; } -/* - Render frame -*/ -- (void) render +static void draw_osd(struct vo *vo, struct osd_state *osd_s) { - glClear(GL_COLOR_BUFFER_BIT); + struct osd_p *osd = p->osd; + GL *gl = p->mpglctx->gl; - glEnable(CVOpenGLTextureGetTarget(texture)); - glBindTexture(CVOpenGLTextureGetTarget(texture), CVOpenGLTextureGetName(texture)); + if (vo_osd_changed(0)) { + clearOSD(vo); + osd_draw_text_ext(osd_s, vo->dwidth, vo->dheight, 0, 0, 0, 0, + p->image_width, p->image_height, create_osd_texture, + vo); + } - glColor3f(1,1,1); - glBegin(GL_QUADS); - glTexCoord2f(upperLeft[0], upperLeft[1]); glVertex2i( textureFrame.origin.x-(vo_panscan_x >> 1), textureFrame.origin.y-(vo_panscan_y >> 1)); - glTexCoord2f(lowerLeft[0], lowerLeft[1]); glVertex2i(textureFrame.origin.x-(vo_panscan_x >> 1), NSMaxY(textureFrame)+(vo_panscan_y >> 1)); - glTexCoord2f(lowerRight[0], lowerRight[1]); glVertex2i(NSMaxX(textureFrame)+(vo_panscan_x >> 1), NSMaxY(textureFrame)+(vo_panscan_y >> 1)); - glTexCoord2f(upperRight[0], upperRight[1]); glVertex2i(NSMaxX(textureFrame)+(vo_panscan_x >> 1), textureFrame.origin.y-(vo_panscan_y >> 1)); - glEnd(); - glDisable(CVOpenGLTextureGetTarget(texture)); - - //render resize box - if(!isFullscreen) - { - NSRect frame = [self frame]; - - glBegin(GL_LINES); - glColor4f(0.2, 0.2, 0.2, 0.5); - glVertex2i(frame.size.width-1, frame.size.height-1); glVertex2i(frame.size.width-1, frame.size.height-1); - glVertex2i(frame.size.width-1, frame.size.height-5); glVertex2i(frame.size.width-5, frame.size.height-1); - glVertex2i(frame.size.width-1, frame.size.height-9); glVertex2i(frame.size.width-9, frame.size.height-1); - - glColor4f(0.4, 0.4, 0.4, 0.5); - glVertex2i(frame.size.width-1, frame.size.height-2); glVertex2i(frame.size.width-2, frame.size.height-1); - glVertex2i(frame.size.width-1, frame.size.height-6); glVertex2i(frame.size.width-6, frame.size.height-1); - glVertex2i(frame.size.width-1, frame.size.height-10); glVertex2i(frame.size.width-10, frame.size.height-1); - - glColor4f(0.6, 0.6, 0.6, 0.5); - glVertex2i(frame.size.width-1, frame.size.height-3); glVertex2i(frame.size.width-3, frame.size.height-1); - glVertex2i(frame.size.width-1, frame.size.height-7); glVertex2i(frame.size.width-7, frame.size.height-1); - glVertex2i(frame.size.width-1, frame.size.height-11); glVertex2i(frame.size.width-11, frame.size.height-1); - glEnd(); - } + if (osd->tex_cnt > 0) { + gl->Enable(GL_BLEND); + gl->BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + + for (int n = 0; n < osd->tex_cnt; n++) { + NSRect tr = osd->tex_rect[n]; + gl->BindTexture(GL_TEXTURE_2D, osd->tex[n]); + glDrawTex(gl, tr.origin.x, tr.origin.y, + tr.size.width, tr.size.height, + 0, 0, 1.0, 1.0, 1, 1, 0, 0, 0); + } - glFlush(); + gl->Disable(GL_BLEND); + gl->BindTexture(GL_TEXTURE_2D, 0); + } } -/* - Create OpenGL texture from current frame & set texco -*/ -- (void) setCurrentTexture +static void prepare_texture(void) { - CVReturn error = kCVReturnSuccess; + CVReturn error; + struct quad *q = p->quad; - CVOpenGLTextureRelease(texture); - error = CVOpenGLTextureCacheCreateTextureFromImage(NULL, textureCache, frameBuffers[image_page], 0, &texture); - if(error != kCVReturnSuccess) - mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create OpenGL texture(%d)\n", error); + CVOpenGLTextureRelease(p->texture); + error = CVOpenGLTextureCacheCreateTextureFromImage(NULL, + p->textureCache, p->pixelBuffer, 0, &p->texture); + if(error != kCVReturnSuccess) + mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create OpenGL" + " texture(%d)\n", error); - CVOpenGLTextureGetCleanTexCoords(texture, lowerLeft, lowerRight, upperRight, upperLeft); + CVOpenGLTextureGetCleanTexCoords(p->texture, q->lowerLeft, q->lowerRight, + q->upperRight, q->upperLeft); } -/* - redraw win rect -*/ -- (void) drawRect: (NSRect *) bounds +static void do_render(struct vo *vo) { - [self render]; -} + struct quad *q = p->quad; + GL *gl = p->mpglctx->gl; + prepare_texture(); -/* - Toggle Fullscreen -*/ -- (void) fullscreen: (BOOL) animate -{ - static NSRect old_frame; - static NSRect old_view_frame; + float x0 = 0; + float y0 = 0; + float w = p->image_width; + float h = p->image_height; - panscan_calc(); + // vertically flips the image + y0 += h; + h = -h; - //go fullscreen - if(vo_fs) - { - if(!isRootwin) - { - SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar); - CGDisplayHideCursor(kCGDirectMainDisplay); - mouseHide = YES; - } - - old_frame = [window frame]; //save main window size & position - update_screen_info(); - - [window setFrame:screen_frame display:YES animate:animate]; //zoom-in window with nice useless sfx - old_view_frame = [self bounds]; - - //fix origin for multi screen setup - screen_frame.origin.x = 0; - screen_frame.origin.y = 0; - [self setFrame:screen_frame]; - [self setNeedsDisplay:YES]; - [window setHasShadow:NO]; - isFullscreen = 1; - } - else - { - SetSystemUIMode( kUIModeNormal, 0); - - isFullscreen = 0; - CGDisplayShowCursor(kCGDirectMainDisplay); - mouseHide = NO; - - //revert window to previous setting - [self setFrame:old_view_frame]; - [self setNeedsDisplay:YES]; - [window setHasShadow:YES]; - [window setFrame:old_frame display:YES animate:animate];//zoom-out window with nice useless sfx - } -} + float xm = x0 + w; + float ym = y0 + h; -/* - Toggle ontop -*/ -- (void) ontop -{ - if(vo_ontop) - { - [window setLevel:NSScreenSaverWindowLevel]; - isOntop = YES; - } - else - { - [window setLevel:NSNormalWindowLevel]; - isOntop = NO; - } -} - -/* - Toggle panscan -*/ -- (void) panscan -{ - panscan_calc(); -} - -/* - Toggle rootwin - */ -- (void) rootwin -{ - if(vo_rootwin) - { - [window setLevel:CGWindowLevelForKey(kCGDesktopWindowLevelKey)]; - [window orderBack:self]; - isRootwin = YES; - } - else - { - [window setLevel:NSNormalWindowLevel]; - isRootwin = NO; - } -} - -/* - Check event for new event -*/ -- (void) check_events -{ - NSEvent *event; - int curTime = TickCount()/60; + gl->Enable(CVOpenGLTextureGetTarget(p->texture)); + gl->BindTexture( + CVOpenGLTextureGetTarget(p->texture), + CVOpenGLTextureGetName(p->texture)); - //automatically hide mouse cursor (and future on-screen control?) - if(isFullscreen && !mouseHide && !isRootwin) - { - if(curTime - lastMouseHide >= 5 || lastMouseHide == 0) - { - CGDisplayHideCursor(kCGDirectMainDisplay); - mouseHide = TRUE; - lastMouseHide = curTime; - } - } - - //update activity every 30 seconds to prevent - //screensaver from starting up. - if(curTime - lastScreensaverUpdate >= 30 || lastScreensaverUpdate == 0) - { - UpdateSystemActivity(UsrActivity); - lastScreensaverUpdate = curTime; - } - - event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:nil inMode:NSEventTrackingRunLoopMode dequeue:YES]; - if (event == nil) - return; - [NSApp sendEvent:event]; - // Without SDL's bootstrap code (include SDL.h in mplayer.c), - // on Leopard, we have trouble to get the play window automatically focused - // when the app is actived. The Following code fix this problem. -#ifndef CONFIG_SDL - if (isLeopardOrLater && [event type] == NSAppKitDefined - && [event subtype] == NSApplicationActivatedEventType) { - [window makeMainWindow]; - [window makeKeyAndOrderFront:mpGLView]; - } -#endif -} + gl->Begin(GL_QUADS); + gl->TexCoord2fv(q->lowerLeft); gl->Vertex2f(x0, y0); + gl->TexCoord2fv(q->upperLeft); gl->Vertex2f(x0, ym); + gl->TexCoord2fv(q->upperRight); gl->Vertex2f(xm, ym); + gl->TexCoord2fv(q->lowerRight); gl->Vertex2f(xm, y0); + gl->End(); -/* - From NSView, respond to key equivalents. -*/ -- (BOOL)performKeyEquivalent:(NSEvent *)theEvent -{ - switch([theEvent keyCode]) - { - case 0x21: [window setAlphaValue: winAlpha-=0.05]; return YES; - case 0x1e: [window setAlphaValue: winAlpha+=0.05]; return YES; - } - return NO; + gl->Disable(CVOpenGLTextureGetTarget(p->texture)); } -/* - Process key event -*/ -- (void) keyDown: (NSEvent *) theEvent +static void flip_page(struct vo *vo) { - unsigned char charcode; - if (([theEvent modifierFlags] & NSRightAlternateKeyMask) == NSRightAlternateKeyMask) - charcode = *[[theEvent characters] UTF8String]; - else - charcode = [[theEvent charactersIgnoringModifiers] characterAtIndex:0]; - - int key = convert_key([theEvent keyCode], charcode); - - if (key > -1) { - if([theEvent modifierFlags] & NSShiftKeyMask) - key |= KEY_MODIFIER_SHIFT; - if([theEvent modifierFlags] & NSControlKeyMask) - key |= KEY_MODIFIER_CTRL; - if(([theEvent modifierFlags] & NSLeftAlternateKeyMask) == NSLeftAlternateKeyMask) - key |= KEY_MODIFIER_ALT; - if([theEvent modifierFlags] & NSCommandKeyMask) - key |= KEY_MODIFIER_META; - mplayer_put_key(key); - } + p->mpglctx->swapGlBuffers(p->mpglctx); + p->mpglctx->gl->Clear(GL_COLOR_BUFFER_BIT); } -/* - Process mouse button event -*/ -- (void) mouseMoved: (NSEvent *) theEvent +static uint32_t draw_image(struct vo *vo, mp_image_t *mpi) { - if(isFullscreen && !isRootwin) - { - CGDisplayShowCursor(kCGDirectMainDisplay); - mouseHide = NO; - } - if (enable_mouse_movements && !isRootwin) { - NSPoint p =[self convertPoint:[theEvent locationInWindow] fromView:nil]; - if ([self mouse:p inRect:textureFrame]) { - vo_mouse_movement(global_vo, vo_fs ? p.x : p.x - textureFrame.origin.x, - vo_fs ? [self frame].size.height - p.y : NSMaxY(textureFrame) - p.y); - } - } -} + CVReturn error; -- (void) mouseDown: (NSEvent *) theEvent -{ - [self mouseEvent: theEvent]; -} + if (!p->textureCache || !p->pixelBuffer) { + error = CVOpenGLTextureCacheCreate(NULL, 0, vo_cocoa_cgl_context(), + vo_cocoa_cgl_pixel_format(), 0, &p->textureCache); + if(error != kCVReturnSuccess) + mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create OpenGL" + " texture Cache(%d)\n", error); -- (void) mouseUp: (NSEvent *) theEvent -{ - [self mouseEvent: theEvent]; -} + error = CVPixelBufferCreateWithBytes(NULL, mpi->width, mpi->height, + p->pixelFormat, mpi->planes[0], mpi->width * mpi->bpp / 8, + NULL, NULL, NULL, &p->pixelBuffer); + if(error != kCVReturnSuccess) + mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create Pixel" + "Buffer(%d)\n", error); + } -- (void) rightMouseDown: (NSEvent *) theEvent -{ - [self mouseEvent: theEvent]; + do_render(vo); + return VO_TRUE; } -- (void) rightMouseUp: (NSEvent *) theEvent +static int query_format(uint32_t format) { - [self mouseEvent: theEvent]; + const int flags = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | + VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | + VOCAP_NOSLICES; + switch (format) { + case IMGFMT_YUY2: + p->pixelFormat = kYUVSPixelFormat; + return flags; + + case IMGFMT_RGB24: + p->pixelFormat = k24RGBPixelFormat; + return flags; + + case IMGFMT_ARGB: + p->pixelFormat = k32ARGBPixelFormat; + return flags; + + case IMGFMT_BGRA: + p->pixelFormat = k32BGRAPixelFormat; + return flags; + } + return 0; } -- (void) otherMouseDown: (NSEvent *) theEvent +static void uninit(struct vo *vo) { - [self mouseEvent: theEvent]; + uninit_mpglcontext(p->mpglctx); + release_cv_entities(); + talloc_free(p); } -- (void) otherMouseUp: (NSEvent *) theEvent -{ - [self mouseEvent: theEvent]; -} -- (void) scrollWheel: (NSEvent *) theEvent +static int preinit(struct vo *vo, const char *arg) { - if([theEvent deltaY] > 0) - mplayer_put_key(MOUSE_BTN3); - else - mplayer_put_key(MOUSE_BTN4); -} + const opt_t subopts[] = { + {NULL} + }; -- (void) mouseEvent: (NSEvent *) theEvent -{ - if ( [theEvent buttonNumber] >= 0 && [theEvent buttonNumber] <= 9 ) - { - int buttonNumber = [theEvent buttonNumber]; - // Fix to mplayer defined button order: left, middle, right - if (buttonNumber == 1) - buttonNumber = 2; - else if (buttonNumber == 2) - buttonNumber = 1; - switch([theEvent type]) - { - case NSLeftMouseDown: - case NSRightMouseDown: - case NSOtherMouseDown: - mplayer_put_key((MOUSE_BTN0 + buttonNumber) | MP_KEY_DOWN); - break; - case NSLeftMouseUp: - case NSRightMouseUp: - case NSOtherMouseUp: - mplayer_put_key(MOUSE_BTN0 + buttonNumber); - break; - } - } -} + if (subopt_parse(arg, subopts) != 0) { + mp_msg(MSGT_VO, MSGL_FATAL, + "\n-vo corevideo command line help:\n" + "Example: mplayer -vo corevideo\n" + "\n" ); + return -1; + } -/* - NSResponder -*/ -- (BOOL) acceptsFirstResponder -{ - return YES; -} + p = talloc_ptrtype(NULL, p); + *p = (struct priv) { + .mpglctx = init_mpglcontext(GLTYPE_COCOA, vo), + .colorspace = MP_CSP_DETAILS_DEFAULTS, + .quad = talloc_ptrtype(p, p->quad), + .osd = talloc_ptrtype(p, p->osd), + }; + + *p->osd = (struct osd_p) { + .tex_cnt = 0, + }; -- (BOOL) becomeFirstResponder -{ - return YES; + return 0; } -- (BOOL) resignFirstResponder +static CFStringRef get_cv_csp_matrix(void) { - return YES; + switch (p->colorspace.format) { + case MP_CSP_BT_601: + return kCVImageBufferYCbCrMatrix_ITU_R_601_4; + case MP_CSP_BT_709: + return kCVImageBufferYCbCrMatrix_ITU_R_709_2; + case MP_CSP_SMPTE_240M: + return kCVImageBufferYCbCrMatrix_SMPTE_240M_1995; + } + return kCVImageBufferYCbCrMatrix_ITU_R_601_4; } -- (BOOL)windowShouldClose:(id)sender +static void set_yuv_colorspace(struct vo *vo) { - mplayer_put_key(KEY_CLOSE_WIN); - // We have to wait for MPlayer to handle this, - // otherwise we are in trouble if the - // KEY_CLOSE_WIN handler is disabled - return NO; + CVBufferSetAttachment(p->pixelBuffer, + kCVImageBufferYCbCrMatrixKey, get_cv_csp_matrix(), + kCVAttachmentMode_ShouldPropagate); + vo->want_redraw = true; +} + +static int control(struct vo *vo, uint32_t request, void *data) +{ + switch (request) { + case VOCTRL_DRAW_IMAGE: + return draw_image(vo, data); + case VOCTRL_QUERY_FORMAT: + return query_format(*(uint32_t*)data); + case VOCTRL_ONTOP: + p->mpglctx->ontop(vo); + return VO_TRUE; + case VOCTRL_FULLSCREEN: + p->mpglctx->fullscreen(vo); + resize(vo, vo->dwidth, vo->dheight); + return VO_TRUE; + case VOCTRL_GET_PANSCAN: + return VO_TRUE; + case VOCTRL_SET_PANSCAN: + resize(vo, vo->dwidth, vo->dheight); + return VO_TRUE; + case VOCTRL_UPDATE_SCREENINFO: + p->mpglctx->update_xinerama_info(vo); + return VO_TRUE; + case VOCTRL_REDRAW_FRAME: + do_render(vo); + return VO_TRUE; + case VOCTRL_SET_YUV_COLORSPACE: + p->colorspace.format = ((struct mp_csp_details *)data)->format; + set_yuv_colorspace(vo); + return VO_TRUE; + case VOCTRL_GET_YUV_COLORSPACE: + *(struct mp_csp_details *)data = p->colorspace; + return VO_TRUE; + } + return VO_NOTIMPL; } -- (void)handleQuitEvent:(NSAppleEventDescriptor*)e withReplyEvent:(NSAppleEventDescriptor*)r -{ - mplayer_put_key(KEY_CLOSE_WIN); -} -@end +const struct vo_driver video_out_corevideo = { + .is_new = true, + .info = &(const vo_info_t) { + "Mac OS X Core Video", + "corevideo", + "Nicolas Plourde and others", + "" + }, + .preinit = preinit, + .config = config, + .control = control, + .draw_osd = draw_osd, + .flip_page = flip_page, + .check_events = check_events, + .uninit = uninit, +}; diff -Nru mplayer2-2.0-426-gc32b3ed/libvo/vo_directx.c mplayer2-2.0-554-gf63dbad/libvo/vo_directx.c --- mplayer2-2.0-426-gc32b3ed/libvo/vo_directx.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libvo/vo_directx.c 2012-05-17 14:38:00.000000000 +0000 @@ -276,7 +276,7 @@ case DDERR_OUTOFVIDEOMEMORY: {mp_msg(MSGT_VO, MSGL_ERR,"not enough video memory\n");break;} default: - mp_msg(MSGT_VO, MSGL_ERR,"create surface failed with 0x%x\n",ddrval); + mp_msg(MSGT_VO, MSGL_ERR,"create surface failed with 0x%xu\n",(unsigned)ddrval); } return 1; } @@ -588,7 +588,7 @@ // we should try upping the destination size a bit, or // perhaps shrinking the source size mp_msg(MSGT_VO, MSGL_ERR ,"UpdateOverlay failed\n" ); - mp_msg(MSGT_VO, MSGL_ERR ,"Overlay:x1:%i,y1:%i,x2:%i,y2:%i,w:%i,h:%i\n",rd.left,rd.top,rd.right,rd.bottom,rd.right - rd.left,rd.bottom - rd.top ); + mp_msg(MSGT_VO, MSGL_ERR ,"Overlay:x1:%li,y1:%li,x2:%li,y2:%li,w:%li,h:%li\n",rd.left,rd.top,rd.right,rd.bottom,rd.right - rd.left,rd.bottom - rd.top ); mp_msg(MSGT_VO, MSGL_ERR ,""); switch (ddrval) { @@ -618,7 +618,7 @@ break; } default: - mp_msg(MSGT_VO, MSGL_ERR ," 0x%x\n",ddrval); + mp_msg(MSGT_VO, MSGL_ERR ," 0x%xu\n",(unsigned)ddrval); } /*ok we can't do anything about it -> hide overlay*/ if(ddrval != DD_OK) diff -Nru mplayer2-2.0-426-gc32b3ed/libvo/vo_gl.c mplayer2-2.0-554-gf63dbad/libvo/vo_gl.c --- mplayer2-2.0-426-gc32b3ed/libvo/vo_gl.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libvo/vo_gl.c 2012-05-17 14:38:00.000000000 +0000 @@ -220,7 +220,8 @@ mp_get_chroma_shift(p->image_format, &xs, &ys, &depth); params.chrom_texw = params.texw >> xs; params.chrom_texh = params.texh >> ys; - params.csp_params.input_shift = -depth & 7; + params.csp_params.input_bits = depth; + params.csp_params.texture_bits = depth+7 & ~7; glSetupYUVConversion(gl, ¶ms); if (p->custom_prog) { FILE *f = fopen(p->custom_prog, "rb"); diff -Nru mplayer2-2.0-426-gc32b3ed/libvo/vo_jpeg.c mplayer2-2.0-554-gf63dbad/libvo/vo_jpeg.c --- mplayer2-2.0-426-gc32b3ed/libvo/vo_jpeg.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libvo/vo_jpeg.c 2012-05-17 14:38:00.000000000 +0000 @@ -45,6 +45,7 @@ #include "video_out.h" #include "video_out_internal.h" #include "mplayer.h" /* for exit_player_bad() */ +#include "osdep/io.h" /* ------------------------------------------------------------------------- */ @@ -107,15 +108,11 @@ static void jpeg_mkdir(const char *buf, int verbose) { struct stat stat_p; -#ifndef __MINGW32__ if ( mkdir(buf, 0755) < 0 ) { -#else - if ( mkdir(buf) < 0 ) { -#endif switch (errno) { /* use switch in case other errors need to be caught and handled in the future */ case EEXIST: - if ( stat(buf, &stat_p ) < 0 ) { + if ( mp_stat(buf, &stat_p ) < 0 ) { mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, _("This error has occurred"), strerror(errno) ); mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, diff -Nru mplayer2-2.0-426-gc32b3ed/libvo/vo_kva.c mplayer2-2.0-554-gf63dbad/libvo/vo_kva.c --- mplayer2-2.0-426-gc32b3ed/libvo/vo_kva.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libvo/vo_kva.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,1090 +0,0 @@ -/* - * OS/2 video output driver - * - * Copyright (c) 2007-2009 by KO Myung-Hun (komh@chollian.net) - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#define INCL_WIN -#define INCL_GPI -#define INCL_DOS -#include - -#include -#include - -#include -#include -#include -#include - -#include - -#include "config.h" -#include "mp_msg.h" -#include "video_out.h" -#include "video_out_internal.h" -#include "aspect.h" - -#include "fastmemcpy.h" -#include "mp_fifo.h" -#include "input/keycodes.h" -#include "input/input.h" -#include "subopt-helper.h" -#include "sub/sub.h" - -#include "cpudetect.h" -#include "libswscale/swscale.h" -#include "libmpcodecs/vf_scale.h" - -static const vo_info_t info = { - "SNAP/WarpOverlay!/DIVE video output", - "kva", - "KO Myung-Hun ", - "" -}; - -const LIBVO_EXTERN(kva) - -#define WC_MPLAYER "WC_MPLAYER" - -#define SRC_WIDTH m_int.kvas.szlSrcSize.cx -#define SRC_HEIGHT m_int.kvas.szlSrcSize.cy - -#define HWNDFROMWINID(wid) ((wid) + 0x80000000UL) - -static const struct mp_keymap m_vk_map[] = { - {VK_NEWLINE, KEY_ENTER}, {VK_TAB, KEY_TAB}, {VK_SPACE, ' '}, - - // control keys - {VK_CTRL, KEY_CTRL}, {VK_BACKSPACE, KEY_BS}, - {VK_DELETE, KEY_DELETE}, {VK_INSERT, KEY_INSERT}, - {VK_HOME, KEY_HOME}, {VK_END, KEY_END}, - {VK_PAGEUP, KEY_PAGE_UP}, {VK_PAGEDOWN, KEY_PAGE_DOWN}, - {VK_ESC, KEY_ESC}, - - // cursor keys - {VK_RIGHT, KEY_RIGHT}, {VK_LEFT, KEY_LEFT}, - {VK_DOWN, KEY_DOWN}, {VK_UP, KEY_UP}, - - // function keys - {VK_F1, KEY_F+1}, {VK_F2, KEY_F+2}, {VK_F3, KEY_F+3}, {VK_F4, KEY_F+4}, - {VK_F5, KEY_F+5}, {VK_F6, KEY_F+6}, {VK_F7, KEY_F+7}, {VK_F8, KEY_F+8}, - {VK_F9, KEY_F+9}, {VK_F10, KEY_F+10}, {VK_F11, KEY_F+11}, {VK_F12, KEY_F+12}, - - {0, 0} -}; - -static const struct mp_keymap m_keypad_map[] = { - // keypad keys - {0x52, KEY_KP0}, {0x4F, KEY_KP1}, {0x50, KEY_KP2}, {0x51, KEY_KP3}, - {0x4B, KEY_KP4}, {0x4C, KEY_KP5}, {0x4D, KEY_KP6}, {0x47, KEY_KP7}, - {0x48, KEY_KP8}, {0x49, KEY_KP9}, {0x53, KEY_KPDEC}, {0x5A, KEY_KPENTER}, - - {0, 0} -}; - -static const struct mp_keymap m_mouse_map[] = { - {WM_BUTTON1DOWN, MOUSE_BTN0}, - {WM_BUTTON3DOWN, MOUSE_BTN1}, - {WM_BUTTON2DOWN, MOUSE_BTN2}, - {WM_BUTTON1DBLCLK, MOUSE_BTN0_DBL}, - {WM_BUTTON3DBLCLK, MOUSE_BTN1_DBL}, - {WM_BUTTON2DBLCLK, MOUSE_BTN2_DBL}, - - {0, 0} -}; - -struct { - HAB hab; - HMQ hmq; - HWND hwndFrame; - HWND hwndClient; - HWND hwndSysMenu; - HWND hwndTitleBar; - HWND hwndMinMax; - FOURCC fcc; - int iImageFormat; - int nChromaShift; - KVASETUP kvas; - KVACAPS kvac; - RECTL rclDst; - int bpp; - LONG lStride; - PBYTE pbImage; - BOOL fFixT23; - PFNWP pfnwpOldFrame; - uint8_t *planes[MP_MAX_PLANES]; // y = 0, u = 1, v = 2 - int stride[MP_MAX_PLANES]; - BOOL fHWAccel; - RECTL rclParent; - struct SwsContext *sws; -} m_int; - -static inline void setAspectRatio(ULONG ulRatio) -{ - ULONG ulValue; - int i; - - m_int.kvas.ulRatio = ulRatio; - kvaSetup(&m_int.kvas); - - // Setup initializes all attributes, so need to restore them. - for (i = 0; i < KVAA_LAST; i++) { - kvaQueryAttr(i, &ulValue); - kvaSetAttr(i, &ulValue); - } -} - -static int query_format_info(int format, PBOOL pfHWAccel, PFOURCC pfcc, - int *pbpp, int *pnChromaShift) -{ - BOOL fHWAccel; - FOURCC fcc; - INT bpp; - INT nChromaShift; - - switch (format) { - case IMGFMT_YV12: - fHWAccel = m_int.kvac.ulInputFormatFlags & KVAF_YV12; - fcc = FOURCC_YV12; - bpp = 1; - nChromaShift = 1; - break; - - case IMGFMT_YUY2: - fHWAccel = m_int.kvac.ulInputFormatFlags & KVAF_YUY2; - fcc = FOURCC_Y422; - bpp = 2; - nChromaShift = 0; - break; - - case IMGFMT_YVU9: - fHWAccel = m_int.kvac.ulInputFormatFlags & KVAF_YVU9; - fcc = FOURCC_YVU9; - bpp = 1; - nChromaShift = 2; - break; - - case IMGFMT_BGR24: - fHWAccel = m_int.kvac.ulInputFormatFlags & KVAF_BGR24; - fcc = FOURCC_BGR3; - bpp = 3; - nChromaShift = 0; - break; - - case IMGFMT_BGR16: - fHWAccel = m_int.kvac.ulInputFormatFlags & KVAF_BGR16; - fcc = FOURCC_R565; - bpp = 2; - nChromaShift = 0; - break; - - case IMGFMT_BGR15: - fHWAccel = m_int.kvac.ulInputFormatFlags & KVAF_BGR15; - fcc = FOURCC_R555; - bpp = 2; - nChromaShift = 0; - break; - - default: - return 1; - } - - if (pfHWAccel) - *pfHWAccel = fHWAccel; - - if (pfcc) - *pfcc = fcc; - - if (pbpp) - *pbpp = bpp; - - if (pnChromaShift) - *pnChromaShift = nChromaShift; - - return 0; -} - -static void imgCreate(void) -{ - int size = SRC_HEIGHT * m_int.lStride;; - - switch (m_int.iImageFormat) { - case IMGFMT_YV12: - size += size / 2; - break; - - case IMGFMT_YVU9: - size += size / 8; - break; - } - - m_int.pbImage = malloc(size); - - memset(m_int.planes, 0, sizeof(m_int.planes)); - memset(m_int.stride, 0, sizeof(m_int.stride)); - m_int.planes[0] = m_int.pbImage; - m_int.stride[0] = m_int.lStride; - - // YV12 or YVU9 ? - if (m_int.nChromaShift) { - m_int.planes[1] = m_int.planes[0] + SRC_HEIGHT * m_int.stride[0]; - m_int.stride[1] = m_int.stride[0] >> m_int.nChromaShift; - - m_int.planes[2] = m_int.planes[1] + - (SRC_HEIGHT >> m_int.nChromaShift) * m_int.stride[1]; - m_int.stride[2] = m_int.stride[1]; - } -} - -static void imgFree(void) -{ - free(m_int.pbImage); - - m_int.pbImage = NULL; -} - -static void imgDisplay(void) -{ - PVOID pBuffer; - ULONG ulBPL; - - if (!kvaLockBuffer(&pBuffer, &ulBPL)) { - uint8_t *dst[MP_MAX_PLANES] = {NULL}; - int dstStride[MP_MAX_PLANES] = {0}; - - // Get packed or Y - dst[0] = pBuffer; - dstStride[0] = ulBPL; - - // YV12 or YVU9 ? - if (m_int.nChromaShift) { - // Get V - dst[2] = dst[0] + SRC_HEIGHT * dstStride[0]; - dstStride[2] = dstStride[0] >> m_int.nChromaShift; - - // Get U - dst[1] = dst[2] + - (SRC_HEIGHT >> m_int.nChromaShift ) * dstStride[2]; - dstStride[1] = dstStride[2]; - } - - if (m_int.fHWAccel) { - int w, h; - - w = m_int.stride[0]; - h = SRC_HEIGHT; - - // Copy packed or Y - mem2agpcpy_pic(dst[0], m_int.planes[0], w, h, - dstStride[0], m_int.stride[0]); - - // YV12 or YVU9 ? - if (m_int.nChromaShift) { - w >>= m_int.nChromaShift; h >>= m_int.nChromaShift; - - // Copy U - mem2agpcpy_pic(dst[1], m_int.planes[1], w, h, - dstStride[1], m_int.stride[1]); - - // Copy V - mem2agpcpy_pic(dst[2], m_int.planes[2], w, h, - dstStride[2], m_int.stride[2]); - } - } else { - sws_scale(m_int.sws, m_int.planes, m_int.stride, 0, SRC_HEIGHT, - dst, dstStride); - } - - kvaUnlockBuffer(); - } -} - -// Frame window procedure to work around T23 laptop with S3 video card, -// which supports upscaling only. -static MRESULT EXPENTRY NewFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1, - MPARAM mp2) -{ - switch (msg) { - case WM_QUERYTRACKINFO: - { - PTRACKINFO pti = (PTRACKINFO)mp2; - RECTL rcl; - - if (vo_fs) - break; - - m_int.pfnwpOldFrame(hwnd, msg, mp1, mp2); - - rcl.xLeft = 0; - rcl.yBottom = 0; - rcl.xRight = SRC_WIDTH + 1; - rcl.yTop = SRC_HEIGHT + 1; - - WinCalcFrameRect(hwnd, &rcl, FALSE); - - pti->ptlMinTrackSize.x = rcl.xRight - rcl.xLeft; - pti->ptlMinTrackSize.y = rcl.yTop - rcl.yBottom; - - pti->ptlMaxTrackSize.x = vo_screenwidth; - pti->ptlMaxTrackSize.y = vo_screenheight; - - return (MRESULT)TRUE; - } - - case WM_ADJUSTWINDOWPOS: - { - PSWP pswp = (PSWP)mp1; - RECTL rcl; - - if (vo_fs) - break; - - if (pswp->fl & SWP_SIZE) { - rcl.xLeft = pswp->x; - rcl.yBottom = pswp->y; - rcl.xRight = rcl.xLeft + pswp->cx; - rcl.yTop = rcl.yBottom + pswp->cy; - - WinCalcFrameRect(hwnd, &rcl, TRUE); - - if (rcl.xRight - rcl.xLeft <= SRC_WIDTH) - rcl.xRight = rcl.xLeft + (SRC_WIDTH + 1); - - if (rcl.yTop - rcl.yBottom <= SRC_HEIGHT) - rcl.yTop = rcl.yBottom + (SRC_HEIGHT + 1); - - WinCalcFrameRect(hwnd, &rcl, FALSE); - - if (rcl.xRight - rcl.xLeft > vo_screenwidth) { - rcl.xLeft = 0; - rcl.xRight = vo_screenwidth; - } - - if (rcl.yTop - rcl.yBottom > vo_screenheight) { - rcl.yBottom = 0; - rcl.yTop = vo_screenheight; - } - - pswp->fl |= SWP_MOVE; - pswp->x = rcl.xLeft; - pswp->y = rcl.yBottom; - pswp->cx = rcl.xRight - rcl.xLeft; - pswp->cy = rcl.yTop - rcl.yBottom; - } - break; - } - } - - return m_int.pfnwpOldFrame(hwnd, msg, mp1, mp2); -} - -static MRESULT EXPENTRY WndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) -{ - // if slave mode, ignore mouse events and deliver them to a parent window - if (WinID != -1 && - ((msg >= WM_MOUSEFIRST && msg <= WM_MOUSELAST) || - (msg >= WM_EXTMOUSEFIRST && msg <= WM_EXTMOUSELAST))) { - WinPostMsg(HWNDFROMWINID(WinID), msg, mp1, mp2); - - return (MRESULT)TRUE; - } - - switch (msg) { - case WM_CLOSE: - mplayer_put_key(KEY_CLOSE_WIN); - - return 0; - - case WM_CHAR: - { - USHORT fsFlags = SHORT1FROMMP(mp1); - UCHAR uchScan = CHAR4FROMMP(mp1); - USHORT usCh = SHORT1FROMMP(mp2); - USHORT usVk = SHORT2FROMMP(mp2); - int mpkey; - - if (fsFlags & KC_KEYUP) - break; - - if (fsFlags & KC_SCANCODE) { - mpkey = lookup_keymap_table(m_keypad_map, uchScan); - if (mpkey) { - // distinguish KEY_KP0 and KEY_KPINS - if (mpkey == KEY_KP0 && usCh != '0') - mpkey = KEY_KPINS; - - // distinguish KEY_KPDEC and KEY_KPDEL - if (mpkey == KEY_KPDEC && usCh != '.') - mpkey = KEY_KPDEL; - - mplayer_put_key(mpkey); - - return (MRESULT)TRUE; - } - } - - if (fsFlags & KC_VIRTUALKEY) { - mpkey = lookup_keymap_table(m_vk_map, usVk); - if (mpkey) { - mplayer_put_key(mpkey); - - return (MRESULT)TRUE; - } - } - - if ((fsFlags & KC_CHAR) && !HIBYTE(usCh)) - mplayer_put_key(usCh); - - return (MRESULT)TRUE; - } - - case WM_BUTTON1DOWN: - case WM_BUTTON3DOWN: - case WM_BUTTON2DOWN: - case WM_BUTTON1DBLCLK: - case WM_BUTTON3DBLCLK: - case WM_BUTTON2DBLCLK: - if (WinQueryFocus(HWND_DESKTOP) != hwnd) - WinSetFocus(HWND_DESKTOP, hwnd); - else if (!vo_nomouse_input) - mplayer_put_key(lookup_keymap_table(m_mouse_map, msg)); - - return (MRESULT)TRUE; - - case WM_PAINT: - { - HPS hps; - RECTL rcl, rclDst; - PRECTL prcl = NULL; - HRGN hrgn, hrgnDst; - RGNRECT rgnCtl; - - // get a current movie area - kvaAdjustDstRect(&m_int.kvas.rclSrcRect, &rclDst); - - // get a current invalidated area - hps = WinBeginPaint(hwnd, NULLHANDLE, &rcl); - - // create a region for an invalidated area - hrgn = GpiCreateRegion(hps, 1, &rcl); - // create a region for a movie area - hrgnDst = GpiCreateRegion(hps, 1, &rclDst); - - // exclude a movie area from an invalidated area - GpiCombineRegion(hps, hrgn, hrgn, hrgnDst, CRGN_DIFF); - - // get rectangles from the region - rgnCtl.ircStart = 1; - rgnCtl.ulDirection = RECTDIR_LFRT_TOPBOT; - GpiQueryRegionRects(hps, hrgn, NULL, &rgnCtl, NULL); - - if (rgnCtl.crcReturned > 0) { - rgnCtl.crc = rgnCtl.crcReturned; - prcl = malloc(sizeof(RECTL) * rgnCtl.crcReturned); - } - - // draw black bar if needed - if (prcl && GpiQueryRegionRects(hps, hrgn, NULL, &rgnCtl, prcl)) { - int i; - - for (i = 0; i < rgnCtl.crcReturned; i++) - WinFillRect(hps, &prcl[i], CLR_BLACK); - } - - free(prcl); - - GpiDestroyRegion(hps, hrgnDst); - GpiDestroyRegion(hps, hrgn); - - WinEndPaint(hps); - - return 0; - } - } - - return WinDefWindowProc(hwnd, msg, mp1, mp2); -} - -// Change process type from VIO to PM to use PM APIs. -static void morphToPM(void) -{ - PPIB pib; - - DosGetInfoBlocks(NULL, &pib); - - // Change flag from VIO to PM: - if (pib->pib_ultype == 2) - pib->pib_ultype = 3; -} - -static int preinit(const char *arg) -{ - HWND hwndParent; - ULONG flFrameFlags; - ULONG kvaMode = 0; - - int fUseSnap = 0; - int fUseWO = 0; - int fUseDive = 0; - int fFixT23 = 0; - - const opt_t subopts[] = { - {"snap", OPT_ARG_BOOL, &fUseSnap, NULL}, - {"wo", OPT_ARG_BOOL, &fUseWO, NULL}, - {"dive", OPT_ARG_BOOL, &fUseDive, NULL}, - {"t23", OPT_ARG_BOOL, &fFixT23, NULL}, - {NULL, 0, NULL, NULL} - }; - - PCSZ pcszVideoModeStr[3] = {"DIVE", "WarpOverlay!", "SNAP"}; - - if (subopt_parse(arg, subopts) != 0) - return -1; - - morphToPM(); - - memset(&m_int, 0, sizeof(m_int)); - - m_int.hab = WinInitialize(0); - m_int.hmq = WinCreateMsgQueue(m_int.hab, 0); - - WinRegisterClass(m_int.hab, - WC_MPLAYER, - WndProc, - CS_SIZEREDRAW | CS_MOVENOTIFY, - sizeof(PVOID)); - - if (WinID == -1) { - hwndParent = HWND_DESKTOP; - flFrameFlags = FCF_SYSMENU | FCF_TITLEBAR | FCF_MINMAX | - FCF_SIZEBORDER | FCF_TASKLIST; - } else { - ULONG ulStyle; - - hwndParent = HWNDFROMWINID(WinID); - flFrameFlags = 0; - - // Prevent a parent window from painting over our window - ulStyle = WinQueryWindowULong(hwndParent, QWL_STYLE); - WinSetWindowULong(hwndParent, QWL_STYLE, ulStyle | WS_CLIPCHILDREN); - } - - m_int.hwndFrame = - WinCreateStdWindow(hwndParent, // parent window handle - WS_VISIBLE, // frame window style - &flFrameFlags, // window style - WC_MPLAYER, // class name - "", // window title - 0L, // default client style - NULLHANDLE, // resource in exe file - 1, // frame window id - &m_int.hwndClient); // client window handle - - if (m_int.hwndFrame == NULLHANDLE) - return -1; - - m_int.hwndSysMenu = WinWindowFromID(m_int.hwndFrame, FID_SYSMENU); - m_int.hwndTitleBar = WinWindowFromID(m_int.hwndFrame, FID_TITLEBAR); - m_int.hwndMinMax = WinWindowFromID(m_int.hwndFrame, FID_MINMAX); - - m_int.fFixT23 = fFixT23; - - if (m_int.fFixT23) - m_int.pfnwpOldFrame = WinSubclassWindow(m_int.hwndFrame, - NewFrameWndProc); - - if (!!fUseSnap + !!fUseWO + !!fUseDive > 1) - mp_msg(MSGT_VO, MSGL_WARN,"KVA: Multiple mode specified!!!\n"); - - if (fUseSnap) - kvaMode = KVAM_SNAP; - else if (fUseWO) - kvaMode = KVAM_WO; - else if (fUseDive) - kvaMode = KVAM_DIVE; - else - kvaMode = KVAM_AUTO; - - if (kvaInit(kvaMode, m_int.hwndClient, vo_colorkey)) { - mp_msg(MSGT_VO, MSGL_ERR, "KVA: Init failed!!!\n"); - - return -1; - } - - kvaCaps(&m_int.kvac); - - mp_msg(MSGT_VO, MSGL_V, "KVA: Selected video mode = %s\n", - pcszVideoModeStr[m_int.kvac.ulMode - 1]); - - kvaDisableScreenSaver(); - - // Might cause PM DLLs to be loaded which incorrectly enable SIG_FPE, - // so mask off all floating-point exceptions. - _control87(MCW_EM, MCW_EM); - - return 0; -} - -static void uninit(void) -{ - kvaEnableScreenSaver(); - - imgFree(); - - sws_freeContext(m_int.sws); - - if (m_int.hwndFrame != NULLHANDLE) { - kvaResetAttr(); - kvaDone(); - - if (m_int.fFixT23) - WinSubclassWindow(m_int.hwndFrame, m_int.pfnwpOldFrame); - - WinDestroyWindow(m_int.hwndFrame); - } - - WinDestroyMsgQueue(m_int.hmq); - WinTerminate(m_int.hab); -} - -static int config(uint32_t width, uint32_t height, - uint32_t d_width, uint32_t d_height, - uint32_t flags, char *title, uint32_t format) -{ - RECTL rcl; - - mp_msg(MSGT_VO, MSGL_V, - "KVA: Using 0x%X (%s) image format, vo_config_count = %d\n", - format, vo_format_name(format), vo_config_count); - - imgFree(); - - if (query_format_info(format, &m_int.fHWAccel, &m_int.fcc, &m_int.bpp, - &m_int.nChromaShift)) - return 1; - - m_int.iImageFormat = format; - - // if there is no hw accel for given format, - // try any format supported by hw accel - if (!m_int.fHWAccel) { - int dstFormat = 0; - - sws_freeContext(m_int.sws); - - if (m_int.kvac.ulInputFormatFlags & KVAF_YV12) - dstFormat = IMGFMT_YV12; - else if (m_int.kvac.ulInputFormatFlags & KVAF_YUY2) - dstFormat = IMGFMT_YUY2; - else if (m_int.kvac.ulInputFormatFlags & KVAF_YVU9) - dstFormat = IMGFMT_YVU9; - else if (m_int.kvac.ulInputFormatFlags & KVAF_BGR24) - dstFormat = IMGFMT_BGR24; - else if (m_int.kvac.ulInputFormatFlags & KVAF_BGR16) - dstFormat = IMGFMT_BGR16; - else if (m_int.kvac.ulInputFormatFlags & KVAF_BGR15) - dstFormat = IMGFMT_BGR15; - - if (query_format_info(dstFormat, NULL, &m_int.fcc, NULL, NULL)) - return 1; - - m_int.sws = sws_getContextFromCmdLine(width, height, format, - width, height, dstFormat); - } - - mp_msg(MSGT_VO, MSGL_V, "KVA: Selected FOURCC = %.4s\n", (char *)&m_int.fcc); - - m_int.kvas.ulLength = sizeof(KVASETUP); - m_int.kvas.szlSrcSize.cx = width; - m_int.kvas.szlSrcSize.cy = height; - m_int.kvas.rclSrcRect.xLeft = 0; - m_int.kvas.rclSrcRect.yTop = 0; - m_int.kvas.rclSrcRect.xRight = width; - m_int.kvas.rclSrcRect.yBottom = height; - m_int.kvas.ulRatio = vo_keepaspect ? KVAR_FORCEANY : KVAR_NONE; - m_int.kvas.ulAspectWidth = d_width; - m_int.kvas.ulAspectHeight = d_height; - m_int.kvas.fccSrcColor = m_int.fcc; - m_int.kvas.fDither = TRUE; - - if (kvaSetup(&m_int.kvas)) { - mp_msg(MSGT_VO, MSGL_ERR, "KVA: Setup failed!!!\n"); - - return 1; - } - - m_int.lStride = width * m_int.bpp; - - imgCreate(); - - if (WinID == -1) { - WinSetWindowText(m_int.hwndFrame, title); - - // initialize 'vo_fs' only once at first config() call - if (vo_config_count == 0) - vo_fs = flags & VOFLAG_FULLSCREEN; - - // workaround for T23 laptop with S3 Video by Franz Bakan - if (!vo_fs && m_int.fFixT23) { - d_width++; - d_height++; - } - - m_int.rclDst.xLeft = ((LONG)vo_screenwidth - (LONG)d_width) / 2; - m_int.rclDst.yBottom = ((LONG)vo_screenheight - (LONG)d_height) / 2; - m_int.rclDst.xRight = m_int.rclDst.xLeft + d_width; - m_int.rclDst.yTop = m_int.rclDst.yBottom + d_height; - - if (vo_fs) { - d_width = vo_screenwidth; - d_height = vo_screenheight; - - // when -fs option is used without this, title bar is not highlighted - WinSetActiveWindow(HWND_DESKTOP, m_int.hwndFrame); - - WinSetParent(m_int.hwndSysMenu, HWND_OBJECT, FALSE); - WinSetParent(m_int.hwndTitleBar, HWND_OBJECT, FALSE); - WinSetParent(m_int.hwndMinMax, HWND_OBJECT, FALSE); - - setAspectRatio(KVAR_FORCEANY); - } - - rcl.xLeft = ((LONG)vo_screenwidth - (LONG)d_width) / 2; - rcl.yBottom = ((LONG)vo_screenheight - (LONG)d_height) /2 ; - rcl.xRight = rcl.xLeft + d_width; - rcl.yTop = rcl.yBottom + d_height; - } else { - vo_fs = 0; - - WinQueryWindowRect(HWNDFROMWINID(WinID), &m_int.rclDst); - rcl = m_int.rclDst; - } - - WinCalcFrameRect(m_int.hwndFrame, &rcl, FALSE); - - WinSetWindowPos(m_int.hwndFrame, HWND_TOP, - rcl.xLeft, rcl.yBottom, - rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, - SWP_SIZE | SWP_MOVE | SWP_ZORDER | SWP_SHOW | - (WinID == -1 ? SWP_ACTIVATE : 0)); - - WinInvalidateRect(m_int.hwndFrame, NULL, TRUE); - - return 0; -} - -static uint32_t get_image(mp_image_t *mpi) -{ - if (m_int.iImageFormat != mpi->imgfmt) - return VO_FALSE; - - if (mpi->type == MP_IMGTYPE_STATIC || mpi->type == MP_IMGTYPE_TEMP) { - if (mpi->flags & MP_IMGFLAG_PLANAR) { - mpi->planes[1] = m_int.planes[1]; - mpi->planes[2] = m_int.planes[2]; - - mpi->stride[1] = m_int.stride[1]; - mpi->stride[2] = m_int.stride[2]; - } - - mpi->planes[0] = m_int.planes[0]; - mpi->stride[0] = m_int.stride[0]; - mpi->flags |= MP_IMGFLAG_DIRECT; - - return VO_TRUE; - } - - return VO_FALSE; -} - -static uint32_t draw_image(mp_image_t *mpi) -{ - // if -dr or -slices then do nothing: - if (mpi->flags & (MP_IMGFLAG_DIRECT | MP_IMGFLAG_DRAW_CALLBACK)) - return VO_TRUE; - - draw_slice(mpi->planes, mpi->stride, mpi->w, mpi->h, mpi->x, mpi->y); - - return VO_TRUE; -} - -static int query_format(uint32_t format) -{ - BOOL fHWAccel; - int res; - - if (query_format_info(format, &fHWAccel, NULL, NULL, NULL)) - return 0; - - res = VFCAP_CSP_SUPPORTED | VFCAP_OSD; - if (fHWAccel) { - res |= VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_HWSCALE_UP; - - if (!m_int.fFixT23) - res |= VFCAP_HWSCALE_DOWN; - } - - return res; -} - -static int fs_toggle(void) -{ - RECTL rcl; - - vo_fs = !vo_fs; - - if (vo_fs) { - SWP swp; - - WinQueryWindowPos(m_int.hwndFrame, &swp); - m_int.rclDst.xLeft = swp.x; - m_int.rclDst.yBottom = swp.y; - m_int.rclDst.xRight = m_int.rclDst.xLeft + swp.cx; - m_int.rclDst.yTop = m_int.rclDst.yBottom + swp.cy; - WinCalcFrameRect(m_int.hwndFrame, &m_int.rclDst, TRUE); - - if (WinID != -1) - WinSetParent(m_int.hwndFrame, HWND_DESKTOP, FALSE); - - WinSetParent(m_int.hwndSysMenu, HWND_OBJECT, FALSE); - WinSetParent(m_int.hwndTitleBar, HWND_OBJECT, FALSE); - WinSetParent(m_int.hwndMinMax, HWND_OBJECT, FALSE); - - rcl.xLeft = 0; - rcl.yBottom = 0; - rcl.xRight = vo_screenwidth; - rcl.yTop = vo_screenheight; - - setAspectRatio(KVAR_FORCEANY); - } else { - if (WinID != -1) - WinSetParent(m_int.hwndFrame, HWNDFROMWINID(WinID), TRUE); - - WinSetParent(m_int.hwndSysMenu, m_int.hwndFrame, FALSE); - WinSetParent(m_int.hwndTitleBar, m_int.hwndFrame, FALSE); - WinSetParent(m_int.hwndMinMax, m_int.hwndFrame, FALSE); - - rcl = m_int.rclDst; - - setAspectRatio(vo_keepaspect ? KVAR_FORCEANY : KVAR_NONE); - } - - WinCalcFrameRect(m_int.hwndFrame, &rcl, FALSE); - - WinSetWindowPos(m_int.hwndFrame, HWND_TOP, - rcl.xLeft, rcl.yBottom, - rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, - SWP_SIZE | SWP_MOVE | SWP_ZORDER | SWP_SHOW | - (WinID == -1 ? SWP_ACTIVATE : 0)); - - return VO_TRUE; -} - -static int color_ctrl_set(char *what, int value) -{ - ULONG ulAttr; - ULONG ulValue; - - if (!strcmp(what, "brightness")) - ulAttr = KVAA_BRIGHTNESS; - else if (!strcmp(what, "contrast")) - ulAttr = KVAA_CONTRAST; - else if (!strcmp(what, "hue")) - ulAttr = KVAA_HUE; - else if (!strcmp(what, "saturation")) - ulAttr = KVAA_SATURATION; - else - return VO_NOTIMPL; - - ulValue = (value + 100) * 255 / 200; - - if (kvaSetAttr(ulAttr, &ulValue)) - return VO_NOTIMPL; - - return VO_TRUE; -} - -static int color_ctrl_get(char *what, int *value) -{ - ULONG ulAttr; - ULONG ulValue; - - if (!strcmp(what, "brightness")) - ulAttr = KVAA_BRIGHTNESS; - else if (!strcmp(what, "contrast")) - ulAttr = KVAA_CONTRAST; - else if (!strcmp(what, "hue")) - ulAttr = KVAA_HUE; - else if (!strcmp(what, "saturation")) - ulAttr = KVAA_SATURATION; - else - return VO_NOTIMPL; - - if (kvaQueryAttr(ulAttr, &ulValue)) - return VO_NOTIMPL; - - // add 1 to adjust range - *value = ((ulValue + 1) * 200 / 255) - 100; - - return VO_TRUE; -} - -static int control(uint32_t request, void *data) -{ - switch (request) { - case VOCTRL_GET_IMAGE: - return get_image(data); - - case VOCTRL_DRAW_IMAGE: - return draw_image(data); - - case VOCTRL_QUERY_FORMAT: - return query_format(*(uint32_t *)data); - - case VOCTRL_FULLSCREEN: - return fs_toggle(); - - case VOCTRL_SET_EQUALIZER: - { - struct voctrl_set_equalizer_args *args = data; - color_ctrl_set(args->name, args->value); - } - - case VOCTRL_GET_EQUALIZER: - { - struct voctrl_get_equalizer_args *args = data; - return color_ctrl_get(args->name, args->valueptr); - } - - case VOCTRL_UPDATE_SCREENINFO: - vo_screenwidth = m_int.kvac.cxScreen; - vo_screenheight = m_int.kvac.cyScreen; - - aspect_save_screenres(vo_screenwidth, vo_screenheight); - - return VO_TRUE; - } - - return VO_NOTIMPL; -} - -static int draw_frame(uint8_t *src[]) -{ - return VO_ERROR; -} - -static int draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y) -{ - uint8_t *s; - uint8_t *d; - - // copy packed or Y - d = m_int.planes[0] + m_int.stride[0] * y + x; - s = src[0]; - mem2agpcpy_pic(d, s, w * m_int.bpp, h, m_int.stride[0], stride[0]); - - // YV12 or YVU9 - if (m_int.nChromaShift) { - w >>= m_int.nChromaShift; h >>= m_int.nChromaShift; - x >>= m_int.nChromaShift; y >>= m_int.nChromaShift; - - // copy U - d = m_int.planes[1] + m_int.stride[1] * y + x; - s = src[1]; - mem2agpcpy_pic(d, s, w, h, m_int.stride[1], stride[1]); - - // copy V - d = m_int.planes[2] + m_int.stride[2] * y + x; - s = src[2]; - mem2agpcpy_pic(d, s, w, h, m_int.stride[2], stride[2]); - } - - return 0; -} - -#define vo_draw_alpha(imgfmt) \ - vo_draw_alpha_##imgfmt(w, h, src, srca, stride, \ - m_int.planes[0] + m_int.stride[0] * y0 + m_int.bpp * x0, \ - m_int.stride[0]) - -static void draw_alpha(int x0, int y0, int w, int h, - unsigned char *src, unsigned char *srca, int stride) -{ - switch (m_int.iImageFormat) { - case IMGFMT_YV12: - case IMGFMT_YVU9: - vo_draw_alpha(yv12); - break; - - case IMGFMT_YUY2: - vo_draw_alpha(yuy2); - break; - - case IMGFMT_BGR24: - vo_draw_alpha(rgb24); - break; - - case IMGFMT_BGR16: - vo_draw_alpha(rgb16); - break; - - case IMGFMT_BGR15: - vo_draw_alpha(rgb15); - break; - } -} - -static void draw_osd(void) -{ - vo_draw_text(SRC_WIDTH, SRC_HEIGHT, draw_alpha); -} - -static void flip_page(void) -{ - imgDisplay(); -} - -static void check_events(void) -{ - QMSG qm; - - // On slave mode, we need to change our window size according to a - // parent window size - if (WinID != -1) { - RECTL rcl; - - WinQueryWindowRect(HWNDFROMWINID(WinID), &rcl); - - if (rcl.xLeft != m_int.rclParent.xLeft || - rcl.yBottom != m_int.rclParent.yBottom || - rcl.xRight != m_int.rclParent.xRight || - rcl.yTop != m_int.rclParent.yTop) { - WinSetWindowPos(m_int.hwndFrame, NULLHANDLE, - rcl.xLeft, rcl.yBottom, - rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, - SWP_SIZE | SWP_MOVE); - - m_int.rclParent = rcl; - } - } - - while (WinPeekMsg(m_int.hab, &qm, NULLHANDLE, 0, 0, PM_REMOVE)) - WinDispatchMsg(m_int.hab, &qm); -} diff -Nru mplayer2-2.0-426-gc32b3ed/libvo/vo_png.c mplayer2-2.0-554-gf63dbad/libvo/vo_png.c --- mplayer2-2.0-426-gc32b3ed/libvo/vo_png.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libvo/vo_png.c 2012-05-17 14:38:00.000000000 +0000 @@ -63,8 +63,24 @@ } mp_msg(MSGT_VO,MSGL_DBG2, "PNG Compression level %i\n", z_compression); - + uninit(); + struct AVCodec *png_codec = avcodec_find_encoder(CODEC_ID_PNG); + if (!png_codec) + goto error; + avctx = avcodec_alloc_context3(png_codec); + if (!avctx) + goto error; + avctx->width = width; + avctx->height = height; + avctx->pix_fmt = imgfmt2pixfmt(format); + avctx->compression_level = z_compression; + if (avcodec_open2(avctx, png_codec, NULL) < 0) + goto error; return 0; + + error: + uninit(); + return -1; } @@ -85,9 +101,6 @@ return 1; } - avctx->width = mpi->w; - avctx->height = mpi->h; - avctx->pix_fmt = imgfmt2pixfmt(mpi->imgfmt); pic.data[0] = mpi->planes[0]; pic.linesize[0] = mpi->stride[0]; buffersize = mpi->w * mpi->h * 8; @@ -137,8 +150,10 @@ return 0; } -static void uninit(void){ - avcodec_close(avctx); +static void uninit(void) +{ + if (avctx) + avcodec_close(avctx); av_freep(&avctx); av_freep(&outbuffer); outbuffer_size = 0; @@ -165,12 +180,6 @@ if (subopt_parse(arg, subopts) != 0) { return -1; } - avctx = avcodec_alloc_context(); - if (avcodec_open(avctx, avcodec_find_encoder(CODEC_ID_PNG)) < 0) { - uninit(); - return -1; - } - avctx->compression_level = z_compression; return 0; } diff -Nru mplayer2-2.0-426-gc32b3ed/libvo/vo_pnm.c mplayer2-2.0-554-gf63dbad/libvo/vo_pnm.c --- mplayer2-2.0-426-gc32b3ed/libvo/vo_pnm.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libvo/vo_pnm.c 2012-05-17 14:38:00.000000000 +0000 @@ -40,6 +40,7 @@ #include "video_out.h" #include "video_out_internal.h" #include "mplayer.h" /* for exit_player_bad() */ +#include "osdep/io.h" /* ------------------------------------------------------------------------- */ @@ -199,16 +200,11 @@ static void pnm_mkdir(char *buf, int verbose) { struct stat stat_p; -/* Silly MING32 bug workaround */ -#ifndef __MINGW32__ if ( mkdir(buf, 0755) < 0 ) { -#else - if ( mkdir(buf) < 0 ) { -#endif switch (errno) { /* use switch in case other errors need to be caught and handled in the future */ case EEXIST: - if ( stat(buf, &stat_p ) < 0 ) { + if ( mp_stat(buf, &stat_p ) < 0 ) { mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, _("This error has occurred"), strerror(errno) ); mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, diff -Nru mplayer2-2.0-426-gc32b3ed/libvo/vo_quartz.c mplayer2-2.0-554-gf63dbad/libvo/vo_quartz.c --- mplayer2-2.0-426-gc32b3ed/libvo/vo_quartz.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libvo/vo_quartz.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,1371 +0,0 @@ -/* - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/** - \author Nicolas Plourde - - Copyright (c) Nicolas Plourde - April 2004 - - YUV support Copyright (C) 2004 Romain Dolbeau - - \brief MPlayer Mac OSX Quartz video out module. - - \todo: -screen overlay output - -fit osd in black bar when available - -fix RGB32 - -(add sugestion here) -*/ - -//SYS -#include - -//OSX -#include -#include - -//MPLAYER -#include "config.h" -#include "fastmemcpy.h" -#include "video_out.h" -#include "video_out_internal.h" -#include "aspect.h" -#include "mp_msg.h" -#include "m_option.h" -#include "mp_fifo.h" -#include "mpbswap.h" -#include "sub/sub.h" - -#include "input/input.h" -#include "input/keycodes.h" - -#include "osx_common.h" - -static const vo_info_t info = -{ - "Mac OSX (Quartz)", - "quartz", - "Nicolas Plourde , Romain Dolbeau ", - "" -}; - -const LIBVO_EXTERN(quartz) - -static uint32_t image_depth; -static uint32_t image_format; -static uint32_t image_size; -static uint32_t image_buffer_size; -static char *image_data; - -static ImageSequence seqId; -static CodecType image_qtcodec; -static PlanarPixmapInfoYUV420 *P = NULL; -static struct -{ - ImageDescriptionHandle desc; - Handle extension_colr; - Handle extension_fiel; - Handle extension_clap; - Handle extension_pasp; -} yuv_qt_stuff; -static MatrixRecord matrix; -static int EnterMoviesDone = 0; -static int get_image_done = 0; - -static int vo_quartz_fs; // we are in fullscreen - -static int winLevel = 1; -int levelList[] = -{ - kCGDesktopWindowLevelKey, - kCGNormalWindowLevelKey, - kCGScreenSaverWindowLevelKey -}; - -static int int_pause = 0; -static float winAlpha = 1; -static int mouseHide = FALSE; -static float winSizeMult = 1; - -static int device_id = 0; - -static short fs_res_x = 0; -static short fs_res_y = 0; - -static WindowRef theWindow = NULL; -static WindowGroupRef winGroup = NULL; -static CGRect bounds; -static CGDirectDisplayID displayId = 0; -static CFDictionaryRef originalMode = NULL; - -static CGDataProviderRef dataProviderRef = NULL; -static CGImageRef image = NULL; - -static Rect imgRect; // size of the original image (unscaled) -static Rect dstRect; // size of the displayed image (after scaling) -static Rect winRect; // size of the window containg the displayed image (include padding) -static Rect oldWinRect; // size of the window containg the displayed image (include padding) when NOT in FS mode -static Rect oldWinBounds; - -static MenuRef windMenu; -static MenuRef movMenu; -static MenuRef aspectMenu; - -static int lastScreensaverUpdate = 0; -static int lastMouseHide = 0; - -enum -{ - kHalfScreenCmd = 2, - kNormalScreenCmd = 3, - kDoubleScreenCmd = 4, - kFullScreenCmd = 5, - kKeepAspectCmd = 6, - kAspectOrgCmd = 7, - kAspectFullCmd = 8, - kAspectWideCmd = 9, - kPanScanCmd = 10 -}; - -//PROTOTYPE///////////////////////////////////////////////////////////////// -static OSStatus KeyEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData); -static OSStatus MouseEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData); -static OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData); -void window_resized(void); -void window_ontop(void); -void window_fullscreen(void); -void window_panscan(void); - -static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, unsigned char *srca, int stride) -{ - switch (image_format) - { - case IMGFMT_RGB32: - vo_draw_alpha_rgb32(w, h, src, srca, stride, image_data + 4 * (y0 * imgRect.right + x0), 4 * imgRect.right); - break; - case IMGFMT_YV12: - case IMGFMT_IYUV: - case IMGFMT_I420: - vo_draw_alpha_yv12(w, h, src, srca, stride, ((char *)P) + be2me_32(P->componentInfoY.offset) + x0 + y0 * imgRect.right, imgRect.right); - break; - case IMGFMT_UYVY: - vo_draw_alpha_uyvy(w, h, src, srca, stride, ((char *)P) + (x0 + y0 * imgRect.right) * 2, imgRect.right * 2); - break; - case IMGFMT_YUY2: - vo_draw_alpha_yuy2(w, h, src, srca, stride, ((char *)P) + (x0 + y0 * imgRect.right) * 2, imgRect.right * 2); - break; - } -} - -//default keyboard event handler -static OSStatus KeyEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData) -{ - OSStatus result = noErr; - UInt32 class = GetEventClass(event); - UInt32 kind = GetEventKind(event); - - result = CallNextEventHandler(nextHandler, event); - - if (class == kEventClassKeyboard) - { - char macCharCodes; - UInt32 macKeyCode; - UInt32 macKeyModifiers; - - GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(macCharCodes), NULL, &macCharCodes); - GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(macKeyCode), NULL, &macKeyCode); - GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(macKeyModifiers), NULL, &macKeyModifiers); - - if (macKeyModifiers != 256) - { - if (kind == kEventRawKeyRepeat || kind == kEventRawKeyDown) - { - int key = convert_key(macKeyCode, macCharCodes); - - if (key != -1) - mplayer_put_key(key); - } - } - else if (macKeyModifiers == 256) - { - switch (macCharCodes) - { - case '[': SetWindowAlpha(theWindow, winAlpha -= 0.05); break; - case ']': SetWindowAlpha(theWindow, winAlpha += 0.05); break; - } - } - else - result = eventNotHandledErr; - } - - return result; -} - -//default mouse event handler -static OSStatus MouseEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData) -{ - OSStatus result = noErr; - UInt32 class = GetEventClass(event); - UInt32 kind = GetEventKind(event); - - result = CallNextEventHandler(nextHandler, event); - - if (class == kEventClassMouse) - { - WindowPtr tmpWin; - Point mousePos; - Point winMousePos; - - GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, 0, sizeof(mousePos), 0, &mousePos); - GetEventParameter(event, kEventParamWindowMouseLocation, typeQDPoint, 0, sizeof(winMousePos), 0, &winMousePos); - - switch (kind) - { - case kEventMouseMoved: - { - if (vo_quartz_fs) - { - CGDisplayShowCursor(displayId); - mouseHide = FALSE; - } - } - break; - - case kEventMouseWheelMoved: - { - int wheel; - short part; - - GetEventParameter(event, kEventParamMouseWheelDelta, typeSInt32, 0, sizeof(wheel), 0, &wheel); - - part = FindWindow(mousePos, &tmpWin); - - if (part == inContent) - { - if (wheel > 0) - mplayer_put_key(MOUSE_BTN3); - else - mplayer_put_key(MOUSE_BTN4); - } - } - break; - - case kEventMouseDown: - case kEventMouseUp: - { - EventMouseButton button; - short part; - Rect bounds; - - GetWindowPortBounds(theWindow, &bounds); - GetEventParameter(event, kEventParamMouseButton, typeMouseButton, 0, sizeof(button), 0, &button); - - part = FindWindow(mousePos, &tmpWin); - if (kind == kEventMouseUp) - { - if (part != inContent) - break; - switch (button) - { - case kEventMouseButtonPrimary: - mplayer_put_key(MOUSE_BTN0); - break; - case kEventMouseButtonSecondary: - mplayer_put_key(MOUSE_BTN2); - break; - case kEventMouseButtonTertiary: - mplayer_put_key(MOUSE_BTN1); - break; - - default: - result = eventNotHandledErr; - break; - } - break; - } - if (winMousePos.h > bounds.right - 15 && winMousePos.v > bounds.bottom) - { - if (!vo_quartz_fs) - { - Rect newSize; - - ResizeWindow(theWindow, mousePos, NULL, &newSize); - } - } - else if (part == inMenuBar) - { - MenuSelect(mousePos); - HiliteMenu(0); - } - else if (part == inContent) - { - switch (button) - { - case kEventMouseButtonPrimary: - mplayer_put_key(MOUSE_BTN0 | MP_KEY_DOWN); - break; - case kEventMouseButtonSecondary: - mplayer_put_key(MOUSE_BTN2 | MP_KEY_DOWN); - break; - case kEventMouseButtonTertiary: - mplayer_put_key(MOUSE_BTN1 | MP_KEY_DOWN); - break; - - default: - result = eventNotHandledErr; - break; - } - } - } - break; - - case kEventMouseDragged: - break; - - default: - result = eventNotHandledErr; - break; - } - } - - return result; -} - -static void set_winSizeMult(float mult) -{ - int d_width, d_height; - aspect(&d_width, &d_height, A_NOZOOM); - - if (vo_quartz_fs) - { - vo_fs = !vo_fs; - window_fullscreen(); - } - - winSizeMult = mult; - SizeWindow(theWindow, d_width * mult, d_height * mult, 1); - window_resized(); -} - -//default window event handler -static OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData) -{ - OSStatus result = noErr; - UInt32 class = GetEventClass(event); - UInt32 kind = GetEventKind(event); - - result = CallNextEventHandler(nextHandler, event); - - if (class == kEventClassCommand) - { - HICommand theHICommand; - - GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, sizeof(theHICommand), NULL, &theHICommand); - - switch (theHICommand.commandID) - { - case kHICommandQuit: - mplayer_put_key(KEY_CLOSE_WIN); - break; - - case kHalfScreenCmd: - set_winSizeMult(0.5); - break; - - case kNormalScreenCmd: - set_winSizeMult(1); - break; - - case kDoubleScreenCmd: - set_winSizeMult(2); - break; - - case kFullScreenCmd: - vo_fs = !vo_fs; - window_fullscreen(); - break; - - case kKeepAspectCmd: - vo_keepaspect = !vo_keepaspect; - CheckMenuItem(aspectMenu, 1, vo_keepaspect); - window_resized(); - break; - - case kAspectOrgCmd: - change_movie_aspect(-1); - break; - - case kAspectFullCmd: - change_movie_aspect(4.0 / 3.0); - break; - - case kAspectWideCmd: - change_movie_aspect(16.0 / 9.0); - break; - - case kPanScanCmd: - vo_panscan = !vo_panscan; - CheckMenuItem(aspectMenu, 2, vo_panscan); - window_panscan(); - window_resized(); - break; - - default: - result = eventNotHandledErr; - break; - } - } - else if (class == kEventClassWindow) - { - WindowRef window; - Rect rectWindow = { 0, 0, 0, 0 }; - - GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(window), NULL, &window); - - if (window) - { - GetWindowBounds(window, kWindowGlobalPortRgn, &rectWindow); - } - - switch (kind) - { - case kEventWindowClosed: - theWindow = NULL; - mplayer_put_key(KEY_CLOSE_WIN); - break; - - // resize window - case kEventWindowZoomed: - case kEventWindowBoundsChanged: - window_resized(); - flip_page(); - window_resized(); - break; - - default: - result = eventNotHandledErr; - break; - } - } - - return result; -} - -static void quartz_CreateWindow(uint32_t d_width, uint32_t d_height, WindowAttributes windowAttrs) -{ - CFStringRef titleKey; - CFStringRef windowTitle; - OSStatus result; - - MenuItemIndex index; - CFStringRef movMenuTitle; - CFStringRef aspMenuTitle; - - const EventTypeSpec win_events[] = { - {kEventClassWindow, kEventWindowClosed}, - {kEventClassWindow, kEventWindowBoundsChanged}, - {kEventClassCommand, kEventCommandProcess} - }; - - const EventTypeSpec key_events[] = { - {kEventClassKeyboard, kEventRawKeyDown}, - {kEventClassKeyboard, kEventRawKeyRepeat} - }; - - const EventTypeSpec mouse_events[] = { - {kEventClassMouse, kEventMouseMoved}, - {kEventClassMouse, kEventMouseWheelMoved}, - {kEventClassMouse, kEventMouseDown}, - {kEventClassMouse, kEventMouseUp}, - {kEventClassMouse, kEventMouseDragged} - }; - - SetRect(&winRect, 0, 0, d_width, d_height); - SetRect(&oldWinRect, 0, 0, d_width, d_height); - SetRect(&dstRect, 0, 0, d_width, d_height); - - // Clear Menu Bar - ClearMenuBar(); - - // Create Window Menu - CreateStandardWindowMenu(0, &windMenu); - InsertMenu(windMenu, 0); - - // Create Movie Menu - CreateNewMenu(1004, 0, &movMenu); - movMenuTitle = CFSTR("Movie"); - SetMenuTitleWithCFString(movMenu, movMenuTitle); - - AppendMenuItemTextWithCFString(movMenu, CFSTR("Half Size"), 0, kHalfScreenCmd, &index); - SetMenuItemCommandKey(movMenu, index, 0, '0'); - - AppendMenuItemTextWithCFString(movMenu, CFSTR("Normal Size"), 0, kNormalScreenCmd, &index); - SetMenuItemCommandKey(movMenu, index, 0, '1'); - - AppendMenuItemTextWithCFString(movMenu, CFSTR("Double Size"), 0, kDoubleScreenCmd, &index); - SetMenuItemCommandKey(movMenu, index, 0, '2'); - - AppendMenuItemTextWithCFString(movMenu, CFSTR("Full Size"), 0, kFullScreenCmd, &index); - SetMenuItemCommandKey(movMenu, index, 0, 'F'); - - AppendMenuItemTextWithCFString(movMenu, NULL, kMenuItemAttrSeparator, 0, &index); - - AppendMenuItemTextWithCFString(movMenu, CFSTR("Aspect Ratio"), 0, 0, &index); - - //// Create Aspect Ratio Sub Menu - CreateNewMenu(0, 0, &aspectMenu); - aspMenuTitle = CFSTR("Aspect Ratio"); - SetMenuTitleWithCFString(aspectMenu, aspMenuTitle); - SetMenuItemHierarchicalMenu(movMenu, 6, aspectMenu); - - AppendMenuItemTextWithCFString(aspectMenu, CFSTR("Keep"), 0, kKeepAspectCmd, &index); - CheckMenuItem(aspectMenu, 1, vo_keepaspect); - AppendMenuItemTextWithCFString(aspectMenu, CFSTR("Pan-Scan"), 0, kPanScanCmd, &index); - CheckMenuItem(aspectMenu, 2, vo_panscan); - AppendMenuItemTextWithCFString(aspectMenu, NULL, kMenuItemAttrSeparator, 0, &index); - AppendMenuItemTextWithCFString(aspectMenu, CFSTR("Original"), 0, kAspectOrgCmd, &index); - AppendMenuItemTextWithCFString(aspectMenu, CFSTR("4:3"), 0, kAspectFullCmd, &index); - AppendMenuItemTextWithCFString(aspectMenu, CFSTR("16:9"), 0, kAspectWideCmd, &index); - - InsertMenu(movMenu, GetMenuID(windMenu)); //insert before Window menu - - DrawMenuBar(); - - // create window - CreateNewWindow(kDocumentWindowClass, windowAttrs, &winRect, &theWindow); - - CreateWindowGroup(0, &winGroup); - SetWindowGroup(theWindow, winGroup); - - // Set window title - titleKey = CFSTR("MPlayer - The Movie Player"); - windowTitle = CFCopyLocalizedString(titleKey, NULL); - result = SetWindowTitleWithCFString(theWindow, windowTitle); - CFRelease(titleKey); - CFRelease(windowTitle); - - // Install event handler - InstallApplicationEventHandler(NewEventHandlerUPP(KeyEventHandler), GetEventTypeCount(key_events), key_events, NULL, NULL); - InstallApplicationEventHandler(NewEventHandlerUPP(MouseEventHandler), GetEventTypeCount(mouse_events), mouse_events, NULL, NULL); - InstallWindowEventHandler(theWindow, NewEventHandlerUPP(WindowEventHandler), GetEventTypeCount(win_events), win_events, theWindow, NULL); -} - -static void update_screen_info(void) -{ - CGRect displayRect; - CGDisplayCount displayCount; - CGDirectDisplayID *displays; - // Display IDs might not be consecutive, get the list of all devices up to # device_id - displayCount = device_id + 1; - displays = malloc(sizeof(*displays) * displayCount); - if (kCGErrorSuccess != CGGetActiveDisplayList(displayCount, displays, &displayCount) || displayCount < device_id + 1) { - mp_msg(MSGT_VO, MSGL_FATAL, "Quartz error: Device ID %d do not exist, falling back to main device.\n", device_id); - displayId = kCGDirectMainDisplay; - device_id = 0; - } - else - { - displayId = displays[device_id]; - } - free(displays); - - displayRect = CGDisplayBounds(displayId); - xinerama_x = displayRect.origin.x; - xinerama_y = displayRect.origin.y; - vo_screenwidth = displayRect.size.width; - vo_screenheight = displayRect.size.height; - aspect_save_screenres(vo_screenwidth, vo_screenheight); -} - -static void free_video_specific(void) -{ - if (seqId) CDSequenceEnd(seqId); - seqId = 0; - free(image_data); - image_data = NULL; - free(P); - P = NULL; - CGDataProviderRelease(dataProviderRef); - dataProviderRef = NULL; - CGImageRelease(image); - image = NULL; -} - -static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) -{ - WindowAttributes windowAttrs; - OSErr qterr; - CGRect tmpBounds; - - free_video_specific(); - - vo_dwidth = d_width *= winSizeMult; - vo_dheight = d_height *= winSizeMult; - config_movie_aspect((float)d_width / d_height); - - // misc mplayer setup///////////////////////////////////////////////////// - SetRect(&imgRect, 0, 0, width, height); - switch (image_format) - { - case IMGFMT_RGB32: - image_depth = 32; - break; - case IMGFMT_YV12: - case IMGFMT_IYUV: - case IMGFMT_I420: - case IMGFMT_UYVY: - case IMGFMT_YUY2: - image_depth = 16; - break; - } - image_size = (imgRect.right * imgRect.bottom * image_depth + 7) / 8; - - image_data = malloc(image_size); - - // Create player window////////////////////////////////////////////////// - windowAttrs = kWindowStandardDocumentAttributes - | kWindowStandardHandlerAttribute - | kWindowLiveResizeAttribute; - - windowAttrs &= ~kWindowResizableAttribute; - - if (theWindow == NULL) - { - CGContextRef context; - - quartz_CreateWindow(d_width, d_height, windowAttrs); - - if (theWindow == NULL) - { - mp_msg(MSGT_VO, MSGL_FATAL, "Quartz error: Couldn't create window !!!!!\n"); - return -1; - } - tmpBounds = CGRectMake(0, 0, winRect.right, winRect.bottom); - QDBeginCGContext(GetWindowPort(theWindow), &context); - CGContextFillRect(context, tmpBounds); - QDEndCGContext(GetWindowPort(theWindow), &context); - } - else - { - HideWindow(theWindow); - ChangeWindowAttributes(theWindow, ~windowAttrs, windowAttrs); - SetRect(&winRect, 0, 0, d_width, d_height); - SetRect(&oldWinRect, 0, 0, d_width, d_height); - SizeWindow(theWindow, d_width, d_height, 1); - } - - switch (image_format) - { - case IMGFMT_RGB32: - { - CGContextRef context; - - QDBeginCGContext(GetWindowPort(theWindow), &context); - - dataProviderRef = CGDataProviderCreateWithData(0, image_data, imgRect.right * imgRect.bottom * 4, 0); - - image = CGImageCreate(imgRect.right, - imgRect.bottom, - 8, - image_depth, - (imgRect.right * 32 + 7) / 8, - CGColorSpaceCreateDeviceRGB(), - kCGImageAlphaNoneSkipFirst, - dataProviderRef, 0, 1, kCGRenderingIntentDefault); - - QDEndCGContext(GetWindowPort(theWindow), &context); - break; - } - - case IMGFMT_YV12: - case IMGFMT_IYUV: - case IMGFMT_I420: - case IMGFMT_UYVY: - case IMGFMT_YUY2: - { - get_image_done = 0; - - if (!EnterMoviesDone) - { - qterr = EnterMovies(); - EnterMoviesDone = 1; - } - else - qterr = 0; - - if (qterr) - { - mp_msg(MSGT_VO, MSGL_FATAL, "Quartz error: EnterMovies (%d)\n", qterr); - return -1; - } - - - SetIdentityMatrix(&matrix); - - if (d_width != width || d_height != height) - { - ScaleMatrix(&matrix, FixDiv(Long2Fix(d_width), Long2Fix(width)), FixDiv(Long2Fix(d_height), Long2Fix(height)), 0, 0); - } - - yuv_qt_stuff.desc = (ImageDescriptionHandle) NewHandleClear(sizeof(ImageDescription)); - - yuv_qt_stuff.extension_colr = NewHandleClear(sizeof(NCLCColorInfoImageDescriptionExtension)); - ((NCLCColorInfoImageDescriptionExtension *) (*yuv_qt_stuff.extension_colr))->colorParamType = kVideoColorInfoImageDescriptionExtensionType; - ((NCLCColorInfoImageDescriptionExtension *) (*yuv_qt_stuff.extension_colr))->primaries = 2; - ((NCLCColorInfoImageDescriptionExtension *) (*yuv_qt_stuff.extension_colr))->transferFunction = 2; - ((NCLCColorInfoImageDescriptionExtension *) (*yuv_qt_stuff.extension_colr))->matrix = 2; - - yuv_qt_stuff.extension_fiel = NewHandleClear(sizeof(FieldInfoImageDescriptionExtension)); - ((FieldInfoImageDescriptionExtension *) (*yuv_qt_stuff.extension_fiel))->fieldCount = 1; - ((FieldInfoImageDescriptionExtension *) (*yuv_qt_stuff.extension_fiel))->fieldOrderings = 0; - - yuv_qt_stuff.extension_clap = NewHandleClear(sizeof(CleanApertureImageDescriptionExtension)); - ((CleanApertureImageDescriptionExtension *) (*yuv_qt_stuff.extension_clap))->cleanApertureWidthN = imgRect.right; - ((CleanApertureImageDescriptionExtension *) (*yuv_qt_stuff.extension_clap))->cleanApertureWidthD = 1; - ((CleanApertureImageDescriptionExtension *) (*yuv_qt_stuff.extension_clap))->cleanApertureHeightN = imgRect.bottom; - ((CleanApertureImageDescriptionExtension *) (*yuv_qt_stuff.extension_clap))->cleanApertureHeightD = 1; - ((CleanApertureImageDescriptionExtension *) (*yuv_qt_stuff.extension_clap))->horizOffN = 0; - ((CleanApertureImageDescriptionExtension *) (*yuv_qt_stuff.extension_clap))->horizOffD = 1; - ((CleanApertureImageDescriptionExtension *) (*yuv_qt_stuff.extension_clap))->vertOffN = 0; - ((CleanApertureImageDescriptionExtension *) (*yuv_qt_stuff.extension_clap))->vertOffD = 1; - - yuv_qt_stuff.extension_pasp = NewHandleClear(sizeof(PixelAspectRatioImageDescriptionExtension)); - ((PixelAspectRatioImageDescriptionExtension *) (*yuv_qt_stuff.extension_pasp))->hSpacing = 1; - ((PixelAspectRatioImageDescriptionExtension *) (*yuv_qt_stuff.extension_pasp))->vSpacing = 1; - - (*yuv_qt_stuff.desc)->idSize = sizeof(ImageDescription); - (*yuv_qt_stuff.desc)->cType = image_qtcodec; - (*yuv_qt_stuff.desc)->version = 2; - (*yuv_qt_stuff.desc)->revisionLevel = 0; - (*yuv_qt_stuff.desc)->vendor = 'mpla'; - (*yuv_qt_stuff.desc)->width = imgRect.right; - (*yuv_qt_stuff.desc)->height = imgRect.bottom; - (*yuv_qt_stuff.desc)->hRes = Long2Fix(72); - (*yuv_qt_stuff.desc)->vRes = Long2Fix(72); - (*yuv_qt_stuff.desc)->temporalQuality = 0; - (*yuv_qt_stuff.desc)->spatialQuality = codecLosslessQuality; - (*yuv_qt_stuff.desc)->frameCount = 1; - (*yuv_qt_stuff.desc)->dataSize = 0; - (*yuv_qt_stuff.desc)->depth = 24; - (*yuv_qt_stuff.desc)->clutID = -1; - - qterr = AddImageDescriptionExtension(yuv_qt_stuff.desc, yuv_qt_stuff.extension_colr, kColorInfoImageDescriptionExtension); - if (qterr) - { - mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: AddImageDescriptionExtension [colr] (%d)\n", qterr); - } - - qterr = AddImageDescriptionExtension(yuv_qt_stuff.desc, yuv_qt_stuff.extension_fiel, kFieldInfoImageDescriptionExtension); - if (qterr) - { - mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: AddImageDescriptionExtension [fiel] (%d)\n", qterr); - } - - qterr = AddImageDescriptionExtension(yuv_qt_stuff.desc, yuv_qt_stuff.extension_clap, kCleanApertureImageDescriptionExtension); - if (qterr) - { - mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: AddImageDescriptionExtension [clap] (%d)\n", qterr); - } - - qterr = AddImageDescriptionExtension(yuv_qt_stuff.desc, yuv_qt_stuff.extension_pasp, kCleanApertureImageDescriptionExtension); - if (qterr) - { - mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: AddImageDescriptionExtension [pasp] (%d)\n", qterr); - } - P = calloc(sizeof(PlanarPixmapInfoYUV420) + image_size, 1); - switch (image_format) - { - case IMGFMT_YV12: - case IMGFMT_IYUV: - case IMGFMT_I420: - P->componentInfoY.offset = be2me_32(sizeof(PlanarPixmapInfoYUV420)); - P->componentInfoCb.offset = be2me_32(be2me_32(P->componentInfoY.offset) + image_size / 2); - P->componentInfoCr.offset = be2me_32(be2me_32(P->componentInfoCb.offset) + image_size / 4); - P->componentInfoY.rowBytes = be2me_32(imgRect.right); - P->componentInfoCb.rowBytes = be2me_32(imgRect.right / 2); - P->componentInfoCr.rowBytes = be2me_32(imgRect.right / 2); - image_buffer_size = image_size + sizeof(PlanarPixmapInfoYUV420); - break; - case IMGFMT_UYVY: - case IMGFMT_YUY2: - image_buffer_size = image_size; - break; - } - - qterr = DecompressSequenceBeginS(&seqId, - yuv_qt_stuff.desc, - (char *)P, - image_buffer_size, - GetWindowPort(theWindow), - NULL, - NULL, - d_width != width || d_height != height ? - &matrix : NULL, - srcCopy, - NULL, - 0, - codecLosslessQuality, - bestSpeedCodec); - - if (qterr) - { - mp_msg(MSGT_VO, MSGL_FATAL, "Quartz error: DecompressSequenceBeginS (%d)\n", qterr); - return -1; - } - } - break; - } - - // Show window - RepositionWindow(theWindow, NULL, kWindowCenterOnMainScreen); - ShowWindow(theWindow); - - if (vo_fs) - window_fullscreen(); - - if (vo_ontop) - window_ontop(); - - if (vo_rootwin) - { - vo_fs = TRUE; - winLevel = 0; - SetWindowGroupLevel(winGroup, CGWindowLevelForKey(levelList[winLevel])); - window_fullscreen(); - } - - window_resized(); - - return 0; -} - -static void check_events(void) -{ - EventRef theEvent; - EventTargetRef theTarget; - OSStatus theErr; - - // Get event - theTarget = GetEventDispatcherTarget(); - theErr = ReceiveNextEvent(0, 0, kEventDurationNoWait, true, &theEvent); - if (theErr == noErr && theEvent != NULL) - { - SendEventToEventTarget(theEvent, theTarget); - ReleaseEvent(theEvent); - } -} - -static void draw_osd(void) -{ - vo_draw_text(imgRect.right, imgRect.bottom, draw_alpha); -} - -static void flip_page(void) -{ - int curTime; - - if (theWindow == NULL) - return; - - switch (image_format) - { - case IMGFMT_RGB32: - { - CGContextRef context; - - QDBeginCGContext(GetWindowPort(theWindow), &context); - CGContextDrawImage(context, bounds, image); - QDEndCGContext(GetWindowPort(theWindow), &context); - } - break; - - case IMGFMT_YV12: - case IMGFMT_IYUV: - case IMGFMT_I420: - case IMGFMT_UYVY: - case IMGFMT_YUY2: - if (EnterMoviesDone) - { - OSErr qterr; - CodecFlags flags = 0; - - qterr = DecompressSequenceFrameWhen(seqId, - (char *)P, - image_buffer_size, - 0, //codecFlagUseImageBuffer, - &flags, - NULL, - NULL); - if (qterr) - { - mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: DecompressSequenceFrameWhen in flip_page (%d) flags:0x%08x\n", qterr, flags); - } - } - break; - } - - if (!vo_quartz_fs) - { - CGContextRef context; - - QDBeginCGContext(GetWindowPort(theWindow), &context); - // render resize box - CGContextBeginPath(context); - CGContextSetAllowsAntialiasing(context, false); - //CGContextSaveGState(context); - - // line white - CGContextSetRGBStrokeColor(context, 0.2, 0.2, 0.2, 0.5); - CGContextMoveToPoint(context, winRect.right - 1, 1); CGContextAddLineToPoint(context, winRect.right - 1, 1); - CGContextMoveToPoint(context, winRect.right - 1, 5); CGContextAddLineToPoint(context, winRect.right - 5, 1); - CGContextMoveToPoint(context, winRect.right - 1, 9); CGContextAddLineToPoint(context, winRect.right - 9, 1); - CGContextStrokePath(context); - - // line gray - CGContextSetRGBStrokeColor(context, 0.4, 0.4, 0.4, 0.5); - CGContextMoveToPoint(context, winRect.right - 1, 2); CGContextAddLineToPoint(context, winRect.right - 2, 1); - CGContextMoveToPoint(context, winRect.right - 1, 6); CGContextAddLineToPoint(context, winRect.right - 6, 1); - CGContextMoveToPoint(context, winRect.right - 1, 10); CGContextAddLineToPoint(context, winRect.right - 10, 1); - CGContextStrokePath(context); - - // line black - CGContextSetRGBStrokeColor(context, 0.6, 0.6, 0.6, 0.5); - CGContextMoveToPoint(context, winRect.right - 1, 3); CGContextAddLineToPoint(context, winRect.right - 3, 1); - CGContextMoveToPoint(context, winRect.right - 1, 7); CGContextAddLineToPoint(context, winRect.right - 7, 1); - CGContextMoveToPoint(context, winRect.right - 1, 11); CGContextAddLineToPoint(context, winRect.right - 11, 1); - CGContextStrokePath(context); - - // CGContextRestoreGState( context ); - CGContextFlush(context); - QDEndCGContext(GetWindowPort(theWindow), &context); - } - - curTime = TickCount() / 60; - - // auto hide mouse cursor (and future on-screen control?) - if (vo_quartz_fs && !mouseHide) - { - if (curTime - lastMouseHide >= 5 || lastMouseHide == 0) - { - CGDisplayHideCursor(displayId); - mouseHide = TRUE; - lastMouseHide = curTime; - } - } - // update activity every 30 seconds to prevent - // screensaver from starting up. - if (curTime - lastScreensaverUpdate >= 30 || lastScreensaverUpdate == 0) - { - UpdateSystemActivity(UsrActivity); - lastScreensaverUpdate = curTime; - } -} - -static int draw_slice(uint8_t * src[], int stride[], int w, int h, int x, int y) -{ - switch (image_format) - { - case IMGFMT_YV12: - case IMGFMT_I420: - memcpy_pic(((char *)P) + be2me_32(P->componentInfoY.offset) + x + imgRect.right * y, src[0], w, h, imgRect.right, stride[0]); - x=x/2;y=y/2;w=w/2;h=h/2; - - memcpy_pic(((char *)P) + be2me_32(P->componentInfoCb.offset) + x + imgRect.right / 2 * y, src[1], w, h, imgRect.right / 2, stride[1]); - memcpy_pic(((char *)P) + be2me_32(P->componentInfoCr.offset) + x + imgRect.right / 2 * y, src[2], w, h, imgRect.right / 2, stride[2]); - return 0; - - case IMGFMT_IYUV: - memcpy_pic(((char *)P) + be2me_32(P->componentInfoY.offset) + x + imgRect.right * y, src[0], w, h, imgRect.right, stride[0]); - x=x/2;y=y/2;w=w/2;h=h/2; - - memcpy_pic(((char *)P) + be2me_32(P->componentInfoCr.offset) + x + imgRect.right / 2 * y, src[1], w, h, imgRect.right / 2, stride[1]); - memcpy_pic(((char *)P) + be2me_32(P->componentInfoCb.offset) + x + imgRect.right / 2 * y, src[2], w, h, imgRect.right / 2, stride[2]); - return 0; - } - return -1; -} - -static int draw_frame(uint8_t * src[]) -{ - switch (image_format) - { - case IMGFMT_RGB32: - fast_memcpy(image_data, src[0], image_size); - return 0; - - case IMGFMT_UYVY: - case IMGFMT_YUY2: - memcpy_pic(((char *)P), src[0], imgRect.right * 2, imgRect.bottom, imgRect.right * 2, imgRect.right * 2); - return 0; - } - return -1; -} - -static int query_format(uint32_t format) -{ - image_format = format; - image_qtcodec = 0; - - if (format == IMGFMT_RGB32) - { - return VFCAP_CSP_SUPPORTED | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN; - } - - if (format == IMGFMT_YV12 || format == IMGFMT_IYUV || format == IMGFMT_I420) - { - image_qtcodec = kMpegYUV420CodecType; //kYUV420CodecType ?; - return VFCAP_CSP_SUPPORTED | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_ACCEPT_STRIDE; - } - - if (format == IMGFMT_YUY2) - { - image_qtcodec = kComponentVideoUnsigned; - return VFCAP_CSP_SUPPORTED | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN; - } - - if (format == IMGFMT_UYVY) - { - image_qtcodec = k422YpCbCr8CodecType; - return VFCAP_CSP_SUPPORTED | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN; - } - - return 0; -} - -static void uninit(void) -{ - free_video_specific(); - if (EnterMoviesDone) - ExitMovies(); - EnterMoviesDone = 0; - - ShowMenuBar(); -} - -static int preinit(const char *arg) -{ - int parse_err = 0; - - if(arg) - { - char *parse_pos = (char *)&arg[0]; - - while (parse_pos[0] && !parse_err) - { - if (strncmp(parse_pos, "device_id=", 10) == 0) - { - parse_pos = &parse_pos[10]; - device_id = strtol(parse_pos, &parse_pos, 0); - } - if (strncmp(parse_pos, "fs_res=", 7) == 0) - { - parse_pos = &parse_pos[7]; - fs_res_x = strtol(parse_pos, &parse_pos, 0); - parse_pos = &parse_pos[1]; - fs_res_y = strtol(parse_pos, &parse_pos, 0); - } - if (parse_pos[0] == ':') - parse_pos = &parse_pos[1]; - else if (parse_pos[0]) - parse_err = 1; - } - } - - osx_foreground_hack(); - - return 0; -} - -static uint32_t draw_yuv_image(mp_image_t * mpi) -{ - // ATM we're only called for planar IMGFMT - // drawing is done directly in P - // and displaying is in flip_page. - return get_image_done ? VO_TRUE : VO_FALSE; -} - -static uint32_t get_yuv_image(mp_image_t * mpi) -{ - if (mpi->type != MP_IMGTYPE_EXPORT) return VO_FALSE; - - if (mpi->imgfmt != image_format) return VO_FALSE; - - if (mpi->flags & MP_IMGFLAG_PLANAR) - { - if (mpi->num_planes != 3) - { - mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: only 3 planes allowed in get_yuv_image for planar (%d) \n", mpi->num_planes); - return VO_FALSE; - } - - mpi->planes[0] = ((char *)P) + be2me_32(P->componentInfoY.offset); - mpi->stride[0] = imgRect.right; - mpi->width = imgRect.right; - - if (mpi->flags & MP_IMGFLAG_SWAPPED) - { - // I420 - mpi->planes[1] = ((char *)P) + be2me_32(P->componentInfoCb.offset); - mpi->planes[2] = ((char *)P) + be2me_32(P->componentInfoCr.offset); - mpi->stride[1] = imgRect.right / 2; - mpi->stride[2] = imgRect.right / 2; - } - else - { - // YV12 - mpi->planes[1] = ((char *)P) + be2me_32(P->componentInfoCr.offset); - mpi->planes[2] = ((char *)P) + be2me_32(P->componentInfoCb.offset); - mpi->stride[1] = imgRect.right / 2; - mpi->stride[2] = imgRect.right / 2; - } - - mpi->flags |= MP_IMGFLAG_DIRECT; - get_image_done = 1; - return VO_TRUE; - } - else - { - // doesn't work yet - if (mpi->num_planes != 1) - { - mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: only 1 plane allowed in get_yuv_image for packed (%d) \n", mpi->num_planes); - return VO_FALSE; - } - - mpi->planes[0] = (char *)P; - mpi->stride[0] = imgRect.right * 2; - mpi->width = imgRect.right; - mpi->flags |= MP_IMGFLAG_DIRECT; - get_image_done = 1; - return VO_TRUE; - } - return VO_FALSE; -} - -static int control(uint32_t request, void *data) -{ - switch (request) - { - case VOCTRL_PAUSE: return int_pause = 1; - case VOCTRL_RESUME: return int_pause = 0; - case VOCTRL_FULLSCREEN: vo_fs = !vo_fs; window_fullscreen(); return VO_TRUE; - case VOCTRL_ONTOP: vo_ontop = !vo_ontop; window_ontop(); return VO_TRUE; - case VOCTRL_QUERY_FORMAT: return query_format(*(uint32_t *) data); - case VOCTRL_GET_PANSCAN: return VO_TRUE; - case VOCTRL_SET_PANSCAN: window_panscan(); return VO_TRUE; - - case VOCTRL_GET_IMAGE: - switch (image_format) - { - case IMGFMT_YV12: - case IMGFMT_IYUV: - case IMGFMT_I420: - case IMGFMT_UYVY: - case IMGFMT_YUY2: - return get_yuv_image(data); - break; - default: - break; - } - case VOCTRL_DRAW_IMAGE: - switch (image_format) - { - case IMGFMT_YV12: - case IMGFMT_IYUV: - case IMGFMT_I420: - case IMGFMT_UYVY: - case IMGFMT_YUY2: - return draw_yuv_image(data); - break; - default: - break; - } - case VOCTRL_UPDATE_SCREENINFO: - update_screen_info(); - return VO_TRUE; - } - return VO_NOTIMPL; -} - -void window_resized(void) -{ - uint32_t d_width; - uint32_t d_height; - - CGRect tmpBounds; - - CGContextRef context; - - GetWindowPortBounds(theWindow, &winRect); - d_width = vo_dwidth = winRect.right; - d_height = vo_dheight = winRect.bottom; - - if (vo_keepaspect) - aspect(&d_width, &d_height, A_WINZOOM); - SetRect(&dstRect, (vo_dwidth - d_width) / 2, (vo_dheight - d_height) / 2, d_width, d_height); - - switch (image_format) - { - case IMGFMT_RGB32: - { - bounds = CGRectMake(dstRect.left, dstRect.top, dstRect.right - dstRect.left, dstRect.bottom - dstRect.top); - break; - } - case IMGFMT_YV12: - case IMGFMT_IYUV: - case IMGFMT_I420: - case IMGFMT_UYVY: - case IMGFMT_YUY2: - { - long scale_X = FixDiv(Long2Fix(dstRect.right - dstRect.left), Long2Fix(imgRect.right)); - long scale_Y = FixDiv(Long2Fix(dstRect.bottom - dstRect.top), Long2Fix(imgRect.bottom)); - - SetIdentityMatrix(&matrix); - if (dstRect.right - dstRect.left != imgRect.right || dstRect.bottom - dstRect.right != imgRect.bottom) - { - ScaleMatrix(&matrix, scale_X, scale_Y, 0, 0); - - if (vo_dwidth > d_width || vo_dheight > d_height) - { - TranslateMatrix(&matrix, Long2Fix(dstRect.left), Long2Fix(dstRect.top)); - } - } - - SetDSequenceMatrix(seqId, &matrix); - break; - } - default: - break; - } - - // Clear Background - tmpBounds = CGRectMake(0, 0, winRect.right, winRect.bottom); - QDBeginCGContext(GetWindowPort(theWindow), &context); - CGContextFillRect(context, tmpBounds); - QDEndCGContext(GetWindowPort(theWindow), &context); -} - -void window_ontop(void) -{ - if (!vo_quartz_fs) - { - // Cycle between level - winLevel++; - if (winLevel > 2) - winLevel = 1; - } - SetWindowGroupLevel(winGroup, CGWindowLevelForKey(levelList[winLevel])); -} - -void window_fullscreen(void) -{ - // go fullscreen - if (vo_fs) - { - if (winLevel != 0) - { - if (displayId == kCGDirectMainDisplay) - { - SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar); - CGDisplayHideCursor(displayId); - mouseHide = TRUE; - } - - if (fs_res_x != 0 || fs_res_y != 0) - { - CFDictionaryRef mode; - size_t desiredBitDepth = 32; - boolean_t exactMatch; - - originalMode = CGDisplayCurrentMode(displayId); - - mode = CGDisplayBestModeForParameters(displayId, desiredBitDepth, fs_res_x, fs_res_y, &exactMatch); - - if (mode != NULL) - { - if (!exactMatch) - { - // Warn if the mode doesn't match exactly - mp_msg(MSGT_VO, MSGL_WARN, "Quartz warning: did not get exact mode match (got %dx%d) \n", (int)CFDictionaryGetValue(mode, kCGDisplayWidth), (int)CFDictionaryGetValue(mode, kCGDisplayHeight)); - } - - CGDisplayCapture(displayId); - CGDisplaySwitchToMode(displayId, mode); - } - else - { - mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: can't switch to fullscreen \n"); - } - - // Get Main device info/////////////////////////////////////////////////// - update_screen_info(); - } - } - // save old window size - if (!vo_quartz_fs) - { - GetWindowPortBounds(theWindow, &oldWinRect); - GetWindowBounds(theWindow, kWindowContentRgn, &oldWinBounds); - } - // go fullscreen - ChangeWindowAttributes(theWindow, kWindowNoShadowAttribute, 0); - - vo_quartz_fs = 1; - window_panscan(); - } - else //go back to windowed mode - { - vo_quartz_fs = 0; - if (originalMode != NULL) - { - CGDisplaySwitchToMode(displayId, originalMode); - CGDisplayRelease(displayId); - - // Get Main device info/////////////////////////////////////////////////// - update_screen_info(); - - originalMode = NULL; - } - SetSystemUIMode(kUIModeNormal, 0); - - // show mouse cursor - CGDisplayShowCursor(displayId); - mouseHide = FALSE; - - // revert window to previous setting - ChangeWindowAttributes(theWindow, 0, kWindowNoShadowAttribute); - SizeWindow(theWindow, oldWinRect.right, oldWinRect.bottom, 1); - MoveWindow(theWindow, oldWinBounds.left, oldWinBounds.top, 1); - } - window_resized(); -} - -void window_panscan(void) -{ - panscan_calc(); - - if (vo_panscan > 0) - CheckMenuItem(aspectMenu, 2, 1); - else - CheckMenuItem(aspectMenu, 2, 0); - - if (vo_quartz_fs) - { - MoveWindow(theWindow, xinerama_x - (vo_panscan_x >> 1), xinerama_y - (vo_panscan_y >> 1), 1); - SizeWindow(theWindow, vo_screenwidth + vo_panscan_x, vo_screenheight + vo_panscan_y, 1); - } -} diff -Nru mplayer2-2.0-426-gc32b3ed/libvo/vo_sdl.c mplayer2-2.0-554-gf63dbad/libvo/vo_sdl.c --- mplayer2-2.0-426-gc32b3ed/libvo/vo_sdl.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libvo/vo_sdl.c 2012-05-17 14:38:00.000000000 +0000 @@ -66,7 +66,7 @@ #include "sub/sub.h" #include "aspect.h" #include "libmpcodecs/vfcap.h" -#include "ffmpeg_files/bswap.h" +#include "mpbswap.h" #ifdef CONFIG_X11 #include diff -Nru mplayer2-2.0-426-gc32b3ed/libvo/vo_sharedbuffer.h mplayer2-2.0-554-gf63dbad/libvo/vo_sharedbuffer.h --- mplayer2-2.0-426-gc32b3ed/libvo/vo_sharedbuffer.h 1970-01-01 00:00:00.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libvo/vo_sharedbuffer.h 2012-05-17 14:38:00.000000000 +0000 @@ -0,0 +1,37 @@ +/* + * OSX Shared Buffer Video Output (extracted from mplayer's corevideo) + * + * This file is part of mplayer2. + * + * mplayer2 is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * mplayer2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with mplayer2. If not, see . + */ + +#ifndef MPLAYER_VO_OSX_SHAREDBUFFER_H +#define MPLAYER_VO_OSX_SHAREDBUFFER_H + +#import + +// Protocol to communicate with the GUI +@protocol MPlayerOSXVOProto +- (int) startWithWidth: (bycopy int)width + withHeight: (bycopy int)height + withBytes: (bycopy int)bytes + withAspect: (bycopy int)aspect; +- (void) stop; +- (void) render; +- (void) toggleFullscreen; +- (void) ontop; +@end + +#endif /* MPLAYER_VO_OSX_SHAREDBUFFER_H */ diff -Nru mplayer2-2.0-426-gc32b3ed/libvo/vo_sharedbuffer.m mplayer2-2.0-554-gf63dbad/libvo/vo_sharedbuffer.m --- mplayer2-2.0-426-gc32b3ed/libvo/vo_sharedbuffer.m 1970-01-01 00:00:00.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libvo/vo_sharedbuffer.m 2012-05-17 14:38:00.000000000 +0000 @@ -0,0 +1,277 @@ +/* + * OSX Shared Buffer Video Output (extracted from mplayer's corevideo) + * + * This file is part of mplayer2. + * + * mplayer2 is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * mplayer2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with mplayer2. If not, see . + */ + +/* + * This video output was extracted from mplayer's corevideo. It's purpose it + * to copy mp_image data to a shared buffer using mmap and to do simple + * coordination with the GUIs using Distributed Objects. + */ + +#include + +#include "vo_sharedbuffer.h" +#include "video_out.h" +#include "subopt-helper.h" +#include "talloc.h" + +#include "libmpcodecs/vfcap.h" +#include "libmpcodecs/mp_image.h" +#include "fastmemcpy.h" + +#include "sub/sub.h" +#include "osd.h" + +// declarations +struct priv { + char *buffer_name; + unsigned char *image_data; + unsigned int image_bytespp; + unsigned int image_width; + unsigned int image_height; + + void (*vo_draw_alpha_fnc)(int w, int h, unsigned char* src, + unsigned char *srca, int srcstride, unsigned char* dstbase, + int dststride); + + NSDistantObject *mposx_proxy; + id mposx_proto; +}; + +struct priv *p; + +// implementation +static void draw_alpha(void *ctx, int x0, int y0, int w, int h, + unsigned char *src, unsigned char *srca, + int stride) +{ + p->vo_draw_alpha_fnc(w, h, src, srca, stride, + p->image_data + (x0 + y0 * p->image_width) * p->image_bytespp, + p->image_width * p->image_bytespp); +} + +static unsigned int image_bytes() +{ + return p->image_width * p->image_height * p->image_bytespp; +} + +static int preinit(struct vo *vo, const char *arg) +{ + p = talloc_zero(NULL, struct priv); + + const opt_t subopts[] = { + {"buffer_name", OPT_ARG_MSTRZ, &p->buffer_name, NULL}, + {NULL} + }; + + if (subopt_parse(arg, subopts) != 0) { + mp_msg(MSGT_VO, MSGL_FATAL, + "\n-vo sharedbuffer command line help:\n" + "Example: mplayer -vo shared_buffer:buffer_name=mybuff\n" + "\nOptions:\n" + " buffer_name=\n" + " Name of the shared buffer created with shm_open() as well as\n" + " the name of the NSConnection mplayer2 will try to open.\n" + "Example: mplayer -vo sharedbuffer\n" + "\n" ); + return -1; + } + + if (!p->buffer_name) p->buffer_name = "mplayerosx"; + + return 0; +} + +static void flip_page(struct vo *vo) +{ + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + [p->mposx_proto render]; + [pool release]; +} + +static void check_events(struct vo *vo) { } + +static uint32_t draw_image(struct vo *vo, mp_image_t *mpi) +{ + memcpy_pic(p->image_data, mpi->planes[0], + (p->image_width) * (p->image_bytespp), p->image_height, + (p->image_width) * (p->image_bytespp), mpi->stride[0]); + return 0; +} + +static void draw_osd(struct vo *vo, struct osd_state *osd) { + osd_draw_text(osd, p->image_width, p->image_height, draw_alpha, vo); +} + +static void free_buffers(void) +{ + [p->mposx_proto stop]; + p->mposx_proto = nil; + [p->mposx_proxy release]; + p->mposx_proxy = nil; + + if (p->image_data) { + if (munmap(p->image_data, image_bytes()) == -1) + mp_msg(MSGT_VO, MSGL_FATAL, "[vo_sharedbuffer] uninit: munmap " + "failed. Error: %s\n", strerror(errno)); + + if (shm_unlink(p->buffer_name) == -1) + mp_msg(MSGT_VO, MSGL_FATAL, "[vo_sharedbuffer] uninit: shm_unlink " + "failed. Error: %s\n", strerror(errno)); + } +} + +static int config(struct vo *vo, uint32_t width, uint32_t height, + uint32_t d_width, uint32_t d_height, uint32_t flags, + uint32_t format) +{ + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + free_buffers(); + + p->image_width = width; + p->image_height = height; + + mp_msg(MSGT_VO, MSGL_INFO, "[vo_sharedbuffer] writing output to a shared " + "buffer named \"%s\"\n", p->buffer_name); + + // create shared memory + int shm_fd = shm_open(p->buffer_name, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR); + if (shm_fd == -1) { + mp_msg(MSGT_VO, MSGL_FATAL, + "[vo_sharedbuffer] failed to open shared memory. Error: %s\n", + strerror(errno)); + goto err_out; + } + + if (ftruncate(shm_fd, image_bytes()) == -1) { + mp_msg(MSGT_VO, MSGL_FATAL, + "[vo_sharedbuffer] failed to size shared memory, possibly " + "already in use. Error: %s\n", strerror(errno)); + close(shm_fd); + shm_unlink(p->buffer_name); + goto err_out; + } + + p->image_data = mmap(NULL, image_bytes(), + PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, 0); + close(shm_fd); + + if (p->image_data == MAP_FAILED) { + mp_msg(MSGT_VO, MSGL_FATAL, + "[vo_sharedbuffer] failed to map shared memory. " + "Error: %s\n", strerror(errno)); + shm_unlink(p->buffer_name); + goto err_out; + } + + //connect to mplayerosx + p->mposx_proxy = [NSConnection + rootProxyForConnectionWithRegisteredName: + [NSString stringWithUTF8String:p->buffer_name] host:nil]; + + if ([p->mposx_proxy conformsToProtocol:@protocol(MPlayerOSXVOProto)]) { + [p->mposx_proxy setProtocolForProxy:@protocol(MPlayerOSXVOProto)]; + p->mposx_proto = (id )p->mposx_proxy; + [p->mposx_proto startWithWidth:p->image_width + withHeight:p->image_height + withBytes:p->image_bytespp + withAspect:d_width*100/d_height]; + } else { + mp_msg(MSGT_VO, MSGL_ERR, + "[vo_sharedbuffer] distributed object doesn't conform " + "to the correct protocol.\n"); + [p->mposx_proxy release]; + p->mposx_proxy = nil; + p->mposx_proto = nil; + } + + [pool release]; + return 0; +err_out: + [pool release]; + return 1; +} + +static int query_format(uint32_t format) +{ + unsigned int image_depth = 0; + switch (format) { + case IMGFMT_YUY2: + p->vo_draw_alpha_fnc = vo_draw_alpha_yuy2; + image_depth = 16; + goto supported; + case IMGFMT_RGB24: + p->vo_draw_alpha_fnc = vo_draw_alpha_rgb24; + image_depth = 24; + goto supported; + case IMGFMT_ARGB: + p->vo_draw_alpha_fnc = vo_draw_alpha_rgb32; + image_depth = 32; + goto supported; + case IMGFMT_BGRA: + p->vo_draw_alpha_fnc = vo_draw_alpha_rgb32; + image_depth = 32; + goto supported; + } + return 0; + +supported: + p->image_bytespp = (image_depth + 7) / 8; + return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | + VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | + VOCAP_NOSLICES; +} + +static void uninit(struct vo *vo) +{ + free_buffers(); +} + +static int control(struct vo *vo, uint32_t request, void *data) +{ + switch (request) { + case VOCTRL_DRAW_IMAGE: + return draw_image(vo, data); + case VOCTRL_FULLSCREEN: + [p->mposx_proto toggleFullscreen]; + return VO_TRUE; + case VOCTRL_QUERY_FORMAT: + return query_format(*(uint32_t*)data); + case VOCTRL_ONTOP: + [p->mposx_proto ontop]; + return VO_TRUE; + } + return VO_NOTIMPL; +} + +const struct vo_driver video_out_sharedbuffer = { + .is_new = true, + .info = &(const vo_info_t) { + "Mac OS X Shared Buffer (headless video output for GUIs)", + "sharedbuffer", + "Stefano Pigozzi and others.", + "" + }, + .preinit = preinit, + .config = config, + .control = control, + .flip_page = flip_page, + .check_events = check_events, + .uninit = uninit, + .draw_osd = draw_osd +}; diff -Nru mplayer2-2.0-426-gc32b3ed/libvo/vo_vdpau.c mplayer2-2.0-554-gf63dbad/libvo/vo_vdpau.c --- mplayer2-2.0-426-gc32b3ed/libvo/vo_vdpau.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libvo/vo_vdpau.c 2012-05-17 14:38:00.000000000 +0000 @@ -599,7 +599,8 @@ // both are float[3][4] VdpCSCMatrix matrix; - struct mp_csp_params cparams = { .colorspace = vc->colorspace }; + struct mp_csp_params cparams = { + .colorspace = vc->colorspace, .input_bits = 8, .texture_bits = 8 }; mp_csp_copy_equalizer_values(&cparams, &vc->video_eq); mp_get_yuv2rgb_coeffs(&cparams, matrix); diff -Nru mplayer2-2.0-426-gc32b3ed/libvo/vo_xv.c mplayer2-2.0-554-gf63dbad/libvo/vo_xv.c --- mplayer2-2.0-426-gc32b3ed/libvo/vo_xv.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libvo/vo_xv.c 2012-05-17 14:38:00.000000000 +0000 @@ -18,29 +18,29 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -// Number of buffers _FOR_DOUBLEBUFFERING_MODE_ -// Use option -double to enable double buffering! (default: single buffer) -#define NUM_BUFFERS 3 - -/* -Buffer allocation: - --nodr: - 1: TEMP - 2: 2*TEMP - --dr: - 1: TEMP - 3: 2*STATIC+TEMP -*/ - #include #include #include #include #include +#include +#include +#include + +#include #include "config.h" + +#ifdef HAVE_SHM +#include +#include +#include +#endif + +// Note: depends on the inclusion of X11/extensions/XShm.h +#include +#include + #include "options.h" #include "talloc.h" #include "mp_msg.h" @@ -48,22 +48,13 @@ #include "libmpcodecs/vfcap.h" #include "libmpcodecs/mp_image.h" #include "osd.h" - -#include -#include -#include - #include "x11_common.h" - #include "fastmemcpy.h" #include "sub/sub.h" #include "aspect.h" #include "csputils.h" - #include "subopt-helper.h" -#include "libavutil/common.h" - static const vo_info_t info = { "X11/Xv", "xv", @@ -71,16 +62,6 @@ "" }; -#ifdef HAVE_SHM -#include -#include -#include -#endif - -// Note: depends on the inclusion of X11/extensions/XShm.h -#include -#include - struct xvctx { XvAdaptorInfo *ai; XvImageFormatValues *fo; @@ -92,7 +73,7 @@ bool have_image_copy; bool unchanged_image; int visible_buf; - XvImage *xvimage[NUM_BUFFERS + 1]; + XvImage *xvimage[2 + 1]; uint32_t image_width; uint32_t image_height; uint32_t image_format; @@ -108,7 +89,7 @@ unsigned char *src, unsigned char *srca, int stride); #ifdef HAVE_SHM - XShmSegmentInfo Shminfo[NUM_BUFFERS + 1]; + XShmSegmentInfo Shminfo[2 + 1]; int Shmem_Flag; #endif }; @@ -301,8 +282,7 @@ for (i = 0; i < ctx->total_buffers; i++) deallocate_xvimage(vo, i); - ctx->num_buffers = - vo_doublebuffering ? (vo_directrendering ? NUM_BUFFERS : 2) : 1; + ctx->num_buffers = 2; ctx->total_buffers = ctx->num_buffers + 1; for (i = 0; i < ctx->total_buffers; i++) @@ -462,12 +442,8 @@ /* remember the currently visible buffer */ ctx->visible_buf = ctx->current_buf; - if (ctx->num_buffers > 1) { - ctx->current_buf = vo_directrendering ? 0 : ((ctx->current_buf + 1) % - ctx->num_buffers); - XFlush(vo->x11->display); - } else - XSync(vo->x11->display, False); + ctx->current_buf = (ctx->current_buf + 1) % ctx->num_buffers; + XFlush(vo->x11->display); return; } @@ -553,10 +529,7 @@ ctx->have_image_copy = false; - if (mpi->flags & MP_IMGFLAG_DIRECT) - // direct rendering: - ctx->current_buf = (size_t)(mpi->priv); // hack! - else if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK) + if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK) ; // done else if (mpi->flags & MP_IMGFLAG_PLANAR) draw_slice(vo, mpi->planes, mpi->stride, mpi->w, mpi->h, 0, 0); @@ -577,66 +550,6 @@ return true; } -static uint32_t get_image(struct xvctx *ctx, mp_image_t *mpi) -{ - // we shouldn't change current_buf unless we do DR! - int buf = ctx->current_buf; - - if (mpi->type == MP_IMGTYPE_STATIC && ctx->num_buffers > 1) - return VO_FALSE; // it is not static - if (mpi->imgfmt != ctx->image_format) - return VO_FALSE; // needs conversion :( - if (mpi->flags & MP_IMGFLAG_READABLE - && (mpi->type == MP_IMGTYPE_IPB || mpi->type == MP_IMGTYPE_IP)) { - // reference (I/P) frame of IP or IPB: - if (ctx->num_buffers < 2) - return VO_FALSE; // not enough - ctx->current_ip_buf ^= 1; - // for IPB with 2 buffers we can DR only one of the 2 P frames: - if (mpi->type == MP_IMGTYPE_IPB && ctx->num_buffers < 3 - && ctx->current_ip_buf) - return VO_FALSE; - buf = ctx->current_ip_buf; - if (mpi->type == MP_IMGTYPE_IPB) - ++buf; // preserve space for B - } - if (mpi->height > ctx->xvimage[buf]->height) - return VO_FALSE; //buffer to small - if (mpi->width * (mpi->bpp / 8) > ctx->xvimage[buf]->pitches[0]) - return VO_FALSE; //buffer to small - if ((mpi->flags & (MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_ACCEPT_WIDTH)) - || (mpi->width * (mpi->bpp / 8) == ctx->xvimage[buf]->pitches[0])) { - ctx->current_buf = buf; - XvImage *current_image = ctx->xvimage[ctx->current_buf]; - mpi->planes[0] = current_image->data + current_image->offsets[0]; - mpi->stride[0] = current_image->pitches[0]; - mpi->width = mpi->stride[0] / (mpi->bpp / 8); - if (mpi->flags & MP_IMGFLAG_PLANAR) { - if (mpi->flags & MP_IMGFLAG_SWAPPED) { - // I420 - mpi->planes[1] = current_image->data - + current_image->offsets[1]; - mpi->planes[2] = current_image->data - + current_image->offsets[2]; - mpi->stride[1] = current_image->pitches[1]; - mpi->stride[2] = current_image->pitches[2]; - } else { - // YV12 - mpi->planes[1] = current_image->data - + current_image->offsets[2]; - mpi->planes[2] = current_image->data - + current_image->offsets[1]; - mpi->stride[1] = current_image->pitches[2]; - mpi->stride[2] = current_image->pitches[1]; - } - } - mpi->flags |= MP_IMGFLAG_DIRECT; - mpi->priv = (void *)(size_t)ctx->current_buf; - return VO_TRUE; - } - return VO_FALSE; -} - static int query_format(struct xvctx *ctx, uint32_t format) { uint32_t i; @@ -813,8 +726,6 @@ return (ctx->is_paused = 0); case VOCTRL_QUERY_FORMAT: return query_format(ctx, *((uint32_t *) data)); - case VOCTRL_GET_IMAGE: - return get_image(ctx, data); case VOCTRL_DRAW_IMAGE: return draw_image(vo, data); case VOCTRL_GET_PANSCAN: diff -Nru mplayer2-2.0-426-gc32b3ed/libvo/w32_common.c mplayer2-2.0-554-gf63dbad/libvo/w32_common.c --- mplayer2-2.0-426-gc32b3ed/libvo/w32_common.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libvo/w32_common.c 2012-05-17 14:38:00.000000000 +0000 @@ -41,6 +41,8 @@ #define MONITOR_DEFAULTTOPRIMARY 1 #endif +#define WIN_ID_TO_HWND(x) ((HWND)(uint32_t)(x)) + static const char classname[] = "MPlayer - The Movie Player"; int vo_vm = 0; @@ -116,7 +118,7 @@ break; case WM_WINDOWPOSCHANGING: if (vo_keepaspect && !vo_fs && WinID < 0) { - WINDOWPOS *wpos = lParam; + WINDOWPOS *wpos = (WINDOWPOS*)lParam; int xborder, yborder; r.left = r.top = 0; r.right = wpos->cx; @@ -232,10 +234,10 @@ vo_dx = p.x; vo_dy = p.y; event_flags |= VO_EVENT_MOVE; } - res = GetClientRect(WinID, &r); + res = GetClientRect(WIN_ID_TO_HWND(WinID), &r); if (res && (r.right != vo_dwidth || r.bottom != vo_dheight)) MoveWindow(vo_window, 0, 0, r.right, r.bottom, FALSE); - if (!IsWindow(WinID)) + if (!IsWindow(WIN_ID_TO_HWND(WinID))) // Window has probably been closed, e.g. due to program crash mplayer_put_key(KEY_CLOSE_WIN); } @@ -514,11 +516,11 @@ if (WinID >= 0) { RECT r; - GetClientRect(WinID, &r); + GetClientRect(WIN_ID_TO_HWND(WinID), &r); vo_dwidth = r.right; vo_dheight = r.bottom; vo_window = CreateWindowEx(WS_EX_NOPARENTNOTIFY, classname, classname, - WS_CHILD | WS_VISIBLE, - 0, 0, vo_dwidth, vo_dheight, WinID, 0, hInstance, 0); + WS_CHILD | WS_VISIBLE, 0, 0, vo_dwidth, vo_dheight, + WIN_ID_TO_HWND(WinID), 0, hInstance, 0); EnableWindow(vo_window, 0); } else vo_window = CreateWindowEx(0, classname, classname, diff -Nru mplayer2-2.0-426-gc32b3ed/libvo/wskeys.h mplayer2-2.0-554-gf63dbad/libvo/wskeys.h --- mplayer2-2.0-426-gc32b3ed/libvo/wskeys.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libvo/wskeys.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -/* - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPLAYER_WSKEYS_H -#define MPLAYER_WSKEYS_H - -#define wsPause 0xff13 -#define wsUp 0xff52 -#define wsDown 0xff54 -#define wsLeft 0xff51 -#define wsRight 0xff53 -#define wsLeftCtrl 0xffe3 -#define wsRightCtrl 0xffe4 -#define wsLeftAlt 0xffe9 -#define wsRightAlt 0xff7e -#define wsLeftShift 0xffe1 -#define wsRightShift 0xffe2 -#define wsEnter 0xff0d -#define wsBackSpace 0xff08 -#define wsCapsLock 0xffe5 -#define wsTab 0xff09 -#define wsF1 0xffbe -#define wsF2 0xffbf -#define wsF3 0xffc0 -#define wsF4 0xffc1 -#define wsF5 0xffc2 -#define wsF6 0xffc3 -#define wsF7 0xffc4 -#define wsF8 0xffc5 -#define wsF9 0xffc6 -#define wsF10 0xffc7 -#define wsF11 0xffc8 -#define wsF12 0xffc9 -#define wsInsert 0xff63 -#define wsDelete 0xffff -#define wsHome 0xff50 -#define wsEnd 0xff57 -#define wsPageUp 0xff55 -#define wsPageDown 0xff56 -#define wsNumLock 0xff7f -#define wsEscape 0xff1b -#define wsGrayEnter 0xff8d -#define wsGrayPlus 0xffab -#define wsGrayMinus 0xffad -#define wsGrayMul 0xffaa -#define wsGrayDiv 0xffaf -#define wsGrayDecimal 0xffae -#define wsGray0 0xffb0 -#define wsGray1 0xffb1 -#define wsGray2 0xffb2 -#define wsGray3 0xffb3 -#define wsGray4 0xffb4 -#define wsGray5 0xffb5 -#define wsGray6 0xffb6 -#define wsGray7 0xffb7 -#define wsGray8 0xffb8 -#define wsGray9 0xffb9 -#define wsGrayHome 0xff95 -#define wsGrayLeft 0xff96 -#define wsGrayUp 0xff97 -#define wsGrayRight 0xff98 -#define wsGrayDown 0xff99 -#define wsGrayPgUp 0xff9a -#define wsGrayPgDn 0xff9b -#define wsGrayEnd 0xff9c -#define wsGray5Dup 0xff9d -#define wsGrayInsert 0xff9e -#define wsGrayDelete 0xff9f - -#endif /* MPLAYER_WSKEYS_H */ diff -Nru mplayer2-2.0-426-gc32b3ed/libvo/x11_common.c mplayer2-2.0-554-gf63dbad/libvo/x11_common.c --- mplayer2-2.0-426-gc32b3ed/libvo/x11_common.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libvo/x11_common.c 2012-05-17 14:38:00.000000000 +0000 @@ -23,6 +23,7 @@ #include #include "config.h" +#include "bstr.h" #include "options.h" #include "mp_msg.h" #include "mp_fifo.h" @@ -45,6 +46,7 @@ #include #include #include +#include #ifdef CONFIG_XSS #include @@ -422,6 +424,8 @@ x11->screen = DefaultScreen(x11->display); // screen ID x11->rootwin = RootWindow(x11->display, x11->screen); // root window ID + x11->xim = XOpenIM(x11->display, NULL, NULL, NULL); + init_atoms(vo->x11); #ifdef CONFIG_XF86VM @@ -523,6 +527,8 @@ "vo: x11 uninit called but X11 not initialized..\n"); } else { mp_msg(MSGT_VO, MSGL_V, "vo: uninit ...\n"); + if (x11->xim) + XCloseIM(x11->xim); XSetErrorHandler(NULL); XCloseDisplay(x11->display); x11->depthonscreen = 0; @@ -531,63 +537,52 @@ talloc_free(x11); } -#include "wskeys.h" - -#ifdef XF86XK_AudioPause -static const struct mp_keymap keysym_map[] = { - {XF86XK_MenuKB, KEY_MENU}, - {XF86XK_AudioPlay, KEY_PLAY}, {XF86XK_AudioPause, KEY_PAUSE}, {XF86XK_AudioStop, KEY_STOP}, - {XF86XK_AudioPrev, KEY_PREV}, {XF86XK_AudioNext, KEY_NEXT}, - {XF86XK_AudioMute, KEY_MUTE}, {XF86XK_AudioLowerVolume, KEY_VOLUME_DOWN}, {XF86XK_AudioRaiseVolume, KEY_VOLUME_UP}, - {0, 0} -}; - -static void vo_x11_putkey_ext(struct vo *vo, int keysym, int modifiers) -{ - struct mp_fifo *f = vo->key_fifo; - int mpkey = lookup_keymap_table(keysym_map, keysym); - if (mpkey) - mplayer_put_key(f, mpkey + modifiers); -} -#endif - static const struct mp_keymap keymap[] = { // special keys - {wsPause, KEY_PAUSE}, {wsEscape, KEY_ESC}, {wsBackSpace, KEY_BS}, - {wsTab, KEY_TAB}, {wsEnter, KEY_ENTER}, + {XK_Pause, KEY_PAUSE}, {XK_Escape, KEY_ESC}, {XK_BackSpace, KEY_BS}, + {XK_Tab, KEY_TAB}, {XK_Return, KEY_ENTER}, + {XK_Menu, KEY_MENU}, {XK_Print, KEY_PRINT}, // cursor keys - {wsLeft, KEY_LEFT}, {wsRight, KEY_RIGHT}, {wsUp, KEY_UP}, {wsDown, KEY_DOWN}, + {XK_Left, KEY_LEFT}, {XK_Right, KEY_RIGHT}, {XK_Up, KEY_UP}, {XK_Down, KEY_DOWN}, // navigation block - {wsInsert, KEY_INSERT}, {wsDelete, KEY_DELETE}, {wsHome, KEY_HOME}, {wsEnd, KEY_END}, - {wsPageUp, KEY_PAGE_UP}, {wsPageDown, KEY_PAGE_DOWN}, + {XK_Insert, KEY_INSERT}, {XK_Delete, KEY_DELETE}, {XK_Home, KEY_HOME}, {XK_End, KEY_END}, + {XK_Page_Up, KEY_PAGE_UP}, {XK_Page_Down, KEY_PAGE_DOWN}, // F-keys - {wsF1, KEY_F+1}, {wsF2, KEY_F+2}, {wsF3, KEY_F+3}, {wsF4, KEY_F+4}, - {wsF5, KEY_F+5}, {wsF6, KEY_F+6}, {wsF7, KEY_F+7}, {wsF8, KEY_F+8}, - {wsF9, KEY_F+9}, {wsF10, KEY_F+10}, {wsF11, KEY_F+11}, {wsF12, KEY_F+12}, + {XK_F1, KEY_F+1}, {XK_F2, KEY_F+2}, {XK_F3, KEY_F+3}, {XK_F4, KEY_F+4}, + {XK_F5, KEY_F+5}, {XK_F6, KEY_F+6}, {XK_F7, KEY_F+7}, {XK_F8, KEY_F+8}, + {XK_F9, KEY_F+9}, {XK_F10, KEY_F+10}, {XK_F11, KEY_F+11}, {XK_F12, KEY_F+12}, // numpad independent of numlock - {wsGrayMinus, '-'}, {wsGrayPlus, '+'}, {wsGrayMul, '*'}, {wsGrayDiv, '/'}, - {wsGrayEnter, KEY_KPENTER}, + {XK_KP_Subtract, '-'}, {XK_KP_Add, '+'}, {XK_KP_Multiply, '*'}, {XK_KP_Divide, '/'}, + {XK_KP_Enter, KEY_KPENTER}, // numpad with numlock - {wsGray0, KEY_KP0}, {wsGray1, KEY_KP1}, {wsGray2, KEY_KP2}, - {wsGray3, KEY_KP3}, {wsGray4, KEY_KP4}, {wsGray5, KEY_KP5}, - {wsGray6, KEY_KP6}, {wsGray7, KEY_KP7}, {wsGray8, KEY_KP8}, - {wsGray9, KEY_KP9}, {wsGrayDecimal, KEY_KPDEC}, + {XK_KP_0, KEY_KP0}, {XK_KP_1, KEY_KP1}, {XK_KP_2, KEY_KP2}, + {XK_KP_3, KEY_KP3}, {XK_KP_4, KEY_KP4}, {XK_KP_5, KEY_KP5}, + {XK_KP_6, KEY_KP6}, {XK_KP_7, KEY_KP7}, {XK_KP_8, KEY_KP8}, + {XK_KP_9, KEY_KP9}, {XK_KP_Decimal, KEY_KPDEC}, + {XK_KP_Separator, KEY_KPDEC}, // numpad without numlock - {wsGrayInsert, KEY_KPINS}, {wsGrayEnd, KEY_KP1}, {wsGrayDown, KEY_KP2}, - {wsGrayPgDn, KEY_KP3}, {wsGrayLeft, KEY_KP4}, {wsGray5Dup, KEY_KP5}, - {wsGrayRight, KEY_KP6}, {wsGrayHome, KEY_KP7}, {wsGrayUp, KEY_KP8}, - {wsGrayPgUp, KEY_KP9}, {wsGrayDelete, KEY_KPDEL}, + {XK_KP_Insert, KEY_KPINS}, {XK_KP_End, KEY_KP1}, {XK_KP_Down, KEY_KP2}, + {XK_KP_Page_Down, KEY_KP3}, {XK_KP_Left, KEY_KP4}, {XK_KP_Begin, KEY_KP5}, + {XK_KP_Right, KEY_KP6}, {XK_KP_Home, KEY_KP7}, {XK_KP_Up, KEY_KP8}, + {XK_KP_Page_Up, KEY_KP9}, {XK_KP_Delete, KEY_KPDEL}, + +#ifdef XF86XK_AudioPause + {XF86XK_MenuKB, KEY_MENU}, + {XF86XK_AudioPlay, KEY_PLAY}, {XF86XK_AudioPause, KEY_PAUSE}, {XF86XK_AudioStop, KEY_STOP}, + {XF86XK_AudioPrev, KEY_PREV}, {XF86XK_AudioNext, KEY_NEXT}, + {XF86XK_AudioMute, KEY_MUTE}, {XF86XK_AudioLowerVolume, KEY_VOLUME_DOWN}, {XF86XK_AudioRaiseVolume, KEY_VOLUME_UP}, +#endif {0, 0} }; -static void vo_x11_putkey(struct vo *vo, int key, int modifiers) +static int vo_x11_lookupkey(int key) { static const char *passthrough_keys = " -+*/<>`~!@#$%^&()_{}:;\"\',.?\\|=[]"; int mpkey = 0; @@ -600,8 +595,7 @@ if (!mpkey) mpkey = lookup_keymap_table(keymap, key); - if (mpkey) - mplayer_put_key(vo->key_fifo, mpkey + modifiers); + return mpkey; } @@ -746,6 +740,10 @@ { XEvent xev; + if (x11->xic) + XDestroyIC(x11->xic); + x11->xic = NULL; + XUnmapWindow(x11->display, x11->window); XSelectInput(x11->display, x11->window, StructureNotifyMask); XDestroyWindow(x11->display, x11->window); @@ -782,14 +780,13 @@ int vo_x11_check_events(struct vo *vo) { struct vo_x11_state *x11 = vo->x11; + struct MPOpts *opts = vo->opts; Display *display = vo->x11->display; int ret = 0; XEvent Event; - char buf[100]; - KeySym keySym; - if (x11->vo_mouse_autohide && x11->mouse_waiting_hide && - (GetTimerMS() - x11->mouse_timer >= 1000)) { + if (x11->mouse_waiting_hide && opts->cursor_autohide_delay != -1 && + (GetTimerMS() - x11->mouse_timer >= opts->cursor_autohide_delay)) { vo_hidecursor(display, x11->window); x11->mouse_waiting_hide = 0; } @@ -812,8 +809,8 @@ break; case KeyPress: { - XLookupString(&Event.xkey, buf, sizeof(buf), &keySym, - &x11->compose_status); + char buf[100]; + KeySym keySym = 0; int modifiers = 0; if (Event.xkey.state & ShiftMask) modifiers |= KEY_MODIFIER_SHIFT; @@ -823,26 +820,41 @@ modifiers |= KEY_MODIFIER_ALT; if (Event.xkey.state & Mod4Mask) modifiers |= KEY_MODIFIER_META; -#ifdef XF86XK_AudioPause - vo_x11_putkey_ext(vo, keySym, modifiers); -#endif - vo_x11_putkey(vo, keySym, modifiers); + if (x11->xic) { + Status status; + int len = Xutf8LookupString(x11->xic, &Event.xkey, buf, + sizeof(buf), &keySym, + &status); + int mpkey = vo_x11_lookupkey(keySym); + if (mpkey) { + mplayer_put_key(vo->key_fifo, mpkey | modifiers); + } else if (status == XLookupChars + || status == XLookupBoth) + { + struct bstr t = { buf, len }; + mplayer_put_key_utf8(vo->key_fifo, modifiers, t); + } + } else { + XLookupString(&Event.xkey, buf, sizeof(buf), &keySym, + &x11->compose_status); + int mpkey = vo_x11_lookupkey(keySym); + if (mpkey) + mplayer_put_key(vo->key_fifo, mpkey | modifiers); + } ret |= VO_EVENT_KEYPRESS; } break; case MotionNotify: vo_mouse_movement(vo, Event.xmotion.x, Event.xmotion.y); - if (x11->vo_mouse_autohide) - { + if (opts->cursor_autohide_delay > -2) { vo_showcursor(display, x11->window); x11->mouse_waiting_hide = 1; x11->mouse_timer = GetTimerMS(); } break; case ButtonPress: - if (x11->vo_mouse_autohide) - { + if (opts->cursor_autohide_delay > -2) { vo_showcursor(display, x11->window); x11->mouse_waiting_hide = 1; x11->mouse_timer = GetTimerMS(); @@ -852,8 +864,7 @@ | MP_KEY_DOWN); break; case ButtonRelease: - if (x11->vo_mouse_autohide) - { + if (opts->cursor_autohide_delay > -2) { vo_showcursor(display, x11->window); x11->mouse_waiting_hide = 1; x11->mouse_timer = GetTimerMS(); @@ -993,43 +1004,32 @@ return WIN_LAYER_NORMAL; } -// set a X text property that expects a STRING type -static void vo_x11_set_property_string(struct vo *vo, Atom name, const char *t) +// set a X text property that expects a UTF8_STRING type +static void vo_x11_set_property_utf8(struct vo *vo, Atom name, const char *t) { struct vo_x11_state *x11 = vo->x11; - XTextProperty prop = {0}; - int success; - - success = Xutf8TextListToTextProperty(x11->display, (char **)&t, 1, - XStringStyle, &prop); - // The call can fail if the string uses characters not in the STRING - // encoding (which is latin-1 as far as I can tell). Try COMPOUND_TEXT - // instead. (It is possible that COMPOUND_TEXT always works, but since the - // difference in the type used for the property is visible to the Window - // manager and the ICCCM seems to specify STRING, we're trying to be careful - // and try STRING first.) - // GTK seems to follow about the same fallback mechanism. - if (success != Success) { - XFree(prop.value); - prop.value = NULL; - success = Xutf8TextListToTextProperty(x11->display, (char **)&t, 1, - XCompoundTextStyle, &prop); - } - - if (success == Success) - XSetTextProperty(x11->display, x11->window, &prop, name); - - XFree(prop.value); + XChangeProperty(x11->display, x11->window, name, x11->XAUTF8_STRING, 8, + PropModeReplace, t, strlen(t)); } -// set a X text property that expects a UTF8_STRING type -static void vo_x11_set_property_utf8(struct vo *vo, Atom name, const char *t) +// set a X text property that expects a STRING or COMPOUND_TEXT type +static void vo_x11_set_property_string(struct vo *vo, Atom name, const char *t) { struct vo_x11_state *x11 = vo->x11; + XTextProperty prop = {0}; - XChangeProperty(x11->display, x11->window, name, x11->XAUTF8_STRING, 8, - PropModeReplace, t, strlen(t)); + if (Xutf8TextListToTextProperty(x11->display, (char **)&t, 1, + XStdICCTextStyle, &prop) == Success) { + XSetTextProperty(x11->display, x11->window, &prop, name); + } else { + // Strictly speaking this violates the ICCCM, but there's no way we + // can do this correctly. + vo_x11_set_property_utf8(vo, name, t); + } + + if (prop.value) + XFree(prop.value); } static void vo_x11_update_window_title(struct vo *vo) @@ -1144,6 +1144,11 @@ XSetWMNormalHints(mDisplay, x11->window, &hint); if (!vo_border) vo_x11_decoration(vo, 0); // map window + x11->xic = XCreateIC(x11->xim, + XNInputStyle, XIMPreeditNone | XIMStatusNone, + XNClientWindow, x11->window, + XNFocusWindow, x11->window, + NULL); XSelectInput(mDisplay, x11->window, NoEventMask); vo_x11_selectinput_witherr(mDisplay, x11->window, StructureNotifyMask | KeyPressMask | PointerMotionMask | @@ -1169,7 +1174,6 @@ x11->vo_gc = XCreateGC(mDisplay, x11->window, 0, NULL); XSync(mDisplay, False); - x11->vo_mouse_autohide = 1; vo->event_fd = ConnectionNumber(x11->display); } diff -Nru mplayer2-2.0-426-gc32b3ed/libvo/x11_common.h mplayer2-2.0-554-gf63dbad/libvo/x11_common.h --- mplayer2-2.0-426-gc32b3ed/libvo/x11_common.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/libvo/x11_common.h 2012-05-17 14:38:00.000000000 +0000 @@ -36,6 +36,9 @@ int display_is_local; int depthonscreen; + XIM xim; + XIC xic; + GC vo_gc; struct xv_ck_info_s { @@ -45,7 +48,6 @@ unsigned long xv_colorkey; unsigned int xv_port; - int vo_mouse_autohide; int wm_type; int fs_type; int window_state; diff -Nru mplayer2-2.0-426-gc32b3ed/loader/afl.c mplayer2-2.0-554-gf63dbad/loader/afl.c --- mplayer2-2.0-426-gc32b3ed/loader/afl.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/loader/afl.c 2012-05-17 14:38:00.000000000 +0000 @@ -227,7 +227,7 @@ return MMSYSERR_ERROR; } - pad->pfnDriverProc = GetProcAddress(pad->hDrvr, "DriverProc"); + pad->pfnDriverProc = (DRIVERPROC)GetProcAddress(pad->hDrvr, "DriverProc"); /* insert new pad at beg of list */ pad->pNextACMDriver = padid->pACMDriverList; diff -Nru mplayer2-2.0-426-gc32b3ed/loader/dmo/DMO_VideoDecoder.c mplayer2-2.0-554-gf63dbad/loader/dmo/DMO_VideoDecoder.c --- mplayer2-2.0-426-gc32b3ed/loader/dmo/DMO_VideoDecoder.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/loader/dmo/DMO_VideoDecoder.c 2012-05-17 14:38:00.000000000 +0000 @@ -361,7 +361,7 @@ int DMO_VideoDecoder_SetDestFmt(DMO_VideoDecoder *this, int bits, unsigned int csp) { HRESULT result; - int should_test=1; + //int should_test=1; Debug printf("DMO_VideoDecoder_SetDestFmt (%p, %d, %d)\n",this,bits,(int)csp); @@ -467,7 +467,7 @@ else this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER); - +#if 0 switch(csp) { case fccYUY2: @@ -499,6 +499,7 @@ should_test=false; break; } +#endif #ifdef WIN32_LOADER Setup_FS_Segment(); diff -Nru mplayer2-2.0-426-gc32b3ed/loader/dshow/DS_Filter.c mplayer2-2.0-554-gf63dbad/loader/dshow/DS_Filter.c --- mplayer2-2.0-426-gc32b3ed/loader/dshow/DS_Filter.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/loader/dshow/DS_Filter.c 2012-05-17 14:38:00.000000000 +0000 @@ -216,7 +216,7 @@ enum_pins->vt->Reset(enum_pins); result = enum_pins->vt->Next(enum_pins, (ULONG)256, (IPin**)array, &fetched); - enum_pins->vt->Release(enum_pins); + enum_pins->vt->Release((IUnknown*)enum_pins); Debug printf("Pins enumeration returned %ld pins, error is %x\n", fetched, (int)result); for (i = 0; i < fetched; i++) @@ -306,7 +306,7 @@ init++; break; } - tempAll->vt->Release(tempAll); + tempAll->vt->Release((IUnknown*)tempAll); if (!init) { diff -Nru mplayer2-2.0-426-gc32b3ed/loader/dshow/DS_VideoDecoder.c mplayer2-2.0-554-gf63dbad/loader/dshow/DS_VideoDecoder.c --- mplayer2-2.0-426-gc32b3ed/loader/dshow/DS_VideoDecoder.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/loader/dshow/DS_VideoDecoder.c 2012-05-17 14:38:00.000000000 +0000 @@ -600,8 +600,8 @@ } if(this->m_pDS_Filter->m_pAll) - this->m_pDS_Filter->m_pAll->vt->Release(this->m_pDS_Filter->m_pAll); - this->m_pDS_Filter->m_pAll=MemAllocatorCreate(); + this->m_pDS_Filter->m_pAll->vt->Release((IUnknown*)this->m_pDS_Filter->m_pAll); + this->m_pDS_Filter->m_pAll=(IMemAllocator*)MemAllocatorCreate(); if (!this->m_pDS_Filter->m_pAll) { printf("Call to MemAllocatorCreate failed\n"); diff -Nru mplayer2-2.0-426-gc32b3ed/loader/dshow/allocator.c mplayer2-2.0-554-gf63dbad/loader/dshow/allocator.c --- mplayer2-2.0-426-gc32b3ed/loader/dshow/allocator.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/loader/dshow/allocator.c 2012-05-17 14:38:00.000000000 +0000 @@ -114,6 +114,7 @@ return NULL; } +#ifdef WIN32_LOADER static long MemAllocator_CreateAllocator(GUID* clsid, const GUID* iid, void** ppv) { IUnknown* p; @@ -130,6 +131,7 @@ return result; } +#endif static HRESULT STDCALL MemAllocator_SetProperties(IMemAllocator * This, /* [in] */ ALLOCATOR_PROPERTIES *pRequest, diff -Nru mplayer2-2.0-426-gc32b3ed/loader/dshow/graph.c mplayer2-2.0-554-gf63dbad/loader/dshow/graph.c --- mplayer2-2.0-426-gc32b3ed/loader/dshow/graph.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/loader/dshow/graph.c 2012-05-17 14:38:00.000000000 +0000 @@ -34,6 +34,7 @@ // Used for knowing when to register and unregister the class in COM. static int GraphKeeper = 0; +#ifdef WIN32_LOADER static long FilterGraph_CreateGraph(GUID* clsid, const GUID* iid, void** ppv) { IUnknown* p; @@ -50,6 +51,7 @@ return result; } +#endif static void FilterGraph_Destroy(FilterGraph* This) { @@ -62,56 +64,56 @@ free(This); } -HRESULT STDCALL FilterGraph_AddFilter(FilterGraph* This, - IBaseFilter* pFilter, - unsigned short* pName) +static HRESULT STDCALL FilterGraph_AddFilter(IFilterGraph* This, + IBaseFilter* pFilter, + unsigned short* pName) { Debug printf("FilterGraph_AddFilter(%p) called\n", This); return E_NOTIMPL; } -HRESULT STDCALL FilterGraph_RemoveFilter(FilterGraph* This, IBaseFilter* pFilter) +static HRESULT STDCALL FilterGraph_RemoveFilter(IFilterGraph* This, IBaseFilter* pFilter) { Debug printf("FilterGraph_RemoveFilter(%p) called\n", This); return E_NOTIMPL; } -HRESULT STDCALL FilterGraph_EnumFilters(FilterGraph* This, IEnumFilters** ppEnum) +static HRESULT STDCALL FilterGraph_EnumFilters(IFilterGraph* This, IEnumFilters** ppEnum) { Debug printf("FilterGraph_EnumFilters(%p) called\n", This); return E_NOTIMPL; } -HRESULT STDCALL FilterGraph_FindFilterByName(FilterGraph* This, - unsigned short* pName, - IBaseFilter** ppFilter) +static HRESULT STDCALL FilterGraph_FindFilterByName(IFilterGraph* This, + unsigned short* pName, + IBaseFilter** ppFilter) { Debug printf("FilterGraph_FindFilterByName(%p) called\n", This); return E_NOTIMPL; } -HRESULT STDCALL FilterGraph_ConnectDirect(FilterGraph* This, - IPin* ppinOut, - IPin* ppinIn, - const AM_MEDIA_TYPE* pmt) +static HRESULT STDCALL FilterGraph_ConnectDirect(IFilterGraph* This, + IPin* ppinOut, + IPin* ppinIn, + const AM_MEDIA_TYPE* pmt) { Debug printf("FilterGraph_ConnectDirect(%p) called\n", This); return E_NOTIMPL; } -HRESULT STDCALL FilterGraph_Reconnect(FilterGraph* This, IPin* ppin) +static HRESULT STDCALL FilterGraph_Reconnect(IFilterGraph* This, IPin* ppin) { Debug printf("FilterGraph_Reconnect(%p) called\n", This); return E_NOTIMPL; } -HRESULT STDCALL FilterGraph_Disconnect(FilterGraph* This, IPin* ppin) +static HRESULT STDCALL FilterGraph_Disconnect(IFilterGraph* This, IPin* ppin) { Debug printf("FilterGraph_Disconnect(%p) called\n", This); return E_NOTIMPL; } -HRESULT STDCALL FilterGraph_SetDefaultSyncSource(FilterGraph* This) +static HRESULT STDCALL FilterGraph_SetDefaultSyncSource(IFilterGraph* This) { Debug printf("FilterGraph_SetDefaultSyncSource(%p) called\n", This); return E_NOTIMPL; diff -Nru mplayer2-2.0-426-gc32b3ed/loader/dshow/graph.h mplayer2-2.0-554-gf63dbad/loader/dshow/graph.h --- mplayer2-2.0-426-gc32b3ed/loader/dshow/graph.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/loader/dshow/graph.h 2012-05-17 14:38:00.000000000 +0000 @@ -52,25 +52,6 @@ HRESULT STDCALL (*SetDefaultSyncSource)(FilterGraph* This); }; - -HRESULT STDCALL FilterGraph_AddFilter(FilterGraph* This, - IBaseFilter* pFilter, - unsigned short* pName); -HRESULT STDCALL FilterGraph_RemoveFilter(FilterGraph* This, - IBaseFilter* pFilter); -HRESULT STDCALL FilterGraph_EnumFilters(FilterGraph* This, - IEnumFilters** ppEnum); -HRESULT STDCALL FilterGraph_FindFilterByName(FilterGraph* This, - unsigned short* pName, - IBaseFilter** ppFilter); -HRESULT STDCALL FilterGraph_ConnectDirect(FilterGraph* This, - IPin* ppinOut, - IPin* ppinIn, - const AM_MEDIA_TYPE* pmt); -HRESULT STDCALL FilterGraph_Reconnect(FilterGraph* This, IPin* ppin); -HRESULT STDCALL FilterGraph_Disconnect(FilterGraph* This, IPin* ppin); -HRESULT STDCALL FilterGraph_SetDefaultSyncSource(FilterGraph* This); - FilterGraph* FilterGraphCreate(void); #endif /* MPLAYER_GRAPH_H */ diff -Nru mplayer2-2.0-426-gc32b3ed/loader/dshow/outputpin.c mplayer2-2.0-554-gf63dbad/loader/dshow/outputpin.c --- mplayer2-2.0-426-gc32b3ed/loader/dshow/outputpin.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/loader/dshow/outputpin.c 2012-05-17 14:38:00.000000000 +0000 @@ -552,8 +552,8 @@ /* [in] */ REFERENCE_TIME tStop, /* [in] */ double dRate) { - Debug printf("COutputPin_NewSegment(%Ld,%Ld,%f) called\n", - tStart, tStop, dRate); + Debug printf("COutputPin_NewSegment(%d,%d,%f) called\n", + (int)tStart, (int)tStop, dRate); return 0; } @@ -749,7 +749,7 @@ /* [in] */ long nSamples, /* [out] */ long *nSamplesProcessed) { - HRESULT hr; + HRESULT hr = 0; Debug printf("COutputMemPin_ReceiveMultiple(%p) %ld\n", This,nSamples); for(*nSamplesProcessed=0; *nSamplesProcessed < nSamples; *nSamplesProcessed++) { hr = This->vt->Receive(This,pSamples[*nSamplesProcessed]); diff -Nru mplayer2-2.0-426-gc32b3ed/loader/ext.c mplayer2-2.0-554-gf63dbad/loader/ext.c --- mplayer2-2.0-426-gc32b3ed/loader/ext.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/loader/ext.c 2012-05-17 14:38:00.000000000 +0000 @@ -443,12 +443,12 @@ if (type&MEM_RESERVE && (unsigned)address&0xffff) { size += (unsigned)address&0xffff; - address = (unsigned)address&~0xffff; + address = (void*)((unsigned)address&~0xffff); } pgsz = sysconf(_SC_PAGESIZE); if (type&MEM_COMMIT && (unsigned)address%pgsz) { size += (unsigned)address%pgsz; - address -= (unsigned)address%pgsz; + address = (void*)((unsigned)address - (unsigned)address%pgsz); } if (type&MEM_RESERVE && size<0x10000) size = 0x10000; @@ -531,7 +531,6 @@ WIN_BOOL WINAPI VirtualFree(LPVOID address, SIZE_T dwSize, DWORD dwFreeType)//not sure { virt_alloc* str=vm; - int answer; //printf("VirtualFree(0x%08X, %d, 0x%08X)\n", (unsigned)address, dwSize, dwFreeType); while(str) @@ -542,7 +541,7 @@ continue; } //printf(" VirtualFree(...) munmap(0x%08X, %d)\n", (unsigned)str->address, str->mapping_size); - answer=munmap(str->address, str->mapping_size); + munmap(str->address, str->mapping_size); if(str->next)str->next->prev=str->prev; if(str->prev)str->prev->next=str->next; if(vm==str)vm=str->prev; diff -Nru mplayer2-2.0-426-gc32b3ed/loader/ldt_keeper.c mplayer2-2.0-554-gf63dbad/loader/ldt_keeper.c --- mplayer2-2.0-426-gc32b3ed/loader/ldt_keeper.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/loader/ldt_keeper.c 2012-05-17 14:38:00.000000000 +0000 @@ -254,9 +254,6 @@ printf("Couldn't install fs segment, expect segfault\n"); } } -#elif defined(__OS2__) - /* convert flat addr to sel idx for LDT_SEL() */ - fs_ldt = (uintptr_t)fs_seg >> 16; #endif Setup_FS_Segment(); diff -Nru mplayer2-2.0-426-gc32b3ed/loader/module.c mplayer2-2.0-554-gf63dbad/loader/module.c --- mplayer2-2.0-426-gc32b3ed/loader/module.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/loader/module.c 2012-05-17 14:38:00.000000000 +0000 @@ -440,7 +440,7 @@ int i; // sse hack moved from patch dll into runtime patching - if (PE_FindExportedFunction(wm, "DriverProc", TRUE)==RVA(0x1000)) { + if ((char*)PE_FindExportedFunction(wm, "DriverProc", TRUE)==RVA(0x1000)) { fprintf(stderr, "VP3 DLL found\n"); for (i=0;i<18;i++) RVA(0x4bd6)[i]=0x90; } @@ -450,7 +450,7 @@ if (strstr(libname,"vp5vfw.dll") && wm) { int i; - if (PE_FindExportedFunction(wm, "DriverProc", TRUE)==RVA(0x3930)) { + if ((char*)PE_FindExportedFunction(wm, "DriverProc", TRUE)==RVA(0x3930)) { for (i=0;i<3;i++) RVA(0x4e86)[i]=0x90; for (i=0;i<3;i++) RVA(0x5a23)[i]=0x90; for (i=0;i<3;i++) RVA(0x5bff)[i]=0x90; @@ -463,12 +463,12 @@ if (strstr(libname,"vp6vfw.dll") && wm) { int i; - if (PE_FindExportedFunction(wm, "DriverProc", TRUE)==RVA(0x3ef0)) { + if ((char*)PE_FindExportedFunction(wm, "DriverProc", TRUE)==RVA(0x3ef0)) { // looks like VP 6.1.0.2 for (i=0;i<6;i++) RVA(0x7268)[i]=0x90; for (i=0;i<6;i++) RVA(0x7e83)[i]=0x90; for (i=0;i<6;i++) RVA(0x806a)[i]=0x90; - } else if (PE_FindExportedFunction(wm, "DriverProc", TRUE)==RVA(0x4120)) { + } else if ((char*)PE_FindExportedFunction(wm, "DriverProc", TRUE)==RVA(0x4120)) { // looks like VP 6.2.0.10 for (i=0;i<6;i++) RVA(0x7688)[i]=0x90; for (i=0;i<6;i++) RVA(0x82c3)[i]=0x90; @@ -476,7 +476,7 @@ for (i=0;i<6;i++) RVA(0x1d2cc)[i]=0x90; for (i=0;i<6;i++) RVA(0x2179d)[i]=0x90; for (i=0;i<6;i++) RVA(0x1977f)[i]=0x90; - } else if (PE_FindExportedFunction(wm, "DriverProc", TRUE)==RVA(0x3e70)) { + } else if ((char*)PE_FindExportedFunction(wm, "DriverProc", TRUE)==RVA(0x3e70)) { // looks like VP 6.0.7.3 for (i=0;i<6;i++) RVA(0x7559)[i]=0x90; for (i=0;i<6;i++) RVA(0x81c3)[i]=0x90; @@ -492,7 +492,7 @@ { // The codec calls IsRectEmpty with coords 0,0,0,0 => result is 0 // but it really wants the rectangle to be not empty - if (PE_FindExportedFunction(wm, "CreateInstance", TRUE)==RVA(0xb812)) { + if ((char*)PE_FindExportedFunction(wm, "CreateInstance", TRUE)==RVA(0xb812)) { // Dll version is 10.0.0.3645 *RVA(0x8b0f)=0xeb; // Jump always, ignoring IsRectEmpty result } else { @@ -509,7 +509,7 @@ // dispatch_addr = GetProcAddress(wm->module, "theQuickTimeDispatcher", TRUE); dispatch_addr = PE_FindExportedFunction(wm, "theQuickTimeDispatcher", TRUE); - if (dispatch_addr == RVA(0x124c30)) + if ((char*)dispatch_addr == RVA(0x124c30)) { fprintf(stderr, "QuickTime5 DLLs found\n"); ptr = (void **)RVA(0x375ca4); // dispatch_ptr @@ -537,7 +537,7 @@ RVA(0x08e0ae)[0] = 0xc3; // font/dc remover for (i=0;i<24;i++) RVA(0x07a1ad)[i]=0x90; // destroy window #endif - } else if (dispatch_addr == RVA(0x13b330)) + } else if ((char*)dispatch_addr == RVA(0x13b330)) { fprintf(stderr, "QuickTime6 DLLs found\n"); ptr = (void **)RVA(0x3b9524); // dispatcher_ptr @@ -546,7 +546,7 @@ for (i=0;i<5;i++) RVA(0x273122)[i]=0x90; // jmp_to_call_loadbitmap for (i=0;i<9;i++) RVA(0x273131)[i]=0x90; // call__calls_OLE_shit for (i=0;i<96;i++) RVA(0x2ac852)[i]=0x90; // disable threads - } else if (dispatch_addr == RVA(0x13c3e0)) + } else if ((char*)dispatch_addr == RVA(0x13c3e0)) { fprintf(stderr, "QuickTime6.3 DLLs found\n"); ptr = (void **)RVA(0x3ca01c); // dispatcher_ptr @@ -715,29 +715,9 @@ #ifdef EMU_QTX_API -#ifdef __OS2__ -uint32_t _System DosQueryMem(void *, uint32_t *, uint32_t *); -#endif - static int is_invalid_ptr_handle(void *p) { -#ifdef __OS2__ - uint32_t cb = 1; - uint32_t fl; - - if(DosQueryMem(p, &cb, &fl)) - return 1; - - // Occasionally, ptr with 'EXEC' attr is passed. - // On OS/2, however, malloc() never sets 'EXEC' attr. - // So ptr with 'EXEC' attr is invalid. - if(fl & 0x04) - return 1; - - return 0; -#else return (uint32_t)p >= 0x60000000; -#endif } static uint32_t ret_array[4096]; @@ -825,7 +805,7 @@ // memory management: case 0x150011: //NewPtrClear case 0x150012: //NewPtrSysClear - reg->eax = malloc(((uint32_t *)stack_base)[1]); + reg->eax = (uint32_t)malloc(((uint32_t *)stack_base)[1]); memset((void *)reg->eax,0,((uint32_t *)stack_base)[1]); #ifdef DEBUG_QTX_API printf("%*sLEAVE(%d): EMULATED! 0x%X\n",ret_i*2,"",ret_i, reg->eax); @@ -833,7 +813,7 @@ return 1; case 0x15000F: //NewPtr case 0x150010: //NewPtrSys - reg->eax = malloc(((uint32_t *)stack_base)[1]); + reg->eax = (uint32_t)malloc(((uint32_t *)stack_base)[1]); #ifdef DEBUG_QTX_API printf("%*sLEAVE(%d): EMULATED! 0x%X\n",ret_i*2,"",ret_i, reg->eax); #endif diff -Nru mplayer2-2.0-426-gc32b3ed/loader/pe_image.c mplayer2-2.0-554-gf63dbad/loader/pe_image.c --- mplayer2-2.0-426-gc32b3ed/loader/pe_image.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/loader/pe_image.c 2012-05-17 14:38:00.000000000 +0000 @@ -73,7 +73,7 @@ char *Module; unsigned int i, j; unsigned short *ordinal; - unsigned long *function,*functions; + unsigned long *function; unsigned char **name; unsigned int load_addr = hModule; @@ -84,14 +84,17 @@ IMAGE_EXPORT_DIRECTORY *pe_exports = (IMAGE_EXPORT_DIRECTORY*)RVA(rva_start); Module = (char*)RVA(pe_exports->Name); + (void)Module; //silence compiler warning TRACE("*******EXPORT DATA*******\n"); TRACE("Module name is %s, %ld functions, %ld names\n", Module, pe_exports->NumberOfFunctions, pe_exports->NumberOfNames); ordinal=(unsigned short*) RVA(pe_exports->AddressOfNameOrdinals); - functions=function=(unsigned long*) RVA(pe_exports->AddressOfFunctions); + function=(unsigned long*) RVA(pe_exports->AddressOfFunctions); name=(unsigned char**) RVA(pe_exports->AddressOfNames); + (void)name; //silence compiler warning + TRACE(" Ord RVA Addr Name\n" ); for (i=0;iNumberOfFunctions;i++, function++) { @@ -135,7 +138,6 @@ IMAGE_EXPORT_DIRECTORY *exports = pem->pe_export; unsigned int load_addr = wm->module; unsigned long rva_start, rva_end, addr; - char * forward; if (HIWORD(funcName)) TRACE("(%s)\n",funcName); @@ -152,7 +154,6 @@ ordinals= (unsigned short*) RVA(exports->AddressOfNameOrdinals); function= (unsigned long*) RVA(exports->AddressOfFunctions); name = (unsigned char **) RVA(exports->AddressOfNames); - forward = NULL; rva_start = PE_HEADER(wm->module)->OptionalHeader .DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress; rva_end = rva_start + PE_HEADER(wm->module)->OptionalHeader @@ -247,14 +248,9 @@ PE_MODREF *pem; unsigned int load_addr = wm->module; int i,characteristics_detection=1; - char *modname; assert(wm->type==MODULE32_PE); pem = &(wm->binfmt.pe); - if (pem->pe_export) - modname = (char*) RVA(pem->pe_export->Name); - else - modname = ""; TRACE("Dumping imports list\n"); diff -Nru mplayer2-2.0-426-gc32b3ed/loader/registry.c mplayer2-2.0-554-gf63dbad/loader/registry.c --- mplayer2-2.0-426-gc32b3ed/loader/registry.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/loader/registry.c 2012-05-17 14:38:00.000000000 +0000 @@ -339,7 +339,6 @@ { char* full_name; reg_handle_t* t; - struct reg_value* v; TRACE("Opening key %s\n", subkey); if(!regs) @@ -357,7 +356,7 @@ if(!full_name) return -1; TRACE("Opening key Fullname %s\n", full_name); - v=find_value_by_name(full_name); + find_value_by_name(full_name); t=insert_handle(generate_handle(), full_name); *newkey=t->handle; diff -Nru mplayer2-2.0-426-gc32b3ed/loader/win32.c mplayer2-2.0-554-gf63dbad/loader/win32.c --- mplayer2-2.0-426-gc32b3ed/loader/win32.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/loader/win32.c 2012-05-17 14:38:00.000000000 +0000 @@ -597,7 +597,7 @@ int pos = 0; while (*name) { if (*name > 256 || pos >= sizeof(aname) - 1) - return NULL; + return 0; aname[pos++] = *name++; } aname[pos] = 0; @@ -2015,15 +2015,15 @@ expSetEvent(mlist); break; case 1: // Semaphore - expReleaseSemaphore(mlist, 1, NULL); + expReleaseSemaphore((long)mlist, 1, NULL); break; case 2: // Mutex - expReleaseMutex(mlist); + expReleaseMutex((long)mlist); break; default: dbgprintf("Signalling unknown object type %d!\n", hObjectToSignal); } - return expWaitForSingleObject(hObjectToWaitOn, dwMilliseconds); + return (DWORD)expWaitForSingleObject((void*)hObjectToWaitOn, dwMilliseconds); } static long WINAPI expRegOpenKeyExA(long key, const char* subkey, long reserved, long access, int* newkey) @@ -2747,7 +2747,7 @@ { dbgprintf("EnumDisplayMonitors(0x%x, 0x%x, 0x%x, 0x%x) => ?\n", dc, r, callback_proc, callback_param); - return callback_proc(0, dc, r, callback_param); + return callback_proc(0, (HDC)dc, r, (LPARAM)callback_param); } #if 0 @@ -2847,8 +2847,8 @@ { int i, i2; dbgprintf("EnumWindows(0x%x, 0x%x) => 1\n", callback_func, callback_param); - i = callback_func(0, callback_param); - i2 = callback_func(1, callback_param); + i = callback_func(0, (LPARAM)callback_param); + i2 = callback_func(1, (LPARAM)callback_param); return i && i2; } @@ -4223,7 +4223,7 @@ } #else /* merged from wine - 2002.04.21 */ -typedef void (*INITTERMFUNC)(); +typedef void (*INITTERMFUNC)(void); static int exp_initterm(INITTERMFUNC *start, INITTERMFUNC *end) { dbgprintf("_initterm(0x%x, 0x%x) %p\n", start, end, *start); @@ -4900,7 +4900,7 @@ dbgprintf("CreatePalette(%x) => NULL\n", lpgpl); i = sizeof(LOGPALETTE)+((lpgpl->palNumEntries-1)*sizeof(PALETTEENTRY)); - test = malloc(i); + test = (HPALETTE)malloc(i); memcpy((void *)test, lpgpl, i); return test; diff -Nru mplayer2-2.0-426-gc32b3ed/loader/wine/winbase.h mplayer2-2.0-554-gf63dbad/loader/wine/winbase.h --- mplayer2-2.0-426-gc32b3ed/loader/wine/winbase.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/loader/wine/winbase.h 2012-05-17 14:38:00.000000000 +0000 @@ -786,8 +786,8 @@ struct { WORD wProcessorArchitecture; WORD wReserved; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; + } s; + } u; DWORD dwPageSize; LPVOID lpMinimumApplicationAddress; LPVOID lpMaximumApplicationAddress; diff -Nru mplayer2-2.0-426-gc32b3ed/loader/wine/windef.h mplayer2-2.0-554-gf63dbad/loader/wine/windef.h --- mplayer2-2.0-426-gc32b3ed/loader/wine/windef.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/loader/wine/windef.h 2012-05-17 14:38:00.000000000 +0000 @@ -47,6 +47,8 @@ # define NONAMELESSUNION #endif /* !defined(NONAMELESSUNION) */ +#if 0 + #ifndef NONAMELESSSTRUCT #define DUMMYSTRUCTNAME #define DUMMYSTRUCTNAME1 @@ -79,6 +81,8 @@ #define DUMMYUNIONNAME5 u5 #endif /* !defined(NONAMELESSUNION) */ +#endif + /* Calling conventions definitions */ #ifdef __i386__ @@ -301,8 +305,8 @@ typedef INT CALLBACK (*EDITWORDBREAKPROCA)(LPSTR,INT,INT,INT); typedef INT CALLBACK (*EDITWORDBREAKPROCW)(LPWSTR,INT,INT,INT); DECL_WINELIB_TYPE_AW(EDITWORDBREAKPROC) -typedef LRESULT CALLBACK (*FARPROC)(); -typedef INT CALLBACK (*PROC)(); +typedef LRESULT CALLBACK (*FARPROC)(void); +typedef INT CALLBACK (*PROC)(void); typedef WIN_BOOL CALLBACK (*GRAYSTRINGPROC)(HDC,LPARAM,INT); typedef LRESULT CALLBACK (*HOOKPROC)(INT,WPARAM,LPARAM); typedef WIN_BOOL CALLBACK (*PROPENUMPROCA)(HWND,LPCSTR,HANDLE); @@ -434,8 +438,8 @@ typedef LRESULT CALLBACK (*DRIVERPROC16)(DWORD,HDRVR16,UINT16,LPARAM,LPARAM); typedef WIN_BOOL16 CALLBACK (*DLGPROC16)(HWND16,UINT16,WPARAM16,LPARAM); typedef INT16 CALLBACK (*EDITWORDBREAKPROC16)(LPSTR,INT16,INT16,INT16); -typedef LRESULT CALLBACK (*FARPROC16)(); -typedef INT16 CALLBACK (*PROC16)(); +typedef LRESULT CALLBACK (*FARPROC16)(void); +typedef INT16 CALLBACK (*PROC16)(void); typedef WIN_BOOL16 CALLBACK (*GRAYSTRINGPROC16)(HDC16,LPARAM,INT16); typedef LRESULT CALLBACK (*HOOKPROC16)(INT16,WPARAM16,LPARAM); typedef WIN_BOOL16 CALLBACK (*PROPENUMPROC16)(HWND16,SEGPTR,HANDLE16); diff -Nru mplayer2-2.0-426-gc32b3ed/m_config.c mplayer2-2.0-554-gf63dbad/m_config.c --- mplayer2-2.0-426-gc32b3ed/m_config.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/m_config.c 2012-05-17 14:38:00.000000000 +0000 @@ -36,12 +36,21 @@ #define MAX_PROFILE_DEPTH 20 -static int parse_profile(const struct m_option *opt, struct bstr name, - struct bstr param, bool ambiguous_param, void *dst) +static int parse_include(struct m_config *config, struct bstr param, bool set) +{ + if (param.len == 0) + return M_OPT_MISSING_PARAM; + if (!set) + return 1; + char *filename = bstrdup0(NULL, param); + config->includefunc(config, filename); + talloc_free(filename); + return 1; +} + +static int parse_profile(struct m_config *config, const struct m_option *opt, + struct bstr name, struct bstr param, bool set) { - struct m_config *config = opt->priv; - char **list = NULL; - int i, r; if (!bstrcmp0(param, "help")) { struct m_profile *p; if (!config->profiles) { @@ -57,40 +66,23 @@ return M_OPT_EXIT - 1; } - r = m_option_type_string_list.parse(opt, name, param, false, &list); + char **list = NULL; + int r = m_option_type_string_list.parse(opt, name, param, false, &list); if (r < 0) return r; if (!list || !list[0]) return M_OPT_INVALID; - for (i = 0; list[i]; i++) - if (!m_config_get_profile(config, list[i])) { + for (int i = 0; list[i]; i++) { + struct m_profile *p = m_config_get_profile(config, list[i]); + if (!p) { mp_tmsg(MSGT_CFGPARSER, MSGL_WARN, "Unknown profile '%s'.\n", list[i]); r = M_OPT_INVALID; - } - if (dst) - m_option_copy(opt, dst, &list); - else - m_option_free(opt, &list); - return r; -} - -static void set_profile(const struct m_option *opt, void *dst, const void *src) -{ - struct m_config *config = opt->priv; - struct m_profile *p; - char **list = NULL; - int i; - if (!src || !*(char ***)src) - return; - m_option_copy(opt, &list, src); - for (i = 0; list[i]; i++) { - p = m_config_get_profile(config, list[i]); - if (!p) - continue; - m_config_set_profile(config, p); + } else if (set) + m_config_set_profile(config, p); } m_option_free(opt, &list); + return r; } static int show_profile(struct m_option *opt, char *name, char *param) @@ -150,18 +142,18 @@ static void m_option_save(const struct m_config *config, const struct m_option *opt, void *dst) { - if (opt->type->save) { + if (opt->type->copy) { const void *src = m_option_get_ptr(opt, config->optstruct); - opt->type->save(opt, dst, src); + opt->type->copy(opt, dst, src); } } static void m_option_set(const struct m_config *config, const struct m_option *opt, const void *src) { - if (opt->type->set) { + if (opt->type->copy) { void *dst = m_option_get_ptr(opt, config->optstruct); - opt->type->set(opt, dst, src); + opt->type->copy(opt, dst, src); } } @@ -172,40 +164,31 @@ const char *prefix, char *disabled_feature); struct m_config *m_config_new(void *optstruct, - int includefunc(struct m_option *conf, + int includefunc(struct m_config *conf, char *filename)) { struct m_config *config; - static int initialized = 0; - static struct m_option_type profile_opt_type; static const struct m_option ref_opts[] = { - { "profile", NULL, &profile_opt_type, CONF_NOSAVE, 0, 0, NULL }, + { "profile", NULL, CONF_TYPE_STRING_LIST, CONF_NOSAVE, 0, 0, NULL }, { "show-profile", show_profile, CONF_TYPE_PRINT_FUNC, CONF_NOCFG }, { "list-options", list_options, CONF_TYPE_PRINT_FUNC, CONF_NOCFG }, { NULL } }; - int i; config = talloc_zero(NULL, struct m_config); config->lvl = 1; // 0 Is the defaults - if (!initialized) { - initialized = 1; - profile_opt_type = m_option_type_string_list; - profile_opt_type.parse = parse_profile; - profile_opt_type.set = set_profile; - } struct m_option *self_opts = talloc_memdup(config, ref_opts, sizeof(ref_opts)); - for (i = 0; self_opts[i].name; i++) + for (int i = 1; self_opts[i].name; i++) self_opts[i].priv = config; m_config_register_options(config, self_opts); if (includefunc) { struct m_option *p = talloc_ptrtype(config, p); *p = (struct m_option){ - "include", includefunc, CONF_TYPE_FUNC_PARAM, - CONF_NOSAVE, 0, 0, config + "include", NULL, CONF_TYPE_STRING, CONF_NOSAVE, }; m_config_add_option(config, p, NULL, NULL); + config->includefunc = includefunc; } config->optstruct = optstruct; @@ -420,18 +403,15 @@ return NULL; } -static int m_config_parse_option(const struct m_config *config, +static int m_config_parse_option(struct m_config *config, struct bstr name, struct bstr param, bool ambiguous_param, bool set) { - struct m_config_option *co; - int r = 0; - assert(config != NULL); assert(config->lvl > 0); assert(name.len != 0); - co = m_config_get_co(config, name); + struct m_config_option *co = m_config_get_co(config, name); if (!co) return M_OPT_UNKNOWN; if (co->disabled_feature) { @@ -466,23 +446,27 @@ (co->opt->flags & M_OPT_PRE_PARSE) && (co->flags & M_CFG_OPT_SET))) set = 0; + if (config->includefunc && !bstrcmp0(name, "include")) { + return parse_include(config, param, set); + } else if (!bstrcmp0(name, "profile")) + return parse_profile(config, co->opt, name, param, set); + // Option with children are a bit different to parse if (co->opt->type->flags & M_OPT_TYPE_HAS_CHILD) { char **lst = NULL; - int i, sr; // Parse the child options - r = m_option_parse(co->opt, name, param, false, &lst); + int r = m_option_parse(co->opt, name, param, false, &lst); // Set them now if (r >= 0) - for (i = 0; lst && lst[2 * i]; i++) { + for (int i = 0; lst && lst[2 * i]; i++) { int l = strlen(co->name) + 1 + strlen(lst[2 * i]) + 1; if (r >= 0) { // Build the full name char n[l]; sprintf(n, "%s:%s", co->name, lst[2 * i]); - sr = m_config_parse_option(config, bstr(n), - bstr(lst[2 * i + 1]), false, - set); + int sr = m_config_parse_option(config, bstr(n), + bstr(lst[2 * i + 1]), false, + set); if (sr < 0) { if (sr == M_OPT_UNKNOWN) { mp_tmsg(MSGT_CFGPARSER, MSGL_ERR, @@ -502,18 +486,16 @@ talloc_free(lst[2 * i + 1]); } talloc_free(lst); - } else - r = m_option_parse(co->opt, name, param, ambiguous_param, - set ? co->slots->data : NULL); + return r; + } + void *dst = set ? m_option_get_ptr(co->opt, config->optstruct) : NULL; + int r = m_option_parse(co->opt, name, param, ambiguous_param, dst); // Parsing failed ? if (r < 0) return r; - // Set the option - if (set) { - m_option_set(config, co->opt, co->slots->data); + else if (set) co->flags |= M_CFG_OPT_SET; - } return r; } @@ -526,7 +508,7 @@ return m_config_parse_option(config, name, param, ambiguous_param, 1); } -int m_config_check_option(const struct m_config *config, struct bstr name, +int m_config_check_option(struct m_config *config, struct bstr name, struct bstr param, bool ambiguous_param) { int r; diff -Nru mplayer2-2.0-426-gc32b3ed/m_config.h mplayer2-2.0-554-gf63dbad/m_config.h --- mplayer2-2.0-426-gc32b3ed/m_config.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/m_config.h 2012-05-17 14:38:00.000000000 +0000 @@ -95,6 +95,7 @@ int profile_depth; void *optstruct; // struct mpopts or other + int (*includefunc)(struct m_config *conf, char *filename); } m_config_t; @@ -107,7 +108,7 @@ // Create a new config object. struct m_config * m_config_new(void *optstruct, - int includefunc(struct m_option *conf, char *filename)); + int includefunc(struct m_config *conf, char *filename)); // Free a config object. void m_config_free(struct m_config *config); @@ -151,7 +152,7 @@ /* Check if an option setting is valid. * Same as above m_config_set_option() but doesn't actually set anything. */ -int m_config_check_option(const struct m_config *config, struct bstr name, +int m_config_check_option(struct m_config *config, struct bstr name, struct bstr param, bool ambiguous_param); static inline int m_config_check_option0(struct m_config *config, diff -Nru mplayer2-2.0-426-gc32b3ed/m_option.c mplayer2-2.0-554-gf63dbad/m_option.c --- mplayer2-2.0-426-gc32b3ed/m_option.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/m_option.c 2012-05-17 14:38:00.000000000 +0000 @@ -129,16 +129,12 @@ } const m_option_type_t m_option_type_flag = { - "Flag", - "need yes or no in config files", - sizeof(int), - 0, - parse_flag, - print_flag, - copy_opt, - copy_opt, - NULL, - NULL + // need yes or no in config files + .name = "Flag", + .size = sizeof(int), + .parse = parse_flag, + .print = print_flag, + .copy = copy_opt, }; // Integer @@ -209,29 +205,19 @@ } const m_option_type_t m_option_type_int = { - "Integer", - "", - sizeof(int), - 0, - parse_int, - print_int, - copy_opt, - copy_opt, - NULL, - NULL + .name = "Integer", + .size = sizeof(int), + .parse = parse_int, + .print = print_int, + .copy = copy_opt, }; const m_option_type_t m_option_type_int64 = { - "Integer64", - "", - sizeof(int64_t), - 0, - parse_int64, - print_int, - copy_opt, - copy_opt, - NULL, - NULL + .name = "Integer64", + .size = sizeof(int64_t), + .parse = parse_int64, + .print = print_int, + .copy = copy_opt, }; static int parse_intpair(const struct m_option *opt, struct bstr name, @@ -271,11 +257,10 @@ } const struct m_option_type m_option_type_intpair = { - .name = "Int[-Int]", - .size = sizeof(int[2]), + .name = "Int[-Int]", + .size = sizeof(int[2]), .parse = parse_intpair, - .save = copy_opt, - .set = copy_opt, + .copy = copy_opt, }; static int parse_choice(const struct m_option *opt, struct bstr name, @@ -315,12 +300,11 @@ } const struct m_option_type m_option_type_choice = { - .name = "String", // same as arbitrary strings in option list for now - .size = sizeof(int), + .name = "String", // same as arbitrary strings in option list for now + .size = sizeof(int), .parse = parse_choice, .print = print_choice, - .save = copy_opt, - .set = copy_opt, + .copy = copy_opt, }; // Float @@ -391,16 +375,12 @@ } const m_option_type_t m_option_type_double = { - "Double", - "double precision floating point number or ratio (numerator[:/]denominator)", - sizeof(double), - 0, - parse_double, - print_double, - copy_opt, - copy_opt, - NULL, - NULL + // double precision float or ratio (numerator[:/]denominator) + .name = "Double", + .size = sizeof(double), + .parse = parse_double, + .print = print_double, + .copy = copy_opt, }; #undef VAL @@ -423,16 +403,12 @@ } const m_option_type_t m_option_type_float = { - "Float", - "floating point number or ratio (numerator[:/]denominator)", - sizeof(float), - 0, - parse_float, - print_float, - copy_opt, - copy_opt, - NULL, - NULL + // floating point number or ratio (numerator[:/]denominator) + .name = "Float", + .size = sizeof(float), + .parse = parse_float, + .print = print_float, + .copy = copy_opt, }; ///////////// Position @@ -455,16 +431,12 @@ } const m_option_type_t m_option_type_position = { - "Position", - "Integer (off_t)", - sizeof(off_t), - 0, - parse_position, - print_position, - copy_opt, - copy_opt, - NULL, - NULL + // Integer (off_t) + .name = "Position", + .size = sizeof(off_t), + .parse = parse_position, + .print = print_position, + .copy = copy_opt, }; @@ -521,16 +493,13 @@ } const m_option_type_t m_option_type_string = { - "String", - "", - sizeof(char *), - M_OPT_TYPE_DYNAMIC, - parse_str, - print_str, - copy_str, - copy_str, - copy_str, - free_str + .name = "String", + .size = sizeof(char *), + .flags = M_OPT_TYPE_DYNAMIC, + .parse = parse_str, + .print = print_str, + .copy = copy_str, + .free = free_str, }; //////////// String list @@ -788,164 +757,24 @@ } const m_option_type_t m_option_type_string_list = { - "String list", - "A list of strings separated by ','\n" - "Option with a name ending in an * permits using the following suffix: \n" - "\t-add: Add the given parameters at the end of the list.\n" - "\t-pre: Add the given parameters at the beginning of the list.\n" - "\t-del: Remove the entry at the given indices.\n" - "\t-clr: Clear the list.\n" - "e.g: -vf-add flip,mirror -vf-del 2,5\n", - sizeof(char **), - M_OPT_TYPE_DYNAMIC | M_OPT_TYPE_ALLOW_WILDCARD, - parse_str_list, - print_str_list, - copy_str_list, - copy_str_list, - copy_str_list, - free_str_list + /* A list of strings separated by ','. + * Option with a name ending in '*' permits using the following suffixes: + * -add: Add the given parameters at the end of the list. + * -pre: Add the given parameters at the beginning of the list. + * -del: Remove the entry at the given indices. + * -clr: Clear the list. + * e.g: -vf-add flip,mirror -vf-del 2,5 + */ + .name = "String list", + .size = sizeof(char **), + .flags = M_OPT_TYPE_DYNAMIC | M_OPT_TYPE_ALLOW_WILDCARD, + .parse = parse_str_list, + .print = print_str_list, + .copy = copy_str_list, + .free = free_str_list, }; -/////////////////// Func based options - -// A chained list to save the various calls for func_param -struct m_func_save { - struct m_func_save *next; - char *name; - char *param; -}; - -#undef VAL -#define VAL(x) (*(struct m_func_save **)(x)) - -static void free_func_pf(void *src) -{ - struct m_func_save *s, *n; - - if (!src) - return; - - s = VAL(src); - - while (s) { - n = s->next; - talloc_free(s->name); - talloc_free(s->param); - talloc_free(s); - s = n; - } - VAL(src) = NULL; -} - -// Parser for func_param -static int parse_func_pf(const m_option_t *opt, struct bstr name, - struct bstr param, bool ambiguous_param, void *dst) -{ - struct m_func_save *s, *p; - - if (!dst) - return 1; - - s = talloc_zero(NULL, struct m_func_save); - s->name = bstrdup0(NULL, name); - s->param = bstrdup0(NULL, param); - - p = VAL(dst); - if (p) { - for (; p->next != NULL; p = p->next) - /**/; - p->next = s; - } else - VAL(dst) = s; - - return 1; -} - -static void copy_func_pf(const m_option_t *opt, void *dst, const void *src) -{ - struct m_func_save *d = NULL, *s, *last = NULL; - - if (!(dst && src)) - return; - s = VAL(src); - - if (VAL(dst)) - free_func_pf(dst); - - while (s) { - d = talloc_zero(NULL, struct m_func_save); - d->name = talloc_strdup(NULL, s->name); - d->param = talloc_strdup(NULL, s->param); - if (last) - last->next = d; - else - VAL(dst) = d; - last = d; - s = s->next; - } - - -} - -/////////////////// Func_param - -static void set_func_param(const m_option_t *opt, void *dst, const void *src) -{ - struct m_func_save *s; - - if (!src) - return; - s = VAL(src); - - if (!s) - return; - - for (; s != NULL; s = s->next) - ((m_opt_func_param_t) opt->p)(opt, s->param); -} - -const m_option_type_t m_option_type_func_param = { - "Func param", - "", - sizeof(struct m_func_save *), - M_OPT_TYPE_INDIRECT, - parse_func_pf, - NULL, - NULL, // Nothing to do on save - set_func_param, - copy_func_pf, - free_func_pf -}; - -/////////////// Func - -#undef VAL - -static int parse_func(const m_option_t *opt, struct bstr name, - struct bstr param, bool ambiguous_param, void *dst) -{ - return 0; -} - -static void set_func(const m_option_t *opt, void *dst, const void *src) -{ - ((m_opt_func_t) opt->p)(opt); -} - -const m_option_type_t m_option_type_func = { - "Func", - "", - sizeof(int), - M_OPT_TYPE_INDIRECT, - parse_func, - NULL, - NULL, // Nothing to do on save - set_func, - NULL, - NULL -}; - /////////////////// Print static int parse_print(const m_option_t *opt, struct bstr name, @@ -969,42 +798,19 @@ } const m_option_type_t m_option_type_print = { - "Print", - "", - 0, - 0, - parse_print, - NULL, - NULL, - NULL, - NULL, - NULL + .name = "Print", + .parse = parse_print, }; const m_option_type_t m_option_type_print_indirect = { - "Print", - "", - 0, - 0, - parse_print, - NULL, - NULL, - NULL, - NULL, - NULL + .name = "Print", + .parse = parse_print, }; const m_option_type_t m_option_type_print_func = { - "Print", - "", - 0, - M_OPT_TYPE_ALLOW_WILDCARD, - parse_print, - NULL, - NULL, - NULL, - NULL, - NULL + .name = "Print", + .flags = M_OPT_TYPE_ALLOW_WILDCARD, + .parse = parse_print, }; @@ -1097,16 +903,10 @@ } const m_option_type_t m_option_type_subconfig = { - "Subconfig", - "The syntax is -option opt1=foo:flag:opt2=blah", - sizeof(int), - M_OPT_TYPE_HAS_CHILD, - parse_subconf, - NULL, - NULL, - NULL, - NULL, - NULL + // The syntax is -option opt1=foo:flag:opt2=blah + .name = "Subconfig", + .flags = M_OPT_TYPE_HAS_CHILD, + .parse = parse_subconf, }; #include "libmpcodecs/img_format.h" @@ -1230,16 +1030,11 @@ } const m_option_type_t m_option_type_imgfmt = { - "Image format", - "Please report any missing colorspaces.", - sizeof(uint32_t), - 0, - parse_imgfmt, - NULL, - copy_opt, - copy_opt, - NULL, - NULL + // Please report any missing colorspaces + .name = "Image format", + .size = sizeof(uint32_t), + .parse = parse_imgfmt, + .copy = copy_opt, }; #include "libaf/af_format.h" @@ -1325,16 +1120,11 @@ } const m_option_type_t m_option_type_afmt = { - "Audio format", - "Please report any missing formats.", - sizeof(uint32_t), - 0, - parse_afmt, - NULL, - copy_opt, - copy_opt, - NULL, - NULL + // Please report any missing formats + .name = "Audio format", + .size = sizeof(uint32_t), + .parse = parse_afmt, + .copy = copy_opt, }; @@ -1377,16 +1167,11 @@ } const m_option_type_t m_option_type_time = { - "Time", - "", - sizeof(double), - 0, - parse_time, - print_double, - copy_opt, - copy_opt, - NULL, - NULL + .name = "Time", + .size = sizeof(double), + .parse = parse_time, + .print = print_double, + .copy = copy_opt, }; @@ -1441,16 +1226,10 @@ } const m_option_type_t m_option_type_time_size = { - "Time or size", - "", - sizeof(m_time_size_t), - 0, - parse_time_size, - NULL, - copy_opt, - copy_opt, - NULL, - NULL + .name = "Time or size", + .size = sizeof(m_time_size_t), + .parse = parse_time_size, + .copy = copy_opt, }; @@ -1660,16 +1439,8 @@ const m_option_type_t m_option_type_obj_params = { - "Object params", - "", - 0, - 0, - parse_obj_params, - NULL, - NULL, - NULL, - NULL, - NULL + .name = "Object params", + .parse = parse_obj_params, }; /// Some predefined types as a definition would be quite lengthy @@ -1999,16 +1770,12 @@ } const m_option_type_t m_option_type_obj_settings_list = { - "Object settings list", - "", - sizeof(m_obj_settings_t *), - M_OPT_TYPE_DYNAMIC | M_OPT_TYPE_ALLOW_WILDCARD, - parse_obj_settings_list, - NULL, - copy_obj_settings_list, - copy_obj_settings_list, - copy_obj_settings_list, - free_obj_settings_list, + .name = "Object settings list", + .size = sizeof(m_obj_settings_t *), + .flags = M_OPT_TYPE_DYNAMIC | M_OPT_TYPE_ALLOW_WILDCARD, + .parse = parse_obj_settings_list, + .copy = copy_obj_settings_list, + .free = free_obj_settings_list, }; @@ -2085,16 +1852,8 @@ const m_option_type_t m_option_type_obj_presets = { - "Object presets", - "", - 0, - 0, - parse_obj_presets, - NULL, - NULL, - NULL, - NULL, - NULL + .name = "Object presets", + .parse = parse_obj_presets, }; static int parse_custom_url(const m_option_t *opt, struct bstr name, @@ -2282,14 +2041,6 @@ /// TODO : Write the other needed funcs for 'normal' options const m_option_type_t m_option_type_custom_url = { - "Custom URL", - "", - 0, - 0, - parse_custom_url, - NULL, - NULL, - NULL, - NULL, - NULL + .name = "Custom URL", + .parse = parse_custom_url, }; diff -Nru mplayer2-2.0-426-gc32b3ed/m_option.h mplayer2-2.0-554-gf63dbad/m_option.h --- mplayer2-2.0-426-gc32b3ed/m_option.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/m_option.h 2012-05-17 14:38:00.000000000 +0000 @@ -55,28 +55,9 @@ extern const m_option_type_t m_option_type_imgfmt; extern const m_option_type_t m_option_type_afmt; -// Func-based types -extern const m_option_type_t m_option_type_func_param; -extern const m_option_type_t m_option_type_func; - -// Callback used to reset func options. -typedef void (*m_opt_default_func_t)(const m_option_t *, const char *); - -// Callback used by m_option_type_func_full options. +// Callback used by m_option_type_print_func options. typedef int (*m_opt_func_full_t)(const m_option_t *, const char *, const char *); -// Callback used by m_option_type_func_param options. -typedef int (*m_opt_func_param_t)(const m_option_t *, const char *); - -// Callback used by m_option_type_func options. -typedef int (*m_opt_func_t)(const m_option_t *); - -// Backwards compatibility -typedef m_opt_default_func_t cfg_default_func_t; -typedef m_opt_func_full_t cfg_func_arg_param_t; -typedef m_opt_func_param_t cfg_func_param_t; -typedef m_opt_func_t cfg_func_t; - #define END_AT_NONE 0 #define END_AT_TIME 1 #define END_AT_SIZE 2 @@ -175,8 +156,6 @@ #define CONF_TYPE_FLOAT (&m_option_type_float) #define CONF_TYPE_DOUBLE (&m_option_type_double) #define CONF_TYPE_STRING (&m_option_type_string) -#define CONF_TYPE_FUNC (&m_option_type_func) -#define CONF_TYPE_FUNC_PARAM (&m_option_type_func_param) #define CONF_TYPE_PRINT (&m_option_type_print) #define CONF_TYPE_PRINT_INDIRECT (&m_option_type_print_indirect) #define CONF_TYPE_PRINT_FUNC (&m_option_type_print_func) @@ -198,8 +177,6 @@ // Option type description struct m_option_type { const char *name; - // Syntax description, etc - const char *comments; // Size needed for the data. unsigned int size; // See \ref OptionTypeFlags. @@ -229,35 +206,12 @@ */ char *(*print)(const m_option_t *opt, const void *val); - /** \name - * These functions are called to save/set/restore the status of the - * variables. The difference between the 3 only matters for types like - * \ref m_option_type_func where 'setting' needs to do more than just - * copying some data. - */ - //@{ - - // Update a save slot (dst) from the current value in the program (src). - /** \param opt The option to copy. - * \param dst Pointer to the destination memory. - * \param src Pointer to the source memory. - */ - void (*save)(const m_option_t *opt, void *dst, const void *src); - - // Set the value in the program (dst) from a save slot. - /** \param opt The option to copy. - * \param dst Pointer to the destination memory. - * \param src Pointer to the source memory. - */ - void (*set)(const m_option_t *opt, void *dst, const void *src); - - // Copy the data between two save slots. If NULL and size is > 0 a memcpy will be used. + // Copy data between two locations. Deep copy if the data has pointers. /** \param opt The option to copy. * \param dst Pointer to the destination memory. * \param src Pointer to the source memory. */ void (*copy)(const m_option_t *opt, void *dst, const void *src); - //@} // Free the data allocated for a save slot. /** This is only needed for dynamic types like strings. @@ -296,7 +250,6 @@ // Type dependent data (for all kinds of extended settings). /** This used to be a function pointer to hold a 'reverse to defaults' func. * Now it can be used to pass any type of extra args needed by the parser. - * Passing a 'default func' is still valid for all func based option types. */ void *priv; @@ -374,17 +327,6 @@ */ #define M_OPT_TYPE_DYNAMIC (1 << 2) -// Indirect option type. -/** If this is set the parse function doesn't directly return - * the wanted thing. Options use this if for some reasons they have to wait - * until the set call to be able to correctly set the target var. - * So for those types new values must first be parsed, then set to the target - * var. If this flag isn't set then new values can be parsed directly to the - * target var. It's used by the callback-based options as the callback call - * may append later on. - */ -#define M_OPT_TYPE_INDIRECT (1 << 3) - ///////////////////////////// Parser flags ///////////////////////////////// // On success parsers return the number of arguments consumed: 0 or 1. @@ -416,13 +358,6 @@ */ #define M_OPT_EXIT -6 -// These are kept for compatibility with older code. -// -#define ERR_NOT_AN_OPTION M_OPT_UNKNOWN -#define ERR_MISSING_PARAM M_OPT_MISSING_PARAM -#define ERR_OUT_OF_RANGE M_OPT_OUT_OF_RANGE -#define ERR_FUNC_ERR M_OPT_PARSER_ERR - char *m_option_strerror(int code); // Find the option matching the given name in the list. @@ -465,8 +400,6 @@ { if (opt->type->copy) opt->type->copy(opt, dst, src); - else if (opt->type->size > 0) - memcpy(dst, src, opt->type->size); } // Helper around \ref m_option_type::free. @@ -507,5 +440,6 @@ #define OPT_HELPER_REMOVEPAREN(...) __VA_ARGS__ #define OPT_CHOICE(optname, varname, flags, choices) {optname, NULL, &m_option_type_choice, flags, 0, 0, (void *)&(const struct m_opt_choice_alternatives[]){OPT_HELPER_REMOVEPAREN choices, {NULL}}, 1, offsetof(struct MPOpts, varname)} #define OPT_TIME(optname, varname, flags) {optname, NULL, &m_option_type_time, flags, 0, 0, NULL, 1, offsetof(struct MPOpts, varname)} +#define OPT_ERRORMESSAGE(optname, message) {optname, message, CONF_TYPE_PRINT} #endif /* MPLAYER_M_OPTION_H */ diff -Nru mplayer2-2.0-426-gc32b3ed/m_struct.c mplayer2-2.0-554-gf63dbad/m_struct.c --- mplayer2-2.0-426-gc32b3ed/m_struct.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/m_struct.c 2012-05-17 14:38:00.000000000 +0000 @@ -48,13 +48,6 @@ mp_msg(MSGT_CFGPARSER, MSGL_ERR,"Struct %s needs defaults\n",st->name); return NULL; } - // Check the struct fields - for(i = 0 ; st->fields[i].name ; i++) { - if(st->fields[i].type->flags & M_OPT_TYPE_INDIRECT) { - mp_msg(MSGT_CFGPARSER, MSGL_ERR,"Struct %s->%s: Option types with the indirect flag are forbidden.\n",st->name,st->fields[i].name); - return NULL; - } - } r = calloc(1,st->size); memcpy(r,st->defaults,st->size); diff -Nru mplayer2-2.0-426-gc32b3ed/mixer.c mplayer2-2.0-554-gf63dbad/mixer.c --- mplayer2-2.0-426-gc32b3ed/mixer.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/mixer.c 2012-05-17 14:38:00.000000000 +0000 @@ -17,163 +17,267 @@ */ #include -#ifndef __MINGW32__ -#include -#endif -#include -#include -#include + +#include #include "config.h" #include "libao2/audio_out.h" #include "libaf/af.h" +#include "mp_msg.h" #include "mixer.h" -char * mixer_device=NULL; -char * mixer_channel=NULL; -int soft_vol = 0; -float soft_vol_max = 110.0; - -void mixer_getvolume(mixer_t *mixer, float *l, float *r) +static void checkvolume(struct mixer *mixer) { - ao_control_vol_t vol; - *l=0; *r=0; - if (mixer->ao) { - if(soft_vol || - CONTROL_OK != ao_control(mixer->ao, AOCONTROL_GET_VOLUME, &vol)) { - if (!mixer->afilter) + if (!mixer->ao) return; - else { + + ao_control_vol_t vol; + if (mixer->softvol || CONTROL_OK != ao_control(mixer->ao, + AOCONTROL_GET_VOLUME, &vol)) { + mixer->softvol = true; + if (!mixer->afilter) + return; float db_vals[AF_NCH]; if (!af_control_any_rev(mixer->afilter, - AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_GET, db_vals)) - db_vals[0] = db_vals[1] = 1.0; + AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_GET, db_vals)) + db_vals[0] = db_vals[1] = 1.0; else - af_from_dB (2, db_vals, db_vals, 20.0, -200.0, 60.0); - vol.left = (db_vals[0] / (soft_vol_max / 100.0)) * 100.0; - vol.right = (db_vals[1] / (soft_vol_max / 100.0)) * 100.0; - } - } - *r=vol.right; - *l=vol.left; - } + af_from_dB(2, db_vals, db_vals, 20.0, -200.0, 60.0); + vol.left = (db_vals[0] / (mixer->softvol_max / 100.0)) * 100.0; + vol.right = (db_vals[1] / (mixer->softvol_max / 100.0)) * 100.0; + } + float l = mixer->vol_l; + float r = mixer->vol_r; + if (mixer->muted_using_volume) + l = r = 0; + /* Try to detect cases where the volume has been changed by some external + * action (such as something else changing a shared system-wide volume). + * We don't test for exact equality, as some AOs may round the value + * we last set to some nearby supported value. 3 has been the default + * volume step for increase/decrease keys, and is apparently big enough + * to step to the next possible value in most setups. + */ + if (FFABS(vol.left - l) >= 3 || FFABS(vol.right - r) >= 3) { + mixer->vol_l = vol.left; + mixer->vol_r = vol.right; + if (mixer->muted_using_volume) + mixer->muted = false; + } + if (!mixer->softvol) + // Rely on the value not changing if the query is not supported + ao_control(mixer->ao, AOCONTROL_GET_MUTE, &mixer->muted); + mixer->muted_by_us &= mixer->muted; + mixer->muted_using_volume &= mixer->muted; +} + +void mixer_getvolume(mixer_t *mixer, float *l, float *r) +{ + checkvolume(mixer); + *l = mixer->vol_l; + *r = mixer->vol_r; +} + +static void setvolume_internal(mixer_t *mixer, float l, float r) +{ + struct ao_control_vol vol = {.left = l, .right = r}; + if (!mixer->softvol) { + // relies on the driver data being permanent (so ptr stays valid) + mixer->restore_volume = mixer->ao->no_persistent_volume ? + mixer->ao->driver->info->short_name : NULL; + if (ao_control(mixer->ao, AOCONTROL_SET_VOLUME, &vol) != CONTROL_OK) + mp_tmsg(MSGT_GLOBAL, MSGL_ERR, + "[Mixer] Failed to change audio output volume.\n"); + return; + } + mixer->restore_volume = "softvol"; + if (!mixer->afilter) + return; + // af_volume uses values in dB + float db_vals[AF_NCH]; + int i; + db_vals[0] = (l / 100.0) * (mixer->softvol_max / 100.0); + db_vals[1] = (r / 100.0) * (mixer->softvol_max / 100.0); + for (i = 2; i < AF_NCH; i++) + db_vals[i] = ((l + r) / 100.0) * (mixer->softvol_max / 100.0) / 2.0; + af_to_dB(AF_NCH, db_vals, db_vals, 20.0); + if (!af_control_any_rev(mixer->afilter, + AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_SET, + db_vals)) { + mp_tmsg(MSGT_GLOBAL, MSGL_INFO, + "[Mixer] No hardware mixing, inserting volume filter.\n"); + if (!(af_add(mixer->afilter, "volume") + && af_control_any_rev(mixer->afilter, + AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_SET, + db_vals))) + mp_tmsg(MSGT_GLOBAL, MSGL_ERR, + "[Mixer] No volume control available.\n"); + } } void mixer_setvolume(mixer_t *mixer, float l, float r) { - ao_control_vol_t vol; - vol.right=r; vol.left=l; - if (mixer->ao) { - if(soft_vol || - CONTROL_OK != ao_control(mixer->ao, AOCONTROL_SET_VOLUME, &vol)) { - if (!mixer->afilter) + checkvolume(mixer); // to check mute status and AO support for volume + mixer->vol_l = av_clip(l, 0, 100); + mixer->vol_r = av_clip(r, 0, 100); + if (!mixer->ao || mixer->muted) return; - else { - // af_volume uses values in dB - float db_vals[AF_NCH]; - int i; - db_vals[0] = (l / 100.0) * (soft_vol_max / 100.0); - db_vals[1] = (r / 100.0) * (soft_vol_max / 100.0); - for (i = 2; i < AF_NCH; i++) { - db_vals[i] = ((l + r) / 100.0) * (soft_vol_max / 100.0) / 2.0; + setvolume_internal(mixer, mixer->vol_l, mixer->vol_r); +} + +void mixer_getbothvolume(mixer_t *mixer, float *b) +{ + float mixer_l, mixer_r; + mixer_getvolume(mixer, &mixer_l, &mixer_r); + *b = (mixer_l + mixer_r) / 2; +} + +void mixer_setmute(struct mixer *mixer, bool mute) +{ + checkvolume(mixer); + if (mute != mixer->muted) { + if (!mixer->softvol && !mixer->muted_using_volume && ao_control( + mixer->ao, AOCONTROL_SET_MUTE, &mute) == CONTROL_OK) { + mixer->muted_using_volume = false; + } else { + setvolume_internal(mixer, mixer->vol_l*!mute, mixer->vol_r*!mute); + mixer->muted_using_volume = mute; } - af_to_dB (AF_NCH, db_vals, db_vals, 20.0); - if (!af_control_any_rev(mixer->afilter, - AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_SET, db_vals)) { - mp_tmsg(MSGT_GLOBAL, MSGL_INFO, "[Mixer] No hardware mixing, inserting volume filter.\n"); - if (af_add(mixer->afilter, "volume")) { - if (!af_control_any_rev(mixer->afilter, - AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_SET, db_vals)) { - mp_tmsg(MSGT_GLOBAL, MSGL_ERR, "[Mixer] No volume control available.\n"); - return; - } - } - } - } + mixer->muted = mute; + mixer->muted_by_us = mute; } - } - mixer->muted=0; } -void mixer_incvolume(mixer_t *mixer) +bool mixer_getmute(struct mixer *mixer) { - float mixer_l, mixer_r; - mixer_getvolume(mixer, &mixer_l, &mixer_r); - mixer_l += mixer->volstep; - if ( mixer_l > 100 ) mixer_l = 100; - mixer_r += mixer->volstep; - if ( mixer_r > 100 ) mixer_r = 100; - mixer_setvolume(mixer, mixer_l, mixer_r); + checkvolume(mixer); + return mixer->muted; } -void mixer_decvolume(mixer_t *mixer) +static void addvolume(struct mixer *mixer, float d) { - float mixer_l, mixer_r; - mixer_getvolume(mixer, &mixer_l, &mixer_r); - mixer_l -= mixer->volstep; - if ( mixer_l < 0 ) mixer_l = 0; - mixer_r -= mixer->volstep; - if ( mixer_r < 0 ) mixer_r = 0; - mixer_setvolume(mixer, mixer_l, mixer_r); + checkvolume(mixer); + mixer_setvolume(mixer, mixer->vol_l + d, mixer->vol_r + d); + if (d > 0) + mixer_setmute(mixer, false); } -void mixer_getbothvolume(mixer_t *mixer, float *b) +void mixer_incvolume(mixer_t *mixer) { - float mixer_l, mixer_r; - mixer_getvolume(mixer, &mixer_l, &mixer_r); - *b = ( mixer_l + mixer_r ) / 2; + addvolume(mixer, mixer->volstep); } -void mixer_mute(mixer_t *mixer) -{ - if (mixer->muted) mixer_setvolume(mixer, mixer->last_l, mixer->last_r); - else - { - mixer_getvolume(mixer, &mixer->last_l, &mixer->last_r); - mixer_setvolume(mixer, 0, 0); - mixer->muted=1; - } +void mixer_decvolume(mixer_t *mixer) +{ + addvolume(mixer, -mixer->volstep); } void mixer_getbalance(mixer_t *mixer, float *val) { - *val = 0.f; - if(!mixer->afilter) - return; - af_control_any_rev(mixer->afilter, - AF_CONTROL_PAN_BALANCE | AF_CONTROL_GET, val); + if (mixer->afilter) + af_control_any_rev(mixer->afilter, + AF_CONTROL_PAN_BALANCE | AF_CONTROL_GET, + &mixer->balance); + *val = mixer->balance; } +/* NOTE: Currently the balance code is seriously buggy: it always changes + * the af_pan mapping between the first two input channels and first two + * output channels to particular values. These values make sense for an + * af_pan instance that was automatically inserted for balance control + * only and is otherwise an identity transform, but if the filter was + * there for another reason, then ignoring and overriding the original + * values is completely wrong. In particular, this will break + * automatically inserted downmix filters; the original coefficients that + * are significantly below 1 will be overwritten with much higher values. + */ + void mixer_setbalance(mixer_t *mixer, float val) { - float level[AF_NCH]; - int i; - af_control_ext_t arg_ext = { .arg = level }; - af_instance_t* af_pan_balance; - - if(!mixer->afilter) - return; - if (af_control_any_rev(mixer->afilter, - AF_CONTROL_PAN_BALANCE | AF_CONTROL_SET, &val)) - return; - - if (!(af_pan_balance = af_add(mixer->afilter, "pan"))) { - mp_tmsg(MSGT_GLOBAL, MSGL_ERR, "[Mixer] No balance control available.\n"); - return; - } - - af_init(mixer->afilter); - /* make all other channels pass thru since by default pan blocks all */ - memset(level, 0, sizeof(level)); - for (i = 2; i < AF_NCH; i++) { - arg_ext.ch = i; - level[i] = 1.f; + float level[AF_NCH]; + int i; + af_control_ext_t arg_ext = { .arg = level }; + af_instance_t *af_pan_balance; + + mixer->balance = val; + + if (!mixer->afilter) + return; + + if (af_control_any_rev(mixer->afilter, + AF_CONTROL_PAN_BALANCE | AF_CONTROL_SET, &val)) + return; + + if (val == 0 || mixer->ao->channels < 2) + return; + + if (!(af_pan_balance = af_add(mixer->afilter, "pan"))) { + mp_tmsg(MSGT_GLOBAL, MSGL_ERR, + "[Mixer] No balance control available.\n"); + return; + } + + af_init(mixer->afilter); + /* make all other channels pass thru since by default pan blocks all */ + memset(level, 0, sizeof(level)); + for (i = 2; i < AF_NCH; i++) { + arg_ext.ch = i; + level[i] = 1.f; + af_pan_balance->control(af_pan_balance, + AF_CONTROL_PAN_LEVEL | AF_CONTROL_SET, + &arg_ext); + level[i] = 0.f; + } + af_pan_balance->control(af_pan_balance, - AF_CONTROL_PAN_LEVEL | AF_CONTROL_SET, &arg_ext); - level[i] = 0.f; - } + AF_CONTROL_PAN_BALANCE | AF_CONTROL_SET, &val); +} - af_pan_balance->control(af_pan_balance, - AF_CONTROL_PAN_BALANCE | AF_CONTROL_SET, &val); +// Called after the audio filter chain is built or rebuilt. +void mixer_reinit(struct mixer *mixer, struct ao *ao) +{ + mixer->ao = ao; + /* Use checkvolume() to see if softvol needs to be enabled because of + * lacking AO support, but first store values it could overwrite. */ + float left = mixer->vol_l, right = mixer->vol_r; + bool muted = mixer->muted_by_us; + checkvolume(mixer); + /* Try to avoid restoring volume stored from one control method with + * another. Especially, restoring softvol volume (typically high) on + * system mixer could have very nasty effects. */ + const char *restore_reason = mixer->softvol ? "softvol" : + mixer->ao->driver->info->short_name; + if (mixer->restore_volume && !strcmp(mixer->restore_volume, + restore_reason)) + mixer_setvolume(mixer, left, right); + /* We turn mute off at AO uninit, so it has to be restored (unless + * we're reinitializing filter chain while keeping AO); but we only + * enable mute, not turn external mute off. */ + if (muted) + mixer_setmute(mixer, true); + if (mixer->balance != 0) + mixer_setbalance(mixer, mixer->balance); +} + +/* Called before uninitializing the audio output. The main purpose is to + * turn off mute, in case it's a global/persistent setting which might + * otherwise be left enabled even after this player instance exits. + */ +void mixer_uninit(struct mixer *mixer) +{ + checkvolume(mixer); + if (mixer->muted_by_us) { + /* Current audio output API combines playing the remaining buffered + * audio and uninitializing the AO into one operation, even though + * ideally unmute would happen between those two steps. We can't do + * volume changes after uninitialization, but we don't want the + * remaining audio to play at full volume either. Thus this + * workaround to drop remaining audio first. */ + ao_reset(mixer->ao); + mixer_setmute(mixer, false); + /* We remember mute status and re-enable it if we play more audio + * in the same process. */ + mixer->muted_by_us = true; + } + mixer->ao = NULL; } diff -Nru mplayer2-2.0-426-gc32b3ed/mixer.h mplayer2-2.0-554-gf63dbad/mixer.h --- mplayer2-2.0-426-gc32b3ed/mixer.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/mixer.h 2012-05-17 14:38:00.000000000 +0000 @@ -19,32 +19,37 @@ #ifndef MPLAYER_MIXER_H #define MPLAYER_MIXER_H +#include + #include "libaf/af.h" #include "libao2/audio_out.h" -extern char * mixer_device; -extern char * mixer_channel; -extern int soft_vol; -extern float soft_vol_max; - -typedef struct mixer_s { +typedef struct mixer { struct ao *ao; af_stream_t *afilter; int volstep; - int muted; - float last_l, last_r; + bool softvol; + float softvol_max; + bool muted; + bool muted_by_us; + bool muted_using_volume; + float vol_l, vol_r; + /* Contains ao driver name or "softvol" if volume is not persistent + * and needs to be restored after the driver is reinitialized. */ + const char *restore_volume; + float balance; } mixer_t; +void mixer_reinit(struct mixer *mixer, struct ao *ao); +void mixer_uninit(struct mixer *mixer); void mixer_getvolume(mixer_t *mixer, float *l, float *r); void mixer_setvolume(mixer_t *mixer, float l, float r); void mixer_incvolume(mixer_t *mixer); void mixer_decvolume(mixer_t *mixer); void mixer_getbothvolume(mixer_t *mixer, float *b); -void mixer_mute(mixer_t *mixer); +void mixer_setmute(mixer_t *mixer, bool mute); +bool mixer_getmute(mixer_t *mixer); void mixer_getbalance(mixer_t *mixer, float *bal); void mixer_setbalance(mixer_t *mixer, float bal); -//void mixer_setbothvolume(int v); -#define mixer_setbothvolume(m, v) mixer_setvolume(m, v, v) - #endif /* MPLAYER_MIXER_H */ diff -Nru mplayer2-2.0-426-gc32b3ed/mp_core.h mplayer2-2.0-554-gf63dbad/mp_core.h --- mplayer2-2.0-426-gc32b3ed/mp_core.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/mp_core.h 2012-05-17 14:38:00.000000000 +0000 @@ -187,9 +187,6 @@ double last_chapter_pts; float begin_skip; ///< start time of the current skip while on edlout mode - // audio is muted if either EDL or user activates mute - short edl_muted; ///< Stores whether EDL is currently in muted mode. - short user_muted; ///< Stores whether user wanted muted mode. int global_sub_size; // this encompasses all subtitle sources int global_sub_pos; // this encompasses all subtitle sources @@ -212,6 +209,9 @@ // step this many frames, then pause int step_frames; + bool status_printed; + int paused_cache_fill; + // Set after showing warning about decoding being too slow for realtime // playback rate. Used to avoid showing it multiple times. bool drop_message_shown; @@ -253,8 +253,7 @@ char *chapter_name(struct MPContext *mpctx, int chapter); double chapter_start_time(struct MPContext *mpctx, int chapter); int get_chapter_count(struct MPContext *mpctx); -void update_subtitles(struct MPContext *mpctx, double refpts, - double sub_offset, bool reset); +void update_subtitles(struct MPContext *mpctx, double refpts, bool reset); // timeline/tl_matroska.c diff -Nru mplayer2-2.0-426-gc32b3ed/mp_fifo.c mplayer2-2.0-554-gf63dbad/mp_fifo.c --- mplayer2-2.0-426-gc32b3ed/mp_fifo.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/mp_fifo.c 2012-05-17 14:38:00.000000000 +0000 @@ -67,3 +67,13 @@ fifo->last_down_time = now; } } + +void mplayer_put_key_utf8(struct mp_fifo *fifo, int mods, struct bstr t) +{ + while (t.len) { + int code = bstr_decode_utf8(t, &t); + if (code < 0) + break; + mplayer_put_key(fifo, code | mods); + } +} diff -Nru mplayer2-2.0-426-gc32b3ed/mp_fifo.h mplayer2-2.0-554-gf63dbad/mp_fifo.h --- mplayer2-2.0-426-gc32b3ed/mp_fifo.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/mp_fifo.h 2012-05-17 14:38:00.000000000 +0000 @@ -19,8 +19,11 @@ #ifndef MPLAYER_MP_FIFO_H #define MPLAYER_MP_FIFO_H +#include "bstr.h" + struct mp_fifo; void mplayer_put_key(struct mp_fifo *fifo, int code); +void mplayer_put_key_utf8(struct mp_fifo *fifo, int mods, struct bstr code); // Can be freed with talloc_free() struct input_ctx; struct MPOpts; diff -Nru mplayer2-2.0-426-gc32b3ed/mp_msg.c mplayer2-2.0-554-gf63dbad/mp_msg.c --- mplayer2-2.0-426-gc32b3ed/mp_msg.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/mp_msg.c 2012-05-17 14:38:00.000000000 +0000 @@ -23,6 +23,7 @@ #include "config.h" #include "osdep/getch2.h" +#include "osdep/io.h" #ifdef CONFIG_TRANSLATION #include @@ -39,6 +40,27 @@ /* maximum message length of mp_msg */ #define MSGSIZE_MAX 3072 +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#include +#define hSTDOUT GetStdHandle(STD_OUTPUT_HANDLE) +#define hSTDERR GetStdHandle(STD_ERROR_HANDLE) +static short stdoutAttrs = 0; +static const unsigned char ansi2win32[10] = { + 0, + FOREGROUND_RED, + FOREGROUND_GREEN, + FOREGROUND_GREEN | FOREGROUND_RED, + FOREGROUND_BLUE, + FOREGROUND_BLUE | FOREGROUND_RED, + FOREGROUND_BLUE | FOREGROUND_GREEN, + FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED, + FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED, + FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED +}; +#endif + int mp_msg_levels[MSGT_MAX]; // verbose level of this module. initialized to -2 int mp_msg_level_all = MSGL_STATUS; int verbose = 0; @@ -82,6 +104,16 @@ } void mp_msg_init(void){ +#ifdef _WIN32 + CONSOLE_SCREEN_BUFFER_INFO cinfo; + long cmode = 0; + GetConsoleMode(hSTDOUT, &cmode); + cmode |= (ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT); + SetConsoleMode(hSTDOUT, cmode); + SetConsoleMode(hSTDERR, cmode); + GetConsoleScreenBufferInfo(hSTDOUT, &cinfo); + stdoutAttrs = cinfo.wAttributes; +#endif int i; char *env = getenv("MPLAYER_VERBOSE"); if (env) @@ -91,7 +123,11 @@ #ifdef CONFIG_ICONV mp_msg_charset = getenv("MPLAYER_CHARSET"); if (!mp_msg_charset) - mp_msg_charset = get_term_charset(); +#ifdef _WIN32 + mp_msg_charset = "UTF-8"; +#else + mp_msg_charset = get_term_charset(); +#endif #endif #ifdef CONFIG_TRANSLATION textdomain("mplayer"); @@ -124,7 +160,14 @@ } #endif if (mp_msg_color) + { +#ifdef _WIN32 + HANDLE *wstream = stream == stderr ? hSTDERR : hSTDOUT; + SetConsoleTextAttribute(wstream, ansi2win32[c] | FOREGROUND_INTENSITY); +#else fprintf(stream, "\033[%d;3%dm", c >> 3, c & 7); +#endif + } } static void print_msg_module(FILE* stream, int mod) @@ -181,11 +224,20 @@ if (!mp_msg_module) return; +#ifdef _WIN32 + HANDLE *wstream = stream == stderr ? hSTDERR : hSTDOUT; + if (mp_msg_color) + SetConsoleTextAttribute(wstream, ansi2win32[c2&7] | FOREGROUND_INTENSITY); + fprintf(stream, "%9s", module_text[mod]); + if (mp_msg_color) + SetConsoleTextAttribute(wstream, stdoutAttrs); +#else if (mp_msg_color) fprintf(stream, "\033[%d;3%dm", c2 >> 3, c2 & 7); fprintf(stream, "%9s", module_text[mod]); if (mp_msg_color) fprintf(stream, "\033[0;37m"); +#endif fprintf(stream, ": "); } @@ -203,33 +255,43 @@ tmp[MSGSIZE_MAX-1] = 0; #if defined(CONFIG_ICONV) && defined(MSG_CHARSET) - if (mp_msg_charset && strcasecmp(mp_msg_charset, "noconv")) { - char tmp2[MSGSIZE_MAX]; - size_t inlen = strlen(tmp), outlen = MSGSIZE_MAX; - char *in = tmp, *out = tmp2; - if (!old_charset || strcmp(old_charset, mp_msg_charset)) { - if (old_charset) { - free(old_charset); - iconv_close(msgiconv); + if (mp_msg_charset && strcasecmp(mp_msg_charset, "noconv")) + { + char tmp2[MSGSIZE_MAX]; + size_t inlen = strlen(tmp), outlen = MSGSIZE_MAX; + char *in = tmp, *out = tmp2; + if (!old_charset || strcmp(old_charset, mp_msg_charset)) + { + if (old_charset) + { + free(old_charset); + iconv_close(msgiconv); + } + msgiconv = iconv_open(mp_msg_charset, MSG_CHARSET); + old_charset = strdup(mp_msg_charset); + } + + if (msgiconv == (iconv_t)(-1)) + { + fprintf(stderr,"iconv: conversion from %s to %s unsupported\n" + ,MSG_CHARSET,mp_msg_charset); + } + else + { + memset(tmp2, 0, MSGSIZE_MAX); + + while (iconv(msgiconv, &in, &inlen, &out, &outlen) == -1) + { + if (!inlen || !outlen) + break; + *out++ = *in++; + outlen--; inlen--; + } + + strncpy(tmp, tmp2, MSGSIZE_MAX); + tmp[MSGSIZE_MAX-1] = 0; + tmp[MSGSIZE_MAX-2] = '\n'; } - msgiconv = iconv_open(mp_msg_charset, MSG_CHARSET); - old_charset = strdup(mp_msg_charset); - } - if (msgiconv == (iconv_t)(-1)) { - fprintf(stderr,"iconv: conversion from %s to %s unsupported\n" - ,MSG_CHARSET,mp_msg_charset); - }else{ - memset(tmp2, 0, MSGSIZE_MAX); - while (iconv(msgiconv, &in, &inlen, &out, &outlen) == -1) { - if (!inlen || !outlen) - break; - *out++ = *in++; - outlen--; inlen--; - } - strncpy(tmp, tmp2, MSGSIZE_MAX); - tmp[MSGSIZE_MAX-1] = 0; - tmp[MSGSIZE_MAX-2] = '\n'; - } } #endif @@ -248,8 +310,16 @@ header = len && (tmp[len-1] == '\n' || tmp[len-1] == '\r'); fprintf(stream, "%s", tmp); + if (mp_msg_color) + { +#ifdef _WIN32 + HANDLE *wstream = lev <= MSGL_WARN ? hSTDERR : hSTDOUT; + SetConsoleTextAttribute(wstream, stdoutAttrs); +#else fprintf(stream, "\033[0m"); +#endif + } fflush(stream); } @@ -269,7 +339,7 @@ * couple of reasons (locale stuff is badly designed and sucks in * general). * - * First setting the locale, especially LC_CTYPE, changes the + * First, setting the locale, especially LC_CTYPE, changes the * behavior of various C functions and we don't want that - we * want isalpha() for example to always behave like in the C * locale. @@ -291,7 +361,7 @@ * affect gettext itself because it supports specifying the * character set directly with bind_textdomain_codeset()). * - * So the only solution (at leat short of trying to work around + * So the only solution (at least short of trying to work around * things possibly producing non-utf-8 output) is to leave all the * locale variables unset. Note that this means it's not possible * to get translated output from any libraries we call if they diff -Nru mplayer2-2.0-426-gc32b3ed/mp_msg.h mplayer2-2.0-554-gf63dbad/mp_msg.h --- mplayer2-2.0-426-gc32b3ed/mp_msg.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/mp_msg.h 2012-05-17 14:38:00.000000000 +0000 @@ -130,19 +130,15 @@ int mp_msg_test(int mod, int lev); #include "config.h" +#include "mpcommon.h" char *mp_gtext(const char *string); void mp_msg_va(int mod, int lev, const char *format, va_list va); -#ifdef __GNUC__ -void mp_msg(int mod, int lev, const char *format, ... ) __attribute__ ((format (printf, 3, 4))); -void mp_tmsg(int mod, int lev, const char *format, ... ) __attribute__ ((format (printf, 3, 4))); -static inline void mp_dbg(int mod, int lev, const char *format, ...) __attribute__ ((format (printf, 3, 4))); -#else // not GNU C -void mp_msg(int mod, int lev, const char *format, ... ); -void mp_tmsg(int mod, int lev, const char *format, ...) -#endif /* __GNUC__ */ +void mp_msg(int mod, int lev, const char *format, ... ) PRINTF_ATTRIBUTE(3, 4); +void mp_tmsg(int mod, int lev, const char *format, ... ) PRINTF_ATTRIBUTE(3, 4); +static inline void mp_dbg(int mod, int lev, const char *format, ...) PRINTF_ATTRIBUTE(3, 4); static inline void mp_dbg(int mod, int lev, const char *format, ...) { diff -Nru mplayer2-2.0-426-gc32b3ed/mpbswap.h mplayer2-2.0-554-gf63dbad/mpbswap.h --- mplayer2-2.0-426-gc32b3ed/mpbswap.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/mpbswap.h 2012-05-17 14:38:00.000000000 +0000 @@ -19,12 +19,14 @@ #ifndef MPLAYER_MPBSWAP_H #define MPLAYER_MPBSWAP_H -#include -#include "config.h" -#include "ffmpeg_files/bswap.h" +#include -#ifndef HAVE_SWAB -void swab(const void *from, void *to, ssize_t n); -#endif +#define bswap_16(x) av_bswap16(x) +#define bswap_32(x) av_bswap32(x) +#define be2me_16(x) av_be2ne16(x) +#define be2me_32(x) av_be2ne32(x) +#define le2me_16(x) av_le2ne16(x) +#define le2me_32(x) av_le2ne32(x) +#define le2me_64(x) av_le2ne64(x) #endif /* MPLAYER_MPBSWAP_H */ diff -Nru mplayer2-2.0-426-gc32b3ed/mpcommon.h mplayer2-2.0-554-gf63dbad/mpcommon.h --- mplayer2-2.0-426-gc32b3ed/mpcommon.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/mpcommon.h 2012-05-17 14:38:00.000000000 +0000 @@ -31,6 +31,26 @@ #define MP_RESIZE_ARRAY(ctx, p, count) do { \ p = talloc_realloc_size((ctx), p, (count) * sizeof(p[0])); } while (0) +#ifdef __GNUC__ + +/** Use gcc attribute to check printf fns. a1 is the 1-based index of + * the parameter containing the format, and a2 the index of the first + * argument. **/ +#ifdef __MINGW32__ +// MinGW maps "printf" to the non-standard MSVCRT functions, even if +// __USE_MINGW_ANSI_STDIO is defined and set to 1. We need to use "gnu_printf", +// which isn't necessarily available on other GCC compatible compilers. +#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (gnu_printf, a1, a2))) +#else +#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (printf, a1, a2))) +#endif + +#else + +#define PRINTF_ATTRIBUTE(a1, a2) + +#endif + extern const char *mplayer_version; #endif /* MPLAYER_MPCOMMON_H */ diff -Nru mplayer2-2.0-426-gc32b3ed/mplayer.c mplayer2-2.0-554-gf63dbad/mplayer.c --- mplayer2-2.0-426-gc32b3ed/mplayer.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/mplayer.c 2012-05-17 14:38:00.000000000 +0000 @@ -22,12 +22,25 @@ #include #include +#include + #include "config.h" #include "talloc.h" +#include "osdep/io.h" + #if defined(__MINGW32__) || defined(__CYGWIN__) -#define _UWIN 1 /*disable Non-underscored versions of non-ANSI functions as otherwise int eof would conflict with eof()*/ #include +// No proper file descriptor event handling; keep waking up to poll input +#define WAKEUP_PERIOD 0.02 +#else +/* Even if we can immediately wake up in response to most input events, + * there are some timers which are not registered to the event loop + * and need to be checked periodically (like automatic mouse cursor hiding). + * OSD content updates behave similarly. Also some uncommon input devices + * may not have proper FD event support. + */ +#define WAKEUP_PERIOD 0.5 #endif #include #include @@ -62,11 +75,8 @@ #include "m_option.h" #include "m_config.h" #include "mplayer.h" -#include "access_mpcontext.h" #include "m_property.h" -#include "libavutil/avstring.h" - #include "sub/subreader.h" #include "sub/find_subfiles.h" #include "sub/dec_sub.h" @@ -77,7 +87,6 @@ #include "sub/font_load.h" #include "sub/sub.h" -#include "ffmpeg_files/intreadwrite.h" #include "sub/av_sub.h" #include "libmpcodecs/dec_teletext.h" #include "cpudetect.h" @@ -91,8 +100,6 @@ #include "codec-cfg.h" -#include "edl.h" - #include "sub/spudec.h" #include "sub/vobsub.h" @@ -142,12 +149,6 @@ // Config file //**************************************************************************// -static int cfg_inc_verbose(m_option_t *conf) -{ - ++verbose; - return 0; -} - #include "path.h" //**************************************************************************// @@ -337,9 +338,9 @@ // --- -edl_record_ptr edl_records = NULL; ///< EDL entries memory area -edl_record_ptr next_edl_record = NULL; ///< only for traversing edl_records FILE *edl_fd; // file to write to when in -edlout mode. +char *edl_output_filename; // file to put EDL entries in (-edlout) + int use_filedir_conf; int use_filename_title; @@ -348,36 +349,6 @@ #include "metadata.h" -void *mpctx_get_video_out(MPContext *mpctx) -{ - return mpctx->video_out; -} - -void *mpctx_get_demuxer(MPContext *mpctx) -{ - return mpctx->demuxer; -} - -void *mpctx_get_playtree_iter(MPContext *mpctx) -{ - return mpctx->playtree_iter; -} - -void *mpctx_get_mixer(MPContext *mpctx) -{ - return &mpctx->mixer; -} - -int mpctx_get_global_sub_size(MPContext *mpctx) -{ - return mpctx->global_sub_size; -} - -int mpctx_get_osd_function(MPContext *mpctx) -{ - return mpctx->osd_function; -} - static float get_relative_time(struct MPContext *mpctx) { unsigned int new_time = GetTimer(); @@ -714,10 +685,10 @@ if (mask & INITIALIZED_AO) { mpctx->initialized_flags &= ~INITIALIZED_AO; current_module = "uninit_ao"; - if (mpctx->edl_muted) - mixer_mute(&mpctx->mixer); - if (mpctx->ao) + if (mpctx->ao) { + mixer_uninit(&mpctx->mixer); ao_uninit(mpctx->ao, mpctx->stop_play != AT_END_OF_FILE); + } mpctx->ao = NULL; } @@ -726,8 +697,6 @@ void exit_player_with_rc(struct MPContext *mpctx, enum exit_reason how, int rc) { - if (mpctx->user_muted && !mpctx->edl_muted) - mixer_mute(&mpctx->mixer); uninit_player(mpctx, INITIALIZED_ALL); #if defined(__MINGW32__) || defined(__CYGWIN__) timeEndPeriod(1); @@ -765,8 +734,6 @@ talloc_free(mpctx->key_fifo); - free(edl_records); // free mem allocated for EDL - edl_records = NULL; switch (how) { case EXIT_QUIT: mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "\nExiting... (%s)\n", "Quit"); @@ -890,9 +857,9 @@ #include "cfg-mplayer.h" -static int cfg_include(m_option_t *conf, char *filename) +static int cfg_include(struct m_config *conf, char *filename) { - return m_config_parse_config_file(conf->priv, filename); + return m_config_parse_config_file(conf, filename); } #define DEF_CONFIG "# Write your default config options here!\n\n\n" @@ -908,11 +875,7 @@ if ((conffile = get_path("")) == NULL) mp_tmsg(MSGT_CPLAYER, MSGL_WARN, "Cannot find HOME directory.\n"); else { -#ifdef __MINGW32__ - mkdir(conffile); -#else mkdir(conffile, 0777); -#endif free(conffile); if ((conffile = get_path("config")) == NULL) mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "get_path(\"config\") problem\n"); @@ -1001,8 +964,7 @@ */ static int try_load_config(m_config_t *conf, const char *file) { - struct stat st; - if (stat(file, &st)) + if (!mp_path_exists(file)) return 0; mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Loading config '%s'\n", file); m_config_parse_config_file(conf, file); @@ -1012,10 +974,10 @@ static void load_per_file_config(m_config_t *conf, const char * const file) { char *confpath; - char cfg[PATH_MAX]; + char cfg[MP_PATH_MAX]; const char *name; - if (strlen(file) > PATH_MAX - 14) { + if (strlen(file) > MP_PATH_MAX - 14) { mp_msg(MSGT_CPLAYER, MSGL_WARN, "Filename is too long, " "can not load file or directory specific config files\n"); return; @@ -1024,7 +986,7 @@ name = mp_basename(cfg); if (use_filedir_conf) { - char dircfg[PATH_MAX]; + char dircfg[MP_PATH_MAX]; strcpy(dircfg, cfg); strcpy(dircfg + (name - cfg), "mplayer.conf"); try_load_config(conf, dircfg); @@ -1270,6 +1232,8 @@ if (mpctx->time_frame > 0) mpctx->last_av_difference += mpctx->time_frame * opts->playback_speed; + if (a_pos == MP_NOPTS_VALUE || mpctx->video_pts == MP_NOPTS_VALUE) + mpctx->last_av_difference = MP_NOPTS_VALUE; if (mpctx->last_av_difference > 0.5 && drop_frame_cnt > 50 && !mpctx->drop_message_shown) { mp_tmsg(MSGT_AVSYNC, MSGL_WARN, SystemTooSlow); @@ -1279,9 +1243,6 @@ if (opts->quiet) return; - if (a_pos == MP_NOPTS_VALUE) - a_pos = -9; // don't print a huge negative number - int width; char *line; unsigned pos = 0; @@ -1290,7 +1251,7 @@ width = screen_width; else width = 80; -#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__OS2__) +#if defined(__MINGW32__) || defined(__CYGWIN__) /* Windows command line is broken (MinGW's rxvt works, but we * should not depend on that). */ width--; @@ -1299,8 +1260,11 @@ // Audio time if (mpctx->sh_audio) { - saddf(line, &pos, width, "A:%6.1f ", a_pos); - if (!sh_video) { + if (a_pos != MP_NOPTS_VALUE) + saddf(line, &pos, width, "A:%6.1f ", a_pos); + else + saddf(line, &pos, width, "A: ??? "); + if (!sh_video && a_pos != MP_NOPTS_VALUE) { float len = get_time_length(mpctx); saddf(line, &pos, width, "("); sadd_hhmmssf(line, &pos, width, a_pos); @@ -1311,13 +1275,22 @@ } // Video time - if (sh_video) - saddf(line, &pos, width, "V:%6.1f ", mpctx->video_pts); + if (sh_video) { + if (mpctx->video_pts != MP_NOPTS_VALUE) + saddf(line, &pos, width, "V:%6.1f ", mpctx->video_pts); + else + saddf(line, &pos, width, "V: ??? ", mpctx->video_pts); + } // A-V sync - if (mpctx->sh_audio && sh_video) - saddf(line, &pos, width, "A-V:%7.3f ct:%7.3f ", - mpctx->last_av_difference, mpctx->total_avsync_change); + if (mpctx->sh_audio && sh_video) { + if (mpctx->last_av_difference != MP_NOPTS_VALUE) + saddf(line, &pos, width, "A-V:%7.3f ct:%7.3f ", + mpctx->last_av_difference, mpctx->total_avsync_change); + else + saddf(line, &pos, width, "A-V: ??? ct:%7.3f ", + mpctx->total_avsync_change); + } // Video stats if (sh_video) @@ -1367,6 +1340,8 @@ mp_msg(MSGT_STATUSLINE, MSGL_STATUS, "%s\r", line); } free(line); + + mpctx->status_printed = true; } struct stream_dump_progress { @@ -1780,7 +1755,7 @@ // Clear the term osd line if (opts->term_osd && osd->osd_text[0]) { osd->osd_text[0] = 0; - printf("%s\n", opts->term_osd_esc); + mp_msg(MSGT_CPLAYER, MSGL_STATUS, "%s\n", opts->term_osd_esc); } } @@ -1789,8 +1764,10 @@ { struct MPOpts *opts = &mpctx->opts; struct ao *ao; - if (!mpctx->sh_audio) + if (!mpctx->sh_audio) { + uninit_player(mpctx, INITIALIZED_AO); return; + } if (!(mpctx->initialized_flags & INITIALIZED_ACODEC)) { current_module = "init_audio_codec"; mp_msg(MSGT_CPLAYER, MSGL_INFO, "==========================================================================\n"); @@ -1804,7 +1781,7 @@ current_module = "af_preinit"; if (!(mpctx->initialized_flags & INITIALIZED_AO)) { mpctx->initialized_flags |= INITIALIZED_AO; - mpctx->ao = ao_create(); + mpctx->ao = ao_create(opts, mpctx->input); mpctx->ao->samplerate = force_srate; mpctx->ao->format = opts->audio_output_format; } @@ -1850,8 +1827,10 @@ "Couldn't find matching filter/ao format!\n"); goto init_error; } - mpctx->mixer.ao = ao; mpctx->mixer.volstep = volstep; + mpctx->mixer.softvol = opts->softvol; + mpctx->mixer.softvol_max = opts->softvol_max; + mixer_reinit(&mpctx->mixer, ao); mpctx->syncing_audio = true; return; @@ -1931,13 +1910,14 @@ return type == 'b' || type == 'p' || type == 'x'; } -void update_subtitles(struct MPContext *mpctx, double refpts, - double sub_offset, bool reset) +void update_subtitles(struct MPContext *mpctx, double refpts_tl, bool reset) { + mpctx->osd->sub_offset = mpctx->video_offset; struct MPOpts *opts = &mpctx->opts; struct sh_video *sh_video = mpctx->sh_video; struct demux_stream *d_sub = mpctx->d_sub; - double curpts = refpts + sub_delay; + double refpts_s = refpts_tl - mpctx->osd->sub_offset; + double curpts_s = refpts_s + sub_delay; unsigned char *packet = NULL; int len; struct sh_sub *sh_sub = d_sub->sh; @@ -1962,7 +1942,7 @@ if (sub_fps == 0) sub_fps = sh_video ? sh_video->fps : 25; current_module = "find_sub"; - find_sub(mpctx, mpctx->subdata, curpts * + find_sub(mpctx, mpctx->subdata, curpts_s * (mpctx->subdata->sub_uses_time ? 100. : sub_fps)); if (vo_sub) mpctx->vo_sub_last = vo_sub; @@ -1977,13 +1957,13 @@ // Vobsub len = 0; if (vo_vobsub) { - if (curpts >= 0) { - len = vobsub_get_packet(vo_vobsub, curpts, + if (curpts_s >= 0) { + len = vobsub_get_packet(vo_vobsub, curpts_s, (void **)&packet, ×tamp); if (len > 0) mp_dbg(MSGT_CPLAYER, MSGL_V, "\rVOB sub: len=%d " "v_pts=%5.3f v_timer=%5.3f sub=%5.3f ts=%d \n", - len, refpts, sh_video->timer, + len, refpts_s, sh_video->timer, timestamp / 90000.0, timestamp); } } else { @@ -1995,14 +1975,14 @@ // d_video->pts which would have been the simplest // improvement doesn't work because mpeg specific hacks // in video.c set d_video->pts to 0. - float x = d_sub->pts - refpts; + float x = d_sub->pts - refpts_s; if (x > -20 && x < 20) // prevent missing subs on pts reset timestamp = 90000 * d_sub->pts; else - timestamp = 90000 * curpts; + timestamp = 90000 * curpts_s; mp_dbg(MSGT_CPLAYER, MSGL_V, "\rDVD sub: len=%d " "v_pts=%5.3f s_pts=%5.3f ts=%d \n", len, - refpts, d_sub->pts, timestamp); + refpts_s, d_sub->pts, timestamp); } } if (len <= 0 || !packet) @@ -2028,19 +2008,19 @@ ds_get_next_pts(d_sub); while (d_sub->first) { - double subpts = ds_get_next_pts(d_sub) + sub_offset; - if (subpts > curpts) { + double subpts_s = ds_get_next_pts(d_sub); + if (subpts_s > curpts_s) { // Libass handled subs can be fed to it in advance if (!opts->ass_enabled || !is_text_sub(type)) break; // Try to avoid demuxing whole file at once - if (d_sub->non_interleaved && subpts > curpts + 1) + if (d_sub->non_interleaved && subpts_s > curpts_s + 1) break; } double duration = d_sub->first->duration; len = ds_get_packet_sub(d_sub, &packet); if (is_av_sub(type)) { - int ret = decode_avsub(sh_sub, packet, len, subpts, duration); + int ret = decode_avsub(sh_sub, packet, len, subpts_s, duration); if (ret < 0) mp_msg(MSGT_SPUDEC, MSGL_WARN, "lavc failed decoding " "subtitle\n"); @@ -2069,10 +2049,10 @@ continue; } if (sh_sub && sh_sub->active) { - sub_decode(sh_sub, mpctx->osd, packet, len, subpts, duration); + sub_decode(sh_sub, mpctx->osd, packet, len, subpts_s, duration); continue; } - if (subpts != MP_NOPTS_VALUE) { + if (subpts_s != MP_NOPTS_VALUE) { if (duration < 0) sub_clear_text(&subs, MP_NOPTS_VALUE); if (type == 'a') { // ssa/ass subs without libass => convert to plaintext @@ -2086,21 +2066,21 @@ len -= p - packet; packet = p; } - double endpts = MP_NOPTS_VALUE; - if (subpts != MP_NOPTS_VALUE && duration >= 0) - endpts = subpts + duration; - sub_add_text(&subs, packet, len, endpts); + double endpts_s = MP_NOPTS_VALUE; + if (subpts_s != MP_NOPTS_VALUE && duration >= 0) + endpts_s = subpts_s + duration; + sub_add_text(&subs, packet, len, endpts_s); set_osd_subtitle(mpctx, &subs); } if (d_sub->non_interleaved) ds_get_next_pts(d_sub); } if (!opts->ass_enabled) - if (sub_clear_text(&subs, curpts)) + if (sub_clear_text(&subs, curpts_s)) set_osd_subtitle(mpctx, &subs); } if (vo_spudec) { - spudec_heartbeat(vo_spudec, 90000 * curpts); + spudec_heartbeat(vo_spudec, 90000 * curpts_s); if (spudec_changed(vo_spudec)) vo_osd_changed(OSDTYPE_SPU); } @@ -2533,7 +2513,7 @@ return decode_audio(sh_audio, &ao->buffer, playsize); } -static int fill_audio_out_buffers(struct MPContext *mpctx) +static int fill_audio_out_buffers(struct MPContext *mpctx, double endpts) { struct MPOpts *opts = &mpctx->opts; struct ao *ao = mpctx->ao; @@ -2549,9 +2529,6 @@ current_module = "play_audio"; - if (ao->untimed && mpctx->sh_video && mpctx->delay > 0) - return 0; - // hack used by some mpeg-writing AOs ao->brokenpts = ((mpctx->sh_video ? mpctx->sh_video->timer : 0) + mpctx->delay) * 90000.0; @@ -2595,8 +2572,7 @@ t = GetTimer() - t; tt = t * 0.000001f; audio_time_usage += tt; - if (mpctx->timeline && modifiable_audio_format) { - double endpts = mpctx->timeline[mpctx->timeline_part + 1].start; + if (endpts != MP_NOPTS_VALUE && modifiable_audio_format) { double bytes = (endpts - written_audio_pts(mpctx) + audio_delay) * ao->bps / opts->playback_speed; if (playsize > bytes) { @@ -2638,71 +2614,14 @@ return -partial_fill; } -static int sleep_until_near_frame(struct MPContext *mpctx, float *time_frame, - bool sync_to_audio, float *aq_sleep_time) -{ - struct MPOpts *opts = &mpctx->opts; - double audio_limit = 2; - current_module = "calc_sleep_time"; - - if (mpctx->restart_playback) - return 0; - - *time_frame -= get_relative_time(mpctx); // reset timer - - if (sync_to_audio) { - float delay = ao_get_delay(mpctx->ao); - mp_dbg(MSGT_AVSYNC, MSGL_DBG2, "delay=%f\n", delay); - - if (opts->autosync) { - /* - * Adjust this raw delay value by calculating the expected - * delay for this frame and generating a new value which is - * weighted between the two. The higher autosync is, the - * closer to the delay value gets to that which "-nosound" - * would have used, and the longer it will take for A/V - * sync to settle at the right value (but it eventually will.) - * This settling time is very short for values below 100. - */ - float predicted = mpctx->delay / opts->playback_speed + *time_frame; - float difference = delay - predicted; - delay = predicted + difference / (float)opts->autosync; - } - - *time_frame = delay - mpctx->delay / opts->playback_speed; - - // delay = amount of audio buffered in soundcard/driver - delay = FFMIN(delay, 0.5); - delay = FFMAX(delay, 0.1); - audio_limit = delay; - } else { - // If we're lagging more than 200 ms behind the right playback rate, - // don't try to "catch up". - // If benchmark is set always output frames as fast as possible - // without sleeping. - if (*time_frame < -0.2 || opts->benchmark) - *time_frame = 0; - } - - double t = *time_frame - mpctx->video_out->flip_queue_offset; - - if (t <= 0.05) - return 0; - - t -= 0.05; - if (t > audio_limit * 0.6) - t = audio_limit * 0.5; - *aq_sleep_time += t; - mp_input_get_cmd(mpctx->input, t * 1000 + 1, 1); - return 1; -} - int reinit_video_chain(struct MPContext *mpctx) { struct MPOpts *opts = &mpctx->opts; sh_video_t * const sh_video = mpctx->sh_video; - if (!sh_video) + if (!sh_video) { + uninit_player(mpctx, INITIALIZED_VO); return 0; + } double ar = -1.0; //================== Init VIDEO (codec & libvo) ========================== if (!opts->fixed_vo || !(mpctx->initialized_flags & INITIALIZED_VO)) { @@ -2794,6 +2713,8 @@ sh_video->last_pts = MP_NOPTS_VALUE; sh_video->num_buffered_pts = 0; sh_video->next_frame_time = 0; + mpctx->restart_playback = true; + mpctx->delay = 0; if (opts->auto_quality > 0) { // Auto quality option enabled @@ -2834,7 +2755,9 @@ frame_time = sh_video->next_frame_time; if (mpctx->restart_playback) frame_time = 0; - int in_size = video_read_frame(sh_video, &sh_video->next_frame_time, + int in_size = 0; + while (!in_size) + in_size = video_read_frame(sh_video, &sh_video->next_frame_time, &packet, force_fps); if (in_size < 0) { #ifdef CONFIG_DVDNAV @@ -2933,7 +2856,15 @@ int in_size = 0; unsigned char *buf = NULL; pts = MP_NOPTS_VALUE; - struct demux_packet *pkt = ds_get_packet2(mpctx->d_video); + struct demux_packet *pkt; + while (1) { + pkt = ds_get_packet2(mpctx->d_video, false); + if (!pkt || pkt->len) + break; + /* Packets with size 0 are assumed to not correspond to frames, + * but to indicate the absence of a frame in formats like AVI + * that must have packets at fixed timecode intervals. */ + } if (pkt) { in_size = pkt->len; buf = pkt->buffer; @@ -3001,6 +2932,48 @@ return frame_time; } +static int get_cache_fill(struct MPContext *mpctx) +{ +#ifdef CONFIG_STREAM_CACHE + if (stream_cache_size > 0) + return cache_fill_status(mpctx->stream); +#endif + return -1; +} + +static void update_pause_message(struct MPContext *mpctx) +{ + struct MPOpts *opts = &mpctx->opts; + + if (opts->quiet) + return; + + int cache_fill = get_cache_fill(mpctx); + bool cache_changed = cache_fill != mpctx->paused_cache_fill; + + if (!mpctx->status_printed && !cache_changed) + return; + + char *msg = mp_gtext(" ===== PAUSE ====="); + char *tmpmem = NULL; + if (cache_fill >= 0) + msg = tmpmem = talloc_asprintf(NULL, "%s %d%%", msg, cache_fill); + + if (opts->term_osd && !mpctx->sh_video) { + set_osd_msg(OSD_MSG_PAUSE, 1, 0, "%s", msg); + update_osd_msg(mpctx); + } else { + if (mpctx->status_printed) + mp_msg(MSGT_CPLAYER, MSGL_STATUS, "\n"); + mp_msg(MSGT_CPLAYER, MSGL_STATUS, "%s\r", msg); + } + + mpctx->paused_cache_fill = cache_fill; + mpctx->status_printed = false; + + talloc_free(tmpmem); +} + void pause_player(struct MPContext *mpctx) { if (mpctx->paused) @@ -3008,12 +2981,20 @@ mpctx->paused = 1; mpctx->step_frames = 0; mpctx->time_frame -= get_relative_time(mpctx); + mpctx->osd_function = OSD_PAUSE; if (mpctx->video_out && mpctx->sh_video && mpctx->video_out->config_ok) vo_control(mpctx->video_out, VOCTRL_PAUSE, NULL); if (mpctx->ao && mpctx->sh_audio) ao_pause(mpctx->ao); // pause audio, keep data if possible + + mpctx->paused_cache_fill = get_cache_fill(mpctx); + mpctx->status_printed = true; + update_pause_message(mpctx); + + if (!mpctx->opts.quiet) + mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_PAUSED\n"); } void unpause_player(struct MPContext *mpctx) @@ -3021,6 +3002,8 @@ if (!mpctx->paused) return; mpctx->paused = 0; + if (!mpctx->step_frames) + mpctx->osd_function = OSD_PLAY; if (mpctx->ao && mpctx->sh_audio) ao_resume(mpctx->ao); @@ -3038,7 +3021,7 @@ return -1; if (vo_redraw_frame(mpctx->video_out) < 0) return -1; - mpctx->osd->pts = mpctx->video_pts; + mpctx->osd->pts = mpctx->video_pts - mpctx->osd->sub_offset; if (!(sh_video->output_flags & VFCAP_EOSD_FILTER)) vf->control(vf, VFCTRL_DRAW_EOSD, mpctx->osd); vf->control(vf, VFCTRL_DRAW_OSD, mpctx->osd); @@ -3054,120 +3037,7 @@ unpause_player(mpctx); } -static void pause_loop(struct MPContext *mpctx) -{ - struct MPOpts *opts = &mpctx->opts; - mp_cmd_t *cmd; -#ifdef CONFIG_STREAM_CACHE - int old_cache_fill = stream_cache_size > 0 ? - cache_fill_status(mpctx->stream) : 0; -#endif - if (!opts->quiet) { - if (opts->term_osd && !mpctx->sh_video) { - set_osd_tmsg(OSD_MSG_PAUSE, 1, 0, " ===== PAUSE ====="); - update_osd_msg(mpctx); - } else - mp_msg(MSGT_CPLAYER, MSGL_STATUS, "\n%s\r", - mp_gtext(" ===== PAUSE =====")); - mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_PAUSED\n"); - } - - while ((cmd = mp_input_get_cmd(mpctx->input, 20, 1)) == NULL - || cmd->id == MP_CMD_SET_MOUSE_POS || cmd->pausing == 4) { - if (cmd) { - cmd = mp_input_get_cmd(mpctx->input, 0, 0); - run_command(mpctx, cmd); - mp_cmd_free(cmd); - continue; - } - if (mpctx->sh_video && mpctx->video_out) - vo_check_events(mpctx->video_out); - update_osd_msg(mpctx); - int hack = vo_osd_changed(0); - vo_osd_changed(hack); - if (hack || mpctx->sh_video && mpctx->video_out->want_redraw) - break; -#ifdef CONFIG_STREAM_CACHE - if (!opts->quiet && stream_cache_size > 0) { - int new_cache_fill = cache_fill_status(mpctx->stream); - if (new_cache_fill != old_cache_fill) { - if (opts->term_osd && !mpctx->sh_video) { - set_osd_tmsg(OSD_MSG_PAUSE, 1, 0, "%s %d%%", - mp_gtext(" ===== PAUSE ====="), - new_cache_fill); - update_osd_msg(mpctx); - } else - mp_msg(MSGT_CPLAYER, MSGL_STATUS, "%s %d%%\r", - mp_gtext(" ===== PAUSE ====="), - new_cache_fill); - old_cache_fill = new_cache_fill; - } - } -#endif - } -} - - -// Find the right mute status and record position for new file position -static void edl_seek_reset(MPContext *mpctx) -{ - mpctx->edl_muted = 0; - next_edl_record = edl_records; - - while (next_edl_record) { - if (next_edl_record->start_sec >= get_current_time(mpctx)) - break; - - if (next_edl_record->action == EDL_MUTE) - mpctx->edl_muted = !mpctx->edl_muted; - next_edl_record = next_edl_record->next; - } - if ((mpctx->user_muted | mpctx->edl_muted) != mpctx->mixer.muted) - mixer_mute(&mpctx->mixer); -} - - -// Execute EDL command for the current position if one exists -static void edl_update(MPContext *mpctx) -{ - if (!next_edl_record) - return; - - if (!mpctx->sh_video) { - mp_tmsg(MSGT_CPLAYER, MSGL_ERR, - "Cannot use EDL without video, disabling.\n"); - free_edl(edl_records); - next_edl_record = NULL; - edl_records = NULL; - return; - } - - if (get_current_time(mpctx) >= next_edl_record->start_sec) { - if (next_edl_record->action == EDL_SKIP) { - mpctx->osd_function = OSD_FFW; - queue_seek(mpctx, MPSEEK_RELATIVE, next_edl_record->length_sec, 0); - mp_msg(MSGT_CPLAYER, MSGL_DBG4, "EDL_SKIP: start [%f], stop " - "[%f], length [%f]\n", next_edl_record->start_sec, - next_edl_record->stop_sec, next_edl_record->length_sec); - } else if (next_edl_record->action == EDL_MUTE) { - mpctx->edl_muted = !mpctx->edl_muted; - if ((mpctx->user_muted | mpctx->edl_muted) != mpctx->mixer.muted) - mixer_mute(&mpctx->mixer); - mp_msg(MSGT_CPLAYER, MSGL_DBG4, "EDL_MUTE: [%f]\n", - next_edl_record->start_sec); - } - next_edl_record = next_edl_record->next; - } -} - -static void reinit_decoders(struct MPContext *mpctx) -{ - reinit_video_chain(mpctx); - reinit_audio_chain(mpctx); - mp_property_do("sub", M_PROPERTY_SET, &(int){mpctx->global_sub_pos}, mpctx); -} - -static void seek_reset(struct MPContext *mpctx, bool reset_ao) +static void seek_reset(struct MPContext *mpctx, bool reset_ao, bool reset_ac) { if (mpctx->sh_video) { current_module = "seek_video_reset"; @@ -3179,18 +3049,16 @@ mpctx->sh_video->last_pts = MP_NOPTS_VALUE; mpctx->delay = 0; mpctx->time_frame = 0; - mpctx->restart_playback = true; // Not all demuxers set d_video->pts during seek, so this value - // (which is used by at least vobsub and edl code below) may - // be completely wrong (probably 0). + // (which is used by at least vobsub code below) may be completely + // wrong (probably 0). mpctx->sh_video->pts = mpctx->d_video->pts + mpctx->video_offset; mpctx->video_pts = mpctx->sh_video->pts; - update_subtitles(mpctx, mpctx->sh_video->pts, mpctx->video_offset, - true); + update_subtitles(mpctx, mpctx->sh_video->pts, true); update_teletext(mpctx->sh_video, mpctx->demuxer, 1); } - if (mpctx->sh_audio) { + if (mpctx->sh_audio && reset_ac) { current_module = "seek_audio_reset"; resync_audio_stream(mpctx->sh_audio); if (reset_ao) @@ -3198,8 +3066,7 @@ mpctx->ao->buffer.len = mpctx->ao->buffer_playable_size; mpctx->sh_audio->a_buffer_len = 0; if (!mpctx->sh_video) - update_subtitles(mpctx, mpctx->sh_audio->pts, - mpctx->video_offset, true); + update_subtitles(mpctx, mpctx->sh_audio->pts, true); } if (vo_vobsub && mpctx->sh_video) { @@ -3207,8 +3074,7 @@ vobsub_seek(vo_vobsub, mpctx->sh_video->pts); } - edl_seek_reset(mpctx); - + mpctx->restart_playback = true; mpctx->hrseek_active = false; mpctx->hrseek_framedrop = false; mpctx->total_avsync_change = 0; @@ -3300,13 +3166,19 @@ if (demuxer_amount == -1) { mpctx->stop_play = AT_END_OF_FILE; // Clear audio from current position - if (mpctx->sh_audio) { + if (mpctx->sh_audio && !timeline_fallthrough) { ao_reset(mpctx->ao); mpctx->sh_audio->a_buffer_len = 0; } return -1; } } + if (need_reset) { + reinit_video_chain(mpctx); + mp_property_do("sub", M_PROPERTY_SET, &(int){mpctx->global_sub_pos}, + mpctx); + } + int demuxer_style = 0; switch (seek.type) { case MPSEEK_FACTOR: @@ -3323,12 +3195,19 @@ demuxer_amount -= opts->hr_seek_demuxer_offset; int seekresult = demux_seek(mpctx->demuxer, demuxer_amount, audio_delay, demuxer_style); - if (need_reset) - reinit_decoders(mpctx); - if (seekresult == 0) + if (seekresult == 0) { + if (need_reset) { + reinit_audio_chain(mpctx); + seek_reset(mpctx, !timeline_fallthrough, false); + } return -1; + } - seek_reset(mpctx, !timeline_fallthrough); + if (need_reset) + reinit_audio_chain(mpctx); + /* If we just reinitialized audio it doesn't need to be reset, + * and resetting could lose audio some decoders produce during init. */ + seek_reset(mpctx, !timeline_fallthrough, !need_reset); /* Use the target time as "current position" for further relative * seeks etc until a new video frame has been decoded */ @@ -3419,9 +3298,11 @@ struct demuxer *demuxer = mpctx->demuxer; if (demuxer->stream_pts != MP_NOPTS_VALUE) return demuxer->stream_pts; - struct sh_video *sh_video = demuxer->video->sh; - if (sh_video) - return mpctx->video_pts; + if (mpctx->sh_video) { + double pts = mpctx->video_pts; + if (pts != MP_NOPTS_VALUE) + return pts; + } double apts = playing_audio_pts(mpctx); if (apts != MP_NOPTS_VALUE) return apts; @@ -3514,7 +3395,7 @@ int res = demuxer_seek_chapter(mpctx->demuxer, chapter, seek_pts); if (res >= 0) { if (*seek_pts == -1) - seek_reset(mpctx, true); + seek_reset(mpctx, true, true); else { mpctx->last_chapter_seek = res; mpctx->last_chapter_pts = *seek_pts; @@ -3537,8 +3418,20 @@ static void run_playloop(struct MPContext *mpctx) { struct MPOpts *opts = &mpctx->opts; - float aq_sleep_time = 0; bool full_audio_buffers = false; + bool audio_left = false, video_left = false; + double endpts = end_at.type == END_AT_TIME ? end_at.pos : MP_NOPTS_VALUE; + bool end_is_chapter = false; + double sleeptime = WAKEUP_PERIOD; + bool was_restart = mpctx->restart_playback; + + if (mpctx->timeline) { + double end = mpctx->timeline[mpctx->timeline_part + 1].start; + if (endpts == MP_NOPTS_VALUE || end < endpts) { + endpts = end; + end_is_chapter = true; + } + } if (opts->chapterrange[1] > 0) { int cur_chapter = get_current_chapter(mpctx); @@ -3552,79 +3445,27 @@ reinit_audio_chain(mpctx); } - /*========================== PLAY AUDIO ============================*/ - - if (!mpctx->sh_video) - mpctx->restart_playback = false; - - if (mpctx->sh_audio && !mpctx->restart_playback) { - int status = fill_audio_out_buffers(mpctx); - full_audio_buffers = status >= 0 && !mpctx->ao->untimed; - if (status == -2) - // at eof, all audio at least written to ao - if (!mpctx->sh_video) - mpctx->stop_play = AT_END_OF_FILE; + if (mpctx->step_frames && !mpctx->sh_video) { + mpctx->step_frames = 0; + pause_player(mpctx); } + if (mpctx->sh_audio && !mpctx->restart_playback && !mpctx->ao->untimed) { + int status = fill_audio_out_buffers(mpctx, endpts); + full_audio_buffers = status >= 0; + // Not at audio stream EOF yet + audio_left = status > -2; + } - if (!mpctx->sh_video) { - if (mpctx->step_frames) { - mpctx->step_frames = 0; - pause_player(mpctx); - } - // handle audio-only case: - double a_pos = 0, a_buf = 0; - // sh_audio can be NULL due to video stream switching - // TODO: handle this better - if (mpctx->sh_audio) { - a_buf = ao_get_delay(mpctx->ao); - a_pos = written_audio_pts(mpctx) - mpctx->opts.playback_speed * - a_buf; - } - - print_status(mpctx, a_pos, false); - - update_subtitles(mpctx, a_pos, mpctx->video_offset, false); - update_osd_msg(mpctx); - if (end_at.type == END_AT_TIME && end_at.pos < a_pos) - mpctx->stop_play = AT_END_OF_FILE; - else if (mpctx->timeline && mpctx->stop_play == AT_END_OF_FILE - && mpctx->timeline_part + 1 < mpctx->num_timeline_parts - && mpctx->sh_audio) { - struct timeline_part *p = mpctx->timeline + mpctx->timeline_part; - if (!opts->gapless_audio && p->source != (p + 1)->source - && a_buf > 0.05) { - mpctx->stop_play = KEEP_PLAYING; - mp_input_get_cmd(mpctx->input, (a_buf - .05) * 1000, true); - } else { - seek(mpctx, (struct seek_params){ .type = MPSEEK_ABSOLUTE, - .amount = (p + 1)->start }, - true); - } - } else if (!mpctx->stop_play) { - int sleep_time = 100; - if (mpctx->sh_audio) { - if (mpctx->ao->untimed) - sleep_time = 0; - else if (full_audio_buffers) - sleep_time = FFMAX(20, a_buf * 1000 - 50); - else - sleep_time = 20; - sleep_time = FFMIN(sleep_time, 100); - } - mp_input_get_cmd(mpctx->input, sleep_time, true); - } - } else { - - /*========================== PLAY VIDEO ============================*/ - + double buffered_audio = -1; + while (mpctx->sh_video) { // never loops, for "break;" only + struct vo *vo = mpctx->video_out; vo_pts = mpctx->sh_video->timer * 90000.0; vo_fps = mpctx->sh_video->fps; - bool blit_frame = mpctx->video_out->frame_loaded; - if (!blit_frame) { + video_left = vo->hasframe || vo->frame_loaded; + if (!vo->frame_loaded && (!mpctx->paused || mpctx->restart_playback)) { double frame_time = update_video(mpctx); - blit_frame = mpctx->video_out->frame_loaded; mp_dbg(MSGT_AVSYNC, MSGL_DBG2, "*** ftime=%5.3f ***\n", frame_time); if (mpctx->sh_video->vf_initialized < 0) { mp_tmsg(MSGT_CPLAYER, MSGL_FATAL, @@ -3633,30 +3474,20 @@ mpctx->stop_play = PT_NEXT_ENTRY; return; } - if (frame_time < 0) - mpctx->stop_play = AT_END_OF_FILE; - else if (!mpctx->restart_playback) { + video_left = frame_time >= 0; + if (video_left && !mpctx->restart_playback) { mpctx->time_frame += frame_time / opts->playback_speed; adjust_sync(mpctx, frame_time); } } - if (mpctx->timeline) { - struct timeline_part *next = - mpctx->timeline + mpctx->timeline_part + 1; - if (mpctx->sh_video->pts >= next->start - || mpctx->stop_play == AT_END_OF_FILE - && mpctx->timeline_part + 1 < mpctx->num_timeline_parts) { - seek(mpctx, (struct seek_params){ .type = MPSEEK_ABSOLUTE, - .amount = next->start }, - true); - return; - } - } + + if (endpts != MP_NOPTS_VALUE) + video_left &= mpctx->sh_video->pts < endpts; // ================================================================ current_module = "vo_check_events"; - vo_check_events(mpctx->video_out); + vo_check_events(vo); #ifdef CONFIG_X11 if (stop_xscreensaver) { @@ -3673,78 +3504,117 @@ } } - bool frame_time_remaining = sleep_until_near_frame(mpctx, - &mpctx->time_frame, - full_audio_buffers, - &aq_sleep_time); + if (!video_left || (mpctx->paused && !mpctx->restart_playback)) + break; + if (!vo->frame_loaded) { + sleeptime = 0; + break; + } + + mpctx->time_frame -= get_relative_time(mpctx); + if (full_audio_buffers && !mpctx->restart_playback) { + buffered_audio = ao_get_delay(mpctx->ao); + mp_dbg(MSGT_AVSYNC, MSGL_DBG2, "delay=%f\n", buffered_audio); + + if (opts->autosync) { + /* Smooth reported playback position from AO by averaging + * it with the value expected based on previus value and + * time elapsed since then. May help smooth video timing + * with audio output that have inaccurate position reporting. + * This is badly implemented; the behavior of the smoothing + * now undesirably depends on how often this code runs + * (mainly depends on video frame rate). */ + float predicted = (mpctx->delay / opts->playback_speed + + mpctx->time_frame); + float difference = buffered_audio - predicted; + buffered_audio = predicted + difference / opts->autosync; + } + + mpctx->time_frame = (buffered_audio - + mpctx->delay / opts->playback_speed); + } else { + /* If we're more than 200 ms behind the right playback + * position, don't try to speed up display of following + * frames to catch up; continue with default speed from + * the current frame instead. + * If benchmark is set always output frames immediately + * without sleeping. + */ + if (mpctx->time_frame < -0.2 || opts->benchmark) + mpctx->time_frame = 0; + } + + double vsleep = mpctx->time_frame - vo->flip_queue_offset; + if (vsleep > 0.050) { + sleeptime = FFMIN(sleeptime, vsleep - 0.040); + break; + } + sleeptime = 0; //=================== FLIP PAGE (VIDEO BLT): ====================== current_module = "flip_page"; - if (!frame_time_remaining && blit_frame) { - vo_new_frame_imminent(mpctx->video_out); - struct sh_video *sh_video = mpctx->sh_video; - mpctx->video_pts = sh_video->pts; - update_subtitles(mpctx, sh_video->pts, mpctx->video_offset, false); - update_teletext(sh_video, mpctx->demuxer, 0); - update_osd_msg(mpctx); - struct vf_instance *vf = sh_video->vfilter; - mpctx->osd->pts = mpctx->video_pts; - vf->control(vf, VFCTRL_DRAW_EOSD, mpctx->osd); - vf->control(vf, VFCTRL_DRAW_OSD, mpctx->osd); - vo_osd_changed(0); - - mpctx->time_frame -= mpctx->video_out->flip_queue_offset; - aq_sleep_time += mpctx->time_frame; - // flag 256 means: libvo driver does its timing (dvb card) - if (mpctx->time_frame > 0.001 - && !(mpctx->sh_video->output_flags & VFCAP_TIMER)) - mpctx->time_frame = timing_sleep(mpctx, mpctx->time_frame); - mpctx->time_frame += mpctx->video_out->flip_queue_offset; - - unsigned int t2 = GetTimer(); - /* Playing with playback speed it's possible to get pathological - * cases with mpctx->time_frame negative enough to cause an - * overflow in pts_us calculation, thus the FFMAX. */ - double time_frame = FFMAX(mpctx->time_frame, -1); - unsigned int pts_us = mpctx->last_time + time_frame * 1e6; - int duration = -1; - double pts2 = mpctx->video_out->next_pts2; - if (pts2 != MP_NOPTS_VALUE && opts->correct_pts - && !mpctx->restart_playback) { - // expected A/V sync correction is ignored - double diff = (pts2 - mpctx->video_pts); - diff /= opts->playback_speed; - if (mpctx->time_frame < 0) - diff += mpctx->time_frame; - if (diff < 0) - diff = 0; - if (diff > 10) - diff = 10; - duration = diff * 1e6; - } - vo_flip_page(mpctx->video_out, pts_us | 1, duration); + vo_new_frame_imminent(vo); + struct sh_video *sh_video = mpctx->sh_video; + mpctx->video_pts = sh_video->pts; + update_subtitles(mpctx, sh_video->pts, false); + update_teletext(sh_video, mpctx->demuxer, 0); + update_osd_msg(mpctx); + struct vf_instance *vf = sh_video->vfilter; + mpctx->osd->pts = mpctx->video_pts - mpctx->osd->sub_offset; + vf->control(vf, VFCTRL_DRAW_EOSD, mpctx->osd); + vf->control(vf, VFCTRL_DRAW_OSD, mpctx->osd); + vo_osd_changed(0); - mpctx->last_vo_flip_duration = (GetTimer() - t2) * 0.000001; - vout_time_usage += mpctx->last_vo_flip_duration; - if (mpctx->video_out->driver->flip_page_timed) { - // No need to adjust sync based on flip speed - mpctx->last_vo_flip_duration = 0; - // For print_status - VO call finishing early is OK for sync - mpctx->time_frame -= get_relative_time(mpctx); - } - if (mpctx->restart_playback) { - mpctx->syncing_audio = true; - if (mpctx->sh_audio) - fill_audio_out_buffers(mpctx); - mpctx->restart_playback = false; - mpctx->time_frame = 0; - get_relative_time(mpctx); - } - print_status(mpctx, MP_NOPTS_VALUE, true); - screenshot_flip(mpctx); - } else - print_status(mpctx, MP_NOPTS_VALUE, false); + mpctx->time_frame -= get_relative_time(mpctx); + mpctx->time_frame -= vo->flip_queue_offset; + float aq_sleep_time = mpctx->time_frame; + if (mpctx->time_frame > 0.001 + && !(mpctx->sh_video->output_flags & VFCAP_TIMER)) + mpctx->time_frame = timing_sleep(mpctx, mpctx->time_frame); + mpctx->time_frame += vo->flip_queue_offset; + + unsigned int t2 = GetTimer(); + /* Playing with playback speed it's possible to get pathological + * cases with mpctx->time_frame negative enough to cause an + * overflow in pts_us calculation, thus the FFMAX. */ + double time_frame = FFMAX(mpctx->time_frame, -1); + unsigned int pts_us = mpctx->last_time + time_frame * 1e6; + int duration = -1; + double pts2 = vo->next_pts2; + if (pts2 != MP_NOPTS_VALUE && opts->correct_pts && + !mpctx->restart_playback) { + // expected A/V sync correction is ignored + double diff = (pts2 - mpctx->video_pts); + diff /= opts->playback_speed; + if (mpctx->time_frame < 0) + diff += mpctx->time_frame; + if (diff < 0) + diff = 0; + if (diff > 10) + diff = 10; + duration = diff * 1e6; + } + vo_flip_page(vo, pts_us | 1, duration); + + mpctx->last_vo_flip_duration = (GetTimer() - t2) * 0.000001; + vout_time_usage += mpctx->last_vo_flip_duration; + if (vo->driver->flip_page_timed) { + // No need to adjust sync based on flip speed + mpctx->last_vo_flip_duration = 0; + // For print_status - VO call finishing early is OK for sync + mpctx->time_frame -= get_relative_time(mpctx); + } + if (mpctx->restart_playback) { + mpctx->syncing_audio = true; + if (mpctx->sh_audio) + fill_audio_out_buffers(mpctx, endpts); + mpctx->restart_playback = false; + mpctx->time_frame = 0; + get_relative_time(mpctx); + } + print_status(mpctx, MP_NOPTS_VALUE, true); + screenshot_flip(mpctx); if (opts->auto_quality > 0) { current_module = "autoq"; @@ -3757,25 +3627,18 @@ set_video_quality(mpctx->sh_video, output_quality); } - if (!frame_time_remaining && blit_frame) { - if (play_n_frames >= 0) { - --play_n_frames; - if (play_n_frames <= 0) - mpctx->stop_play = PT_NEXT_ENTRY; - } - if (mpctx->step_frames > 0) { - mpctx->step_frames--; - if (mpctx->step_frames == 0) - pause_player(mpctx); - } + if (play_n_frames >= 0) { + --play_n_frames; + if (play_n_frames <= 0) + mpctx->stop_play = PT_NEXT_ENTRY; } - - // FIXME: add size based support for -endpos - if (end_at.type == END_AT_TIME && - !frame_time_remaining && end_at.pos <= mpctx->sh_video->pts) - mpctx->stop_play = PT_NEXT_ENTRY; - - } // end if(mpctx->sh_video) + if (mpctx->step_frames > 0) { + mpctx->step_frames--; + if (mpctx->step_frames == 0) + pause_player(mpctx); + } + break; + } // video #ifdef CONFIG_DVDNAV if (mpctx->stream->type == STREAMTYPE_DVDNAV) { @@ -3801,48 +3664,117 @@ } #endif - //================= Keyboard events, SEEKing ==================== + if (mpctx->sh_audio && (mpctx->restart_playback ? !video_left : + mpctx->ao->untimed && (mpctx->delay <= 0 || + !video_left))) { + int status = fill_audio_out_buffers(mpctx, endpts); + full_audio_buffers = status >= 0 && !mpctx->ao->untimed; + // Not at audio stream EOF yet + audio_left = status > -2; + } + if (!video_left) + mpctx->restart_playback = false; + if (mpctx->sh_audio && buffered_audio == -1) + buffered_audio = mpctx->paused ? 0 : ao_get_delay(mpctx->ao); - current_module = "key_events"; + update_osd_msg(mpctx); + if (mpctx->paused) + update_pause_message(mpctx); + if (!video_left && (!mpctx->paused || was_restart)) { + double a_pos = 0; + if (mpctx->sh_audio) { + a_pos = (written_audio_pts(mpctx) - + mpctx->opts.playback_speed * buffered_audio); + } + print_status(mpctx, a_pos, false); - while (1) { - mp_cmd_t *cmd; - while ((cmd = mp_input_get_cmd(mpctx->input, 0, 1)) != NULL) { - /* Allow running consecutive seek commands to combine them, - * but execute the seek before running other commands. - * If the user seeks continuously (keeps arrow key down) - * try to finish showing a frame from one location before doing - * another seek (which could lead to unchanging display). */ - if (mpctx->seek.type && cmd->id != MP_CMD_SEEK - || mpctx->restart_playback && cmd->id == MP_CMD_SEEK - && GetTimerMS() - mpctx->start_timestamp < 300) - break; - cmd = mp_input_get_cmd(mpctx->input, 0, 0); - run_command(mpctx, cmd); - mp_cmd_free(cmd); - if (mpctx->stop_play) - break; + if (!mpctx->sh_video) + update_subtitles(mpctx, a_pos, false); + } + + /* It's possible for the user to simultaneously switch both audio + * and video streams to "disabled" at runtime. Handle this by waiting + * rather than immediately stopping playback due to EOF. + * + * When all audio has been written to output driver, stay in the + * main loop handling commands until it has been mostly consumed, + * except in the gapless case, where the next file will be started + * while audio from the current one still remains to be played. + * + * We want this check to trigger if we seeked to this position, + * but not if we paused at it with audio possibly still buffered in + * the AO. There's currently no working way to check buffered audio + * inside AO while paused. Thus the "was_restart" check below, which + * should trigger after seek only, when we know there's no audio + * buffered. + */ + if ((mpctx->sh_audio || mpctx->sh_video) && !audio_left && !video_left + && (opts->gapless_audio || buffered_audio < 0.05) + && (!mpctx->paused || was_restart)) { + if (end_is_chapter) { + seek(mpctx, (struct seek_params){ + .type = MPSEEK_ABSOLUTE, + .amount = mpctx->timeline[mpctx->timeline_part+1].start + }, true); + } else + mpctx->stop_play = AT_END_OF_FILE; + } else if (!mpctx->stop_play) { + double audio_sleep = 9; + if (mpctx->sh_audio && !mpctx->paused) { + if (mpctx->ao->untimed) { + if (!video_left) + audio_sleep = 0; + } else if (full_audio_buffers) { + audio_sleep = buffered_audio - 0.050; + // Keep extra safety margin if the buffers are large + if (audio_sleep > 0.100) + audio_sleep = FFMAX(audio_sleep - 0.200, 0.100); + else + audio_sleep = FFMAX(audio_sleep, 0.020); + } else + audio_sleep = 0.020; } - bool slow_video = mpctx->sh_video && mpctx->video_out->frame_loaded; - if (!(mpctx->paused || slow_video) || mpctx->stop_play - || mpctx->seek.type || mpctx->restart_playback) - break; - if (mpctx->sh_video) { - update_osd_msg(mpctx); + sleeptime = FFMIN(sleeptime, audio_sleep); + if (sleeptime > 0) { + if (!mpctx->sh_video) + goto novideo; int hack = vo_osd_changed(0); vo_osd_changed(hack); if (hack || mpctx->video_out->want_redraw) { if (redraw_osd(mpctx) < 0) { - if (mpctx->paused) + if (mpctx->paused && video_left) add_step_frame(mpctx); - break; + else + goto novideo; } else vo_osd_changed(0); + } else { + novideo: + mp_input_get_cmd(mpctx->input, sleeptime * 1000, true); } } - if (!mpctx->paused) + } + + //================= Keyboard events, SEEKing ==================== + + current_module = "key_events"; + + mp_cmd_t *cmd; + while ((cmd = mp_input_get_cmd(mpctx->input, 0, 1)) != NULL) { + /* Allow running consecutive seek commands to combine them, + * but execute the seek before running other commands. + * If the user seeks continuously (keeps arrow key down) + * try to finish showing a frame from one location before doing + * another seek (which could lead to unchanging display). */ + if (mpctx->seek.type && cmd->id != MP_CMD_SEEK + || mpctx->restart_playback && cmd->id == MP_CMD_SEEK + && GetTimerMS() - mpctx->start_timestamp < 300) + break; + cmd = mp_input_get_cmd(mpctx->input, 0, 0); + run_command(mpctx, cmd); + mp_cmd_free(cmd); + if (mpctx->stop_play) break; - pause_loop(mpctx); } // handle -sstep @@ -3851,8 +3783,6 @@ queue_seek(mpctx, MPSEEK_RELATIVE, step_sec, 0); } - edl_update(mpctx); - /* Looping. */ if (opts->loop_times >= 0 && (mpctx->stop_play == AT_END_OF_FILE || mpctx->stop_play == PT_NEXT_ENTRY)) { @@ -3876,8 +3806,9 @@ static int read_keys(void *ctx, int fd) { - getch2(ctx); - return MP_INPUT_NOTHING; + if (getch2(ctx)) + return MP_INPUT_NOTHING; + return MP_INPUT_DEAD; } static bool attachment_is_font(struct demux_attachment *att) @@ -3971,6 +3902,10 @@ || !strcmp(argv[1], "--leak-report"))) talloc_enable_leak_report(); +#ifdef __MINGW32__ + mp_get_converted_argv(&argc, &argv); +#endif + char *mem_ptr; // movie info: @@ -3988,6 +3923,7 @@ .set_of_sub_pos = -1, .file_format = DEMUXER_TYPE_UNKNOWN, .last_dvb_step = 1, + .paused_cache_fill = -1, }; InitTimer(); @@ -4008,7 +3944,7 @@ mp_input_register_options(mpctx->mconfig); // Preparse the command line - m_config_preparse_command_line(mpctx->mconfig, argc, argv); + m_config_preparse_command_line(mpctx->mconfig, argc, argv, &verbose); #if (defined(__MINGW32__) || defined(__CYGWIN__)) && defined(CONFIG_WIN32DLL) set_path_env(); @@ -4316,17 +4252,13 @@ mp_msg(MSGT_CPLAYER, MSGL_DBG2, "\n[[[init getch2]]]\n"); } - // ================= GUI idle loop (STOP state) ========================= + // ================= idle loop (STOP state) ========================= while (opts->player_idle_mode && !mpctx->filename) { + uninit_player(mpctx, INITIALIZED_AO | INITIALIZED_VO); play_tree_t *entry = NULL; mp_cmd_t *cmd; - if (mpctx->video_out && mpctx->video_out->config_ok) - vo_control(mpctx->video_out, VOCTRL_PAUSE, NULL); - while (!(cmd = mp_input_get_cmd(mpctx->input, 0, 0))) { - if (mpctx->video_out) - vo_check_events(mpctx->video_out); - usec_sleep(20000); - } + while (!(cmd = mp_input_get_cmd(mpctx->input, WAKEUP_PERIOD * 1000, + false))); switch (cmd->id) { case MP_CMD_LOADFILE: // prepare a tree entry with the new filename @@ -4396,11 +4328,6 @@ mp_basename(mpctx->filename)); } - if (edl_filename) { - if (edl_records) - free_edl(edl_records); - next_edl_record = edl_records = edl_parse_file(); - } if (edl_output_filename) { if (edl_fd) fclose(edl_fd); @@ -4915,7 +4842,6 @@ mixer_setvolume(&mpctx->mixer, start_volume, start_volume); if (!ignore_start) audio_delay -= mpctx->sh_audio->stream_delay; - mpctx->delay = -audio_delay; } if (!mpctx->sh_audio) { diff -Nru mplayer2-2.0-426-gc32b3ed/options.h mplayer2-2.0-554-gf63dbad/options.h --- mplayer2-2.0-426-gc32b3ed/options.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/options.h 2012-05-17 14:38:00.000000000 +0000 @@ -6,6 +6,10 @@ char **audio_driver_list; int fixed_vo; int vo_ontop; + char *mixer_device; + char *mixer_channel; + int softvol; + float softvol_max; int gapless_audio; int ao_buffersize; int screen_size_x; @@ -24,6 +28,7 @@ int requested_colorspace; int requested_input_range; int requested_output_range; + int cursor_autohide_delay; // ranges -100 - 100, 1000 if the vo default should be used int vo_gamma_gamma; diff -Nru mplayer2-2.0-426-gc32b3ed/osdep/cocoa_events.h mplayer2-2.0-554-gf63dbad/osdep/cocoa_events.h --- mplayer2-2.0-426-gc32b3ed/osdep/cocoa_events.h 1970-01-01 00:00:00.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/osdep/cocoa_events.h 2012-05-17 14:38:00.000000000 +0000 @@ -0,0 +1,30 @@ +/* + * Cocoa Event Handling + * + * This file is part of mplayer2. + * + * mplayer2 is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * mplayer2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with mplayer2. If not, see . + */ + +#ifndef MPLAYER_COCOA_EVENTS_H +#define MPLAYER_COCOA_EVENTS_H + +#include "input/input.h" + +void cocoa_events_init(struct input_ctx *ictx, + void (*read_all_fd_events)(struct input_ctx *ictx, int time)); +void cocoa_events_uninit(void); +void cocoa_events_read_all_events(struct input_ctx *ictx, int time); + +#endif /* MPLAYER_COCOA_EVENTS_H */ diff -Nru mplayer2-2.0-426-gc32b3ed/osdep/cocoa_events.m mplayer2-2.0-554-gf63dbad/osdep/cocoa_events.m --- mplayer2-2.0-426-gc32b3ed/osdep/cocoa_events.m 1970-01-01 00:00:00.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/osdep/cocoa_events.m 2012-05-17 14:38:00.000000000 +0000 @@ -0,0 +1,137 @@ +/* + * Cocoa Event Handling + * + * This file is part of mplayer2. + * + * mplayer2 is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * mplayer2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with mplayer2. If not, see . + */ + +/* + * Implementation details: + * This file deals with custom event polling on MacOSX. When mplayer2 is paused + * it will asynchronously poll for events using select. This works correctly on + * Linux with X11 since the events are notified through the file descriptors + * where mplayer2 is listening on. On the other hand, the OSX window server + * notifies the processes for events using mach ports. + * + * The code below uses functionality from Cocoa that abstracts the async polling + * of events from the window server. When a Cocoa event comes in, the polling is + * interrupted and the event is dealt with in the next vo_check_events. + * + * To keep the select fd polling code working, that functionality is executed + * from another thread. Whoever finishes polling before the given time, be it + * Cocoa or the original select code, notifies the other for an immediate wake. + */ + +#include "cocoa_events.h" +#include "libvo/cocoa_common.h" +#include "talloc.h" + +#import +#include + +// Bogus event subtype to wake the Cocoa code from polling state +#define MP_EVENT_SUBTYPE_WAKE_EVENTLOOP 100 + +// This is the threshold in milliseconds below which the Cocoa polling is not +// executed. There is some overhead caused by the synchronization between +// threads. Even if in practice it isn't noticeable, we try to avoid the useless +// waste of resources. +#define MP_ASYNC_THRESHOLD 50 + +struct priv { + dispatch_queue_t select_queue; + bool is_runloop_polling; + void (*read_all_fd_events)(struct input_ctx *ictx, int time); +}; + +static struct priv *p; + +static void cocoa_wait_events(int mssleeptime) +{ + NSTimeInterval sleeptime = mssleeptime / 1000.0; + NSEvent *event; + p->is_runloop_polling = YES; + event = [NSApp nextEventMatchingMask:NSAnyEventMask + untilDate:[NSDate dateWithTimeIntervalSinceNow:sleeptime] + inMode:NSEventTrackingRunLoopMode dequeue:NO]; + + // dequeue the next event if it is a fake to wake the cocoa polling + if (event && [event type] == NSApplicationDefined && + [event subtype] == MP_EVENT_SUBTYPE_WAKE_EVENTLOOP) { + [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:nil + inMode:NSEventTrackingRunLoopMode dequeue:YES]; + } + p->is_runloop_polling = NO; +} + +static void cocoa_wake_runloop() +{ + if (p->is_runloop_polling) { + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + NSEvent *event; + + /* Post an event so we'll wake the run loop that is async polling */ + event = [NSEvent otherEventWithType: NSApplicationDefined + location: NSZeroPoint + modifierFlags: 0 + timestamp: 0 + windowNumber: 0 + context: nil + subtype: MP_EVENT_SUBTYPE_WAKE_EVENTLOOP + data1: 0 + data2: 0]; + + [NSApp postEvent:event atStart:NO]; + [pool release]; + } +} + +void cocoa_events_init(struct input_ctx *ictx, + void (*read_all_fd_events)(struct input_ctx *ictx, int time)) +{ + NSApplicationLoad(); + p = talloc_ptrtype(NULL, p); + *p = (struct priv){ + .is_runloop_polling = NO, + .read_all_fd_events = read_all_fd_events, + .select_queue = dispatch_queue_create("org.mplayer2.select_queue", + NULL), + }; +} + +void cocoa_events_uninit(void) +{ + talloc_free(p); +} + +void cocoa_events_read_all_events(struct input_ctx *ictx, int time) +{ + // don't bother delegating the select to the async queue if the blocking + // time is really low or if we are not running a GUI + if (time > MP_ASYNC_THRESHOLD && vo_cocoa_gui_running()) { + dispatch_async(p->select_queue, ^{ + p->read_all_fd_events(ictx, time); + cocoa_wake_runloop(); + }); + + cocoa_wait_events(time); + mp_input_wakeup(ictx); + + // wait for the async queue to get empty. + dispatch_sync(p->select_queue, ^{}); + } else { + p->read_all_fd_events(ictx, time); + } +} diff -Nru mplayer2-2.0-426-gc32b3ed/osdep/getch2-os2.c mplayer2-2.0-554-gf63dbad/osdep/getch2-os2.c --- mplayer2-2.0-426-gc32b3ed/osdep/getch2-os2.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/osdep/getch2-os2.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,200 +0,0 @@ -/* - * OS/2 TermIO - * - * Copyright (c) 2007 KO Myung-Hun (komh@chollian.net) - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#define INCL_KBD -#define INCL_VIO -#define INCL_DOS -#include - -#include -#include - -#include "config.h" -#include "input/keycodes.h" -#include "input/input.h" -#include "mp_fifo.h" -#include "getch2.h" - -#if defined(HAVE_LANGINFO) && defined(CONFIG_ICONV) -#include -#include -#endif - -int mp_input_slave_cmd_func( int fd, char *dest, int size ) -{ - PPIB ppib; - CHAR szPipeName[ 100 ]; - HFILE hpipe; - ULONG ulAction; - ULONG cbActual; - ULONG rc; - - DosGetInfoBlocks( NULL, &ppib ); - - sprintf( szPipeName, "\\PIPE\\MPLAYER\\%lx", ppib->pib_ulpid ); - - rc = DosOpen( szPipeName, &hpipe, &ulAction, 0, FILE_NORMAL, - OPEN_ACTION_OPEN_IF_EXISTS, - OPEN_SHARE_DENYREADWRITE | OPEN_ACCESS_READWRITE, - NULL ); - if( rc ) - return MP_INPUT_NOTHING; - - rc = DosRead( hpipe, dest, size, &cbActual ); - if( rc ) - return MP_INPUT_NOTHING; - - rc = cbActual; - - // Send ACK - DosWrite( hpipe, &rc, sizeof( ULONG ), &cbActual ); - - DosClose( hpipe ); - - return rc; -} - - -int screen_width = 80; -int screen_height = 24; -char *erase_to_end_of_line = NULL; - -void get_screen_size( void ) -{ - VIOMODEINFO vmi; - - vmi.cb = sizeof( VIOMODEINFO ); - - VioGetMode( &vmi, 0 ); - - screen_width = vmi.col; - screen_height = vmi.row; -} - -static int getch2_status = 0; - -static int getch2_internal( void ) -{ - KBDKEYINFO kki; - - if( !getch2_status ) - return -1; - - if( KbdCharIn( &kki, IO_NOWAIT, 0 )) - return -1; - - // key pressed ? - if( kki.fbStatus ) - { - // extended key ? - if(( kki.chChar == 0x00 ) || ( kki.chChar == 0xE0 )) - { - switch( kki.chScan ) - { - case 0x4B : // Left - return KEY_LEFT; - - case 0x48 : // Up - return KEY_UP; - - case 0x4D : // Right - return KEY_RIGHT; - - case 0x50 : // Down - return KEY_DOWN; - - case 0x53 : // Delete - return KEY_DELETE; - - case 0x52 : // Insert - return KEY_INSERT; - - case 0x47 : // Home - return KEY_HOME; - - case 0x4F : // End - return KEY_END; - - case 0x49 : // Page Up - return KEY_PAGE_UP; - - case 0x51 : // Page Down - return KEY_PAGE_DOWN; - } - } - else - { - switch( kki.chChar ) - { - case 0x08 : // Backspace - return KEY_BS; - - case 0x1B : // Esc - return KEY_ESC; - - case 0x0D : // Enter - // Keypad Enter ? - if( kki.chScan == 0xE0 ) - return KEY_KPENTER; - break; - } - - return kki.chChar; - } - } - - return -1; -} - -void getch2(struct mp_fifo *fifo) -{ - int key; - - key = getch2_internal(); - if( key != -1 ) - mplayer_put_key(fifo, key); -} - -void getch2_enable( void ) -{ - getch2_status = 1; -} - -void getch2_disable( void ) -{ - getch2_status = 0; -} - -#ifdef CONFIG_ICONV -char *get_term_charset( void ) -{ - char *charset = NULL; - -#ifdef HAVE_LANGINFO - setlocale( LC_CTYPE, ""); - charset = strdup( nl_langinfo( CODESET )); - setlocale( LC_CTYPE, "C"); -#endif - - return charset; -} -#endif diff -Nru mplayer2-2.0-426-gc32b3ed/osdep/getch2-win.c mplayer2-2.0-554-gf63dbad/osdep/getch2-win.c --- mplayer2-2.0-426-gc32b3ed/osdep/getch2-win.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/osdep/getch2-win.c 2012-05-17 14:38:00.000000000 +0000 @@ -55,6 +55,12 @@ char * erase_to_end_of_line = NULL; void get_screen_size(void){ + CONSOLE_SCREEN_BUFFER_INFO cinfo; + if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cinfo)) + { + screen_width = cinfo.dwMaximumWindowSize.X; + screen_height = cinfo.dwMaximumWindowSize.Y; + } } static HANDLE in; @@ -77,7 +83,7 @@ /*check if there are input events*/ if(!GetNumberOfConsoleInputEvents(in,&retval)) { - printf("getch2: can't get number of input events: %i\n",GetLastError()); + printf("getch2: can't get number of input events: %i\n",(int)GetLastError()); return -1; } if(retval<=0)return -1; @@ -152,11 +158,12 @@ return -1; } -void getch2(struct mp_fifo *fifo) +bool getch2(struct mp_fifo *fifo) { int r = getch2_internal(); if (r >= 0) mplayer_put_key(fifo, r); + return true; } void getch2_enable(void) @@ -165,7 +172,7 @@ in = GetStdHandle(STD_INPUT_HANDLE); if(!GetNumberOfConsoleInputEvents(in,&retval)) { - printf("getch2: %i can't get number of input events [disabling console input]\n",GetLastError()); + printf("getch2: %i can't get number of input events [disabling console input]\n",(int)GetLastError()); getch2_status = 0; } else getch2_status=1; diff -Nru mplayer2-2.0-426-gc32b3ed/osdep/getch2.c mplayer2-2.0-554-gf63dbad/osdep/getch2.c --- mplayer2-2.0-426-gc32b3ed/osdep/getch2.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/osdep/getch2.c 2012-05-17 14:38:00.000000000 +0000 @@ -24,7 +24,7 @@ #include "config.h" //#define HAVE_TERMCAP -#if !defined(__OS2__) && !defined(__MORPHOS__) +#if !defined(__MORPHOS__) #define CONFIG_IOCTL #endif @@ -57,6 +57,7 @@ #include #include +#include "bstr.h" #include "mp_fifo.h" #include "input/keycodes.h" #include "getch2.h" @@ -157,11 +158,17 @@ #endif } -void getch2(struct mp_fifo *fifo) +bool getch2(struct mp_fifo *fifo) { int retval = read(0, &getch2_buf[getch2_len], BUF_LEN-getch2_len); + /* Return false on EOF to stop running select() on the FD, as it'd + * trigger all the time. Note that it's possible to get temporary + * EOF on terminal if the user presses ctrl-d, but that shouldn't + * happen if the terminal state change done in getch2_enable() + * works. + */ if (retval < 1) - return; + return retval; getch2_len += retval; while (getch2_len > 0 && (getch2_len > 1 || getch2_buf[0] != 27)) { @@ -201,6 +208,16 @@ len = 2; } code = KEY_ENTER; + } else { + int utf8len = bstr_parse_utf8_code_length(code); + if (utf8len > 0 && utf8len <= getch2_len) { + struct bstr s = { getch2_buf, utf8len }; + int unicode = bstr_decode_utf8(s, NULL); + if (unicode > 0) { + len = utf8len; + code = unicode; + } + } } } else if (getch2_len > 1) { @@ -225,7 +242,7 @@ } if ((c == '[' || c == 'O') && getch2_len >= 3) { int c = getch2_buf[2]; - const short ctable[] = { + const int ctable[] = { KEY_UP, KEY_DOWN, KEY_RIGHT, KEY_LEFT, 0, KEY_END, KEY_PGDWN, KEY_HOME, KEY_PGUP, 0, 0, KEY_INS, 0, 0, 0, KEY_F+1, KEY_F+2, KEY_F+3, KEY_F+4}; @@ -268,6 +285,7 @@ getch2_buf[i] = getch2_buf[len+i]; mplayer_put_key(fifo, code); } + return true; } static int getch2_status=0; diff -Nru mplayer2-2.0-426-gc32b3ed/osdep/getch2.h mplayer2-2.0-554-gf63dbad/osdep/getch2.h --- mplayer2-2.0-426-gc32b3ed/osdep/getch2.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/osdep/getch2.h 2012-05-17 14:38:00.000000000 +0000 @@ -24,6 +24,8 @@ #ifndef MPLAYER_GETCH2_H #define MPLAYER_GETCH2_H +#include + #include "config.h" /* Screen size. Initialized by load_termcap() and get_screen_size() */ @@ -45,7 +47,7 @@ /* Read a character or a special key code (see keycodes.h) */ struct mp_fifo; -void getch2(struct mp_fifo *fifo); +bool getch2(struct mp_fifo *fifo); #ifdef CONFIG_ICONV /** @@ -58,8 +60,8 @@ char *get_term_charset(void); #endif -#if defined(__MINGW32__) || defined(__OS2__) -/* slave cmd function for Windows and OS/2 */ +#if defined(__MINGW32__) +// slave cmd function for Windows int mp_input_slave_cmd_func(int fd,char* dest,int size); #define USE_FD0_CMD_SELECT 0 #define MP_INPUT_SLAVE_CMD_FUNC mp_input_slave_cmd_func diff -Nru mplayer2-2.0-426-gc32b3ed/osdep/io.c mplayer2-2.0-554-gf63dbad/osdep/io.c --- mplayer2-2.0-426-gc32b3ed/osdep/io.c 1970-01-01 00:00:00.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/osdep/io.c 2012-05-17 14:38:00.000000000 +0000 @@ -0,0 +1,243 @@ +/* + * unicode/utf-8 I/O helpers and wrappers for Windows + * + * This file is part of mplayer2. + * Contains parts based on libav code (http://libav.org). + * + * mplayer2 is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * mplayer2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with mplayer2. If not, see . + */ + +#ifdef _WIN32 + +#include +#include +#include +#include + +#include "osdep/io.h" +#include "talloc.h" + +//copied and modified from libav +//http://git.libav.org/?p=libav.git;a=blob;f=libavformat/os_support.c;h=a0fcd6c9ba2be4b0dbcc476f6c53587345cc1152;hb=HEADl30 + +wchar_t *mp_from_utf8(void *talloc_ctx, const char *s) +{ + int count = MultiByteToWideChar(CP_UTF8, 0, s, -1, NULL, 0); + if (count <= 0) + abort(); + wchar_t *ret = talloc_array(talloc_ctx, wchar_t, count); + MultiByteToWideChar(CP_UTF8, 0, s, -1, ret, count); + return ret; +} + +char *mp_to_utf8(void *talloc_ctx, const wchar_t *s) +{ + int count = WideCharToMultiByte(CP_UTF8, 0, s, -1, NULL, 0, NULL, NULL); + if (count <= 0) + abort(); + char *ret = talloc_array(talloc_ctx, char, count); + WideCharToMultiByte(CP_UTF8, 0, s, -1, ret, count, NULL, NULL); + return ret; +} + +#endif // _WIN32 + +#ifdef __MINGW32__ + +#include +#include + +//http://git.libav.org/?p=libav.git;a=blob;f=cmdutils.c;h=ade3f10ce2fc030e32e375a85fbd06c26d43a433#l161 + +static char** win32_argv_utf8; +static int win32_argc; + +void mp_get_converted_argv(int *argc, char ***argv) +{ + if (!win32_argv_utf8) { + win32_argc = 0; + wchar_t **argv_w = CommandLineToArgvW(GetCommandLineW(), &win32_argc); + if (win32_argc <= 0 || !argv_w) + return; + + win32_argv_utf8 = talloc_zero_array(NULL, char*, win32_argc + 1); + + for (int i = 0; i < win32_argc; i++) { + win32_argv_utf8[i] = mp_to_utf8(NULL, argv_w[i]); + } + + LocalFree(argv_w); + } + + *argc = win32_argc; + *argv = win32_argv_utf8; +} + +int mp_stat(const char *path, struct stat *buf) +{ + wchar_t *wpath = mp_from_utf8(NULL, path); + int res = _wstat64(wpath, buf); + talloc_free(wpath); + return res; +} + +int mp_fprintf(FILE *stream, const char *format, ...) +{ + va_list args; + int done = 0; + + va_start(args, format); + + if (stream == stdout || stream == stderr) + { + HANDLE *wstream = GetStdHandle(stream == stdout ? + STD_OUTPUT_HANDLE : STD_ERROR_HANDLE); + if (wstream != INVALID_HANDLE_VALUE) + { + // figure out whether we're writing to a console + unsigned int filetype = GetFileType(wstream); + if (!((filetype == FILE_TYPE_UNKNOWN) && + (GetLastError() != ERROR_SUCCESS))) + { + int isConsole; + filetype &= ~(FILE_TYPE_REMOTE); + if (filetype == FILE_TYPE_CHAR) + { + DWORD ConsoleMode; + int ret = GetConsoleMode(wstream, &ConsoleMode); + if (!ret && (GetLastError() == ERROR_INVALID_HANDLE)) + isConsole = 0; + else + isConsole = 1; + } + else + isConsole = 0; + + if (isConsole) + { + int nchars = vsnprintf(NULL, 0, format, args) + 1; + char *buf = talloc_array(NULL, char, nchars); + if (buf) + { + vsnprintf(buf, nchars, format, args); + wchar_t *out = mp_from_utf8(NULL, buf); + size_t nchars = wcslen(out); + talloc_free(buf); + done = WriteConsoleW(wstream, out, nchars, NULL, NULL); + talloc_free(out); + } + } + else + done = vfprintf(stream, format, args); + } + } + } + else + done = vfprintf(stream, format, args); + + va_end(args); + + return done; +} + +int mp_open(const char *filename, int oflag, ...) +{ + int mode = 0; + if (oflag & _O_CREAT) { + va_list va; + va_start(va, oflag); + mode = va_arg(va, int); + va_end(va); + } + wchar_t *wpath = mp_from_utf8(NULL, filename); + int res = _wopen(wpath, oflag, mode); + talloc_free(wpath); + return res; +} + +int mp_creat(const char *filename, int mode) +{ + return open(filename, O_CREAT|O_WRONLY|O_TRUNC, mode); +} + +FILE *mp_fopen(const char *filename, const char *mode) +{ + wchar_t *wpath = mp_from_utf8(NULL, filename); + wchar_t *wmode = mp_from_utf8(wpath, mode); + FILE *res = _wfopen(wpath, wmode); + talloc_free(wpath); + return res; +} + +struct mp_dir { + DIR crap; // must be first member + _WDIR *wdir; + union { + struct dirent dirent; + // dirent has space only for FILENAME_MAX bytes. _wdirent has space for + // FILENAME_MAX wchar_t, which might end up bigger as UTF-8 in some + // cases. Guarantee we can always hold _wdirent.d_name converted to + // UTF-8 (see MP_PATH_MAX). + // This works because dirent.d_name is the last member of dirent. + char space[MP_PATH_MAX]; + }; +}; + +DIR* mp_opendir(const char *path) +{ + wchar_t *wpath = mp_from_utf8(NULL, path); + _WDIR *wdir = _wopendir(wpath); + talloc_free(wpath); + if (!wdir) + return NULL; + struct mp_dir *mpdir = talloc(NULL, struct mp_dir); + // DIR is supposed to be opaque, but unfortunately the MinGW headers still + // define it. Make sure nobody tries to use it. + memset(&mpdir->crap, 0xCD, sizeof(mpdir->crap)); + mpdir->wdir = wdir; + return (DIR*)mpdir; +} + +struct dirent* mp_readdir(DIR *dir) +{ + struct mp_dir *mpdir = (struct mp_dir*)dir; + struct _wdirent *wdirent = _wreaddir(mpdir->wdir); + if (!wdirent) + return NULL; + size_t buffersize = sizeof(mpdir->space) - offsetof(struct dirent, d_name); + WideCharToMultiByte(CP_UTF8, 0, wdirent->d_name, -1, mpdir->dirent.d_name, + buffersize, NULL, NULL); + mpdir->dirent.d_ino = 0; + mpdir->dirent.d_reclen = 0; + mpdir->dirent.d_namlen = strlen(mpdir->dirent.d_name); + return &mpdir->dirent; +} + +int mp_closedir(DIR *dir) +{ + struct mp_dir *mpdir = (struct mp_dir*)dir; + int res = _wclosedir(mpdir->wdir); + talloc_free(mpdir); + return res; +} + +int mp_mkdir(const char *path, int mode) +{ + wchar_t *wpath = mp_from_utf8(NULL, path); + int res = _wmkdir(wpath); + talloc_free(wpath); + return res; +} + +#endif // __MINGW32__ diff -Nru mplayer2-2.0-426-gc32b3ed/osdep/io.h mplayer2-2.0-554-gf63dbad/osdep/io.h --- mplayer2-2.0-426-gc32b3ed/osdep/io.h 1970-01-01 00:00:00.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/osdep/io.h 2012-05-17 14:38:00.000000000 +0000 @@ -0,0 +1,78 @@ +/* + * unicode/utf-8 I/O helpers and wrappers for Windows + * + * This file is part of mplayer2. + * + * mplayer2 is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * mplayer2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with mplayer2. If not, see . + */ + +#ifndef MPLAYER_OSDEP_IO +#define MPLAYER_OSDEP_IO + +#include + +#ifdef _WIN32 +#include +wchar_t *mp_from_utf8(void *talloc_ctx, const char *s); +char *mp_to_utf8(void *talloc_ctx, const wchar_t *s); +#endif + +#ifdef __MINGW32__ + +#include +#include +#include +#include + +// Windows' MAX_PATH/PATH_MAX/FILENAME_MAX is fixed to 260, but this limit +// applies to unicode paths encoded with wchar_t (2 bytes on Windows). The UTF-8 +// version could end up bigger in memory. In the worst case each wchar_t is +// encoded to 3 bytes in UTF-8, so in the worst case we have: +// wcslen(wpath) <= strlen(utf8path) * 3 +// Thus we need MP_PATH_MAX as the UTF-8/char version of PATH_MAX. +#define MP_PATH_MAX (FILENAME_MAX * 3) + +void mp_get_converted_argv(int *argc, char ***argv); + +int mp_stat(const char *path, struct stat *buf); +int mp_fprintf(FILE *stream, const char *format, ...); +int mp_open(const char *filename, int oflag, ...); +int mp_creat(const char *filename, int mode); +FILE *mp_fopen(const char *filename, const char *mode); +DIR *mp_opendir(const char *path); +struct dirent *mp_readdir(DIR *dir); +int mp_closedir(DIR *dir); +int mp_mkdir(const char *path, int mode); + +// NOTE: Stat is not overridden with mp_stat, because MinGW-w64 defines it as +// macro. + +#define fprintf(...) mp_fprintf(__VA_ARGS__) +#define open(...) mp_open(__VA_ARGS__) +#define creat(...) mp_creat(__VA_ARGS__) +#define fopen(...) mp_fopen(__VA_ARGS__) +#define opendir(...) mp_opendir(__VA_ARGS__) +#define readdir(...) mp_readdir(__VA_ARGS__) +#define closedir(...) mp_closedir(__VA_ARGS__) +#define mkdir(...) mp_mkdir(__VA_ARGS__) + +#else /* __MINGW32__ */ + +#define MP_PATH_MAX PATH_MAX + +#define mp_stat(...) stat(__VA_ARGS__) + +#endif /* __MINGW32__ */ + +#endif diff -Nru mplayer2-2.0-426-gc32b3ed/osdep/macosx_finder_args.c mplayer2-2.0-554-gf63dbad/osdep/macosx_finder_args.c --- mplayer2-2.0-426-gc32b3ed/osdep/macosx_finder_args.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/osdep/macosx_finder_args.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,128 +0,0 @@ -/* - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include - -#include "stream/url.h" -#include "mp_msg.h" -#include "m_option.h" -#include "m_config.h" -#include "playtree.h" -#include "macosx_finder_args.h" - -static play_tree_t *files=NULL; - -static inline void add_entry(play_tree_t **last_parentp, play_tree_t **last_entryp, play_tree_t *entry) { - - if(*last_entryp==NULL) - play_tree_set_child(*last_parentp, entry); - else - play_tree_append_entry(*last_entryp, entry); - - *last_entryp=entry; -} - -static pascal OSErr AppleEventHandlerProc(const AppleEvent *theAppleEvent, AppleEvent* reply, SInt32 handlerRefcon) { -OSErr err=errAEEventNotHandled, res=noErr; -AEDescList docList; -long itemsInList; - - AERemoveEventHandler(kCoreEventClass, kAEOpenDocuments, NULL, FALSE); - if((res=AEGetParamDesc(theAppleEvent, keyDirectObject, typeAEList, &docList))==noErr) { - if((res=AECountItems(&docList, &itemsInList))==noErr) { - Size currentSize=0; - int valid=0,i; - char *parm=NULL; - play_tree_t *last_entry=NULL; - - files=play_tree_new(); - for(i=1;i<=itemsInList;++i) { - - for(;;) { - OSErr e; - Size actualSize=0; - AEKeyword keywd; - DescType returnedType; - - if((e=AEGetNthPtr(&docList, i, typeFileURL, &keywd, &returnedType, (Ptr)parm, currentSize, &actualSize))==noErr) { - if(actualSize>=currentSize) { - currentSize=actualSize+1; - parm=realloc(parm, currentSize); - } - else { - parm[actualSize]=0; - valid=1; - break; - } - } - else { - valid=0; - break; - } - } - - if(valid) { - URL_t *url=url_new(parm); - - if(url && !strcmp(url->protocol,"file") && !strcmp(url->hostname,"localhost")) { - play_tree_t *entry=play_tree_new(); - - url_unescape_string(url->file, url->file); - play_tree_add_file(entry, url->file); - add_entry(&files, &last_entry, entry); - } - - url_free(url); - } - } - - free(parm); - - err=noErr; - } - else - mp_msg(MSGT_CFGPARSER, MSGL_ERR, "AECountItems() error %d\n", res); - - AEDisposeDesc(&docList); - } - else - mp_msg(MSGT_CFGPARSER, MSGL_ERR, "AEGetParamDesc() error %d\n", res); - - QuitApplicationEventLoop(); - return err; -} - -play_tree_t *macosx_finder_args(m_config_t *config, int argc, char **argv) { -ProcessSerialNumber myPsn; -char myPsnStr[5+10+1+10+1]; - - GetCurrentProcess(&myPsn); - snprintf(myPsnStr, 5+10+1+10+1, "-psn_%u_%u", myPsn.highLongOfPSN, myPsn.lowLongOfPSN); - myPsnStr[5+10+1+10]=0; - - if((argc==2) && !strcmp(myPsnStr, argv[1])) { - m_config_set_option0(config, "quiet", NULL, false); - InitCursor(); - AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, NewAEEventHandlerUPP(AppleEventHandlerProc), 0, FALSE); - RunApplicationEventLoop(); - } - - return files; -} diff -Nru mplayer2-2.0-426-gc32b3ed/osdep/macosx_finder_args.h mplayer2-2.0-554-gf63dbad/osdep/macosx_finder_args.h --- mplayer2-2.0-426-gc32b3ed/osdep/macosx_finder_args.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/osdep/macosx_finder_args.h 2012-05-17 14:38:00.000000000 +0000 @@ -1,18 +1,18 @@ /* - * This file is part of MPlayer. + * This file is part of mplayer2. * - * MPlayer is free software; you can redistribute it and/or modify + * mplayer2 is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * - * MPlayer is distributed in the hope that it will be useful, + * mplayer2 is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., + * with mplayer2; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ diff -Nru mplayer2-2.0-426-gc32b3ed/osdep/macosx_finder_args.m mplayer2-2.0-554-gf63dbad/osdep/macosx_finder_args.m --- mplayer2-2.0-426-gc32b3ed/osdep/macosx_finder_args.m 1970-01-01 00:00:00.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/osdep/macosx_finder_args.m 2012-05-17 14:38:00.000000000 +0000 @@ -0,0 +1,95 @@ +/* + * This file is part of mplayer2. + * + * mplayer2 is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * mplayer2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with mplayer2; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#import +#import +#include +#include "macosx_finder_args.h" + +static play_tree_t *files = NULL; + +void macosx_wait_fileopen_events(void); +void macosx_redirect_output_to_logfile(const char *filename); +bool psn_matches_current_process(char *psn_arg_to_check); + +@interface FileOpenDelegate : NSObject +- (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames; +@end + +@implementation FileOpenDelegate +- (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames +{ + files = play_tree_new(); + play_tree_t *last_entry = nil; + for (NSString *filename in filenames) { + play_tree_t *entry = play_tree_new(); + play_tree_add_file(entry, [filename UTF8String]); + + if (last_entry) + play_tree_append_entry(files, entry); + else + play_tree_set_child(files, entry); + + last_entry = entry; + } + [NSApp stop:nil]; // stop the runloop (give back control to mplayer2 code) +} +@end + +void macosx_wait_fileopen_events() +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSApp = [NSApplication sharedApplication]; + [NSApp setDelegate: [[[FileOpenDelegate alloc] init] autorelease]]; + [NSApp run]; // block until we recive the fileopen events + [pool release]; +} + +void macosx_redirect_output_to_logfile(const char *filename) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSString *log_path = [NSHomeDirectory() stringByAppendingPathComponent: + [@"Library/Logs/" stringByAppendingFormat:@"%s.log", filename]]; + freopen([log_path fileSystemRepresentation], "a", stdout); + freopen([log_path fileSystemRepresentation], "a", stderr); + [pool release]; +} + +bool psn_matches_current_process(char *psn_arg_to_check) +{ + ProcessSerialNumber psn; + char psn_arg[5+10+1+10+1]; + + GetCurrentProcess(&psn); + snprintf(psn_arg, 5+10+1+10+1, "-psn_%u_%u", + psn.highLongOfPSN, psn.lowLongOfPSN); + psn_arg[5+10+1+10]=0; + + return strcmp(psn_arg, psn_arg_to_check) == 0; +} + +play_tree_t *macosx_finder_args(m_config_t *config, int argc, char **argv) +{ + if (argc==2 && psn_matches_current_process(argv[1])) { + macosx_redirect_output_to_logfile("mplayer2"); + m_config_set_option0(config, "quiet", NULL, false); + macosx_wait_fileopen_events(); + } + + return files; +} diff -Nru mplayer2-2.0-426-gc32b3ed/osdep/mmap-os2.c mplayer2-2.0-554-gf63dbad/osdep/mmap-os2.c --- mplayer2-2.0-426-gc32b3ed/osdep/mmap-os2.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/osdep/mmap-os2.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,211 +0,0 @@ -/* - * very simple implementation of mmap() for OS/2 - * - * Copyright (c) 2008 KO Myung-Hun (komh@chollian.net) - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#define INCL_DOS -#include - -#include -#include -#include -#include -#include - -#include "config.h" -#include "mmap.h" -#include "mmap_anon.h" - -typedef struct os2_mmap_s -{ - void *addr; - size_t len; - int flags; - struct os2_mmap_s *prev; - struct os2_mmap_s *next; -} os2_mmap; -static os2_mmap *m_mmap = NULL; - -void *mmap( void *addr, size_t len, int prot, int flags, int fildes, off_t off ) -{ - os2_mmap *new_mmap; - - ULONG fl; - ULONG rc; - - void *ret; - - if( prot & PROT_WRITE ) - { - if( flags & MAP_SHARED ) - return MAP_FAILED; - - if( !( flags & MAP_PRIVATE )) - return MAP_FAILED; - } - - if( flags & MAP_FIXED ) - { - ULONG cb; - - cb = len; - rc = DosQueryMem( addr, &cb, &fl ); - if( rc || ( cb < len )) - return MAP_FAILED; - - rc = DosSetMem( addr, len, fPERM ); - if( rc ) - return MAP_FAILED; - - ret = addr; - } - else - { - // Allocate tiled memory compatible with 16-bit selectors - // 'fs_seg' in 'ldt_keeper.c' need this attribute - rc = DosAllocMem( &ret, len, fALLOC ); - if( rc ) - return MAP_FAILED; - } - - new_mmap = malloc( sizeof( os2_mmap )); - new_mmap->addr = ret; - new_mmap->len = len; - new_mmap->flags = flags; - new_mmap->prev = m_mmap; - new_mmap->next = NULL; - - if( m_mmap ) - m_mmap->next = new_mmap; - m_mmap = new_mmap; - - if( !( flags & MAP_ANON )) - { - int pos; - - /* Now read in the file */ - if(( pos = lseek( fildes, off, SEEK_SET )) == -1) - { - munmap( ret, len ); - - return MAP_FAILED; - } - - read( fildes, ret, len ); - lseek( fildes, pos, SEEK_SET ); /* Restore the file pointer */ - } - - fl = 0; - - if( prot & PROT_READ ) - fl |= PAG_READ; - - if( prot & PROT_WRITE ) - fl |= PAG_WRITE; - - if( prot & PROT_EXEC ) - fl |= PAG_EXECUTE; - - if( prot & PROT_NONE ) - fl |= PAG_GUARD; - - rc = DosSetMem( ret, len, fl ); - if( rc ) - { - munmap( ret, len ); - - return MAP_FAILED; - } - - return ret; -} - -int munmap( void *addr, size_t len ) -{ - os2_mmap *mm; - - for( mm = m_mmap; mm; mm = mm->prev ) - { - if( mm->addr == addr ) - break; - } - - if( mm ) - { - - if( !( mm->flags & MAP_FIXED )) - DosFreeMem( addr ); - - if( mm->next ) - mm->next->prev = mm->prev; - - if( mm->prev ) - mm->prev->next = mm->next; - - if( m_mmap == mm ) - m_mmap = mm->prev; - - free( mm ); - - return 0; - } - - return -1; -} - -int mprotect( void *addr, size_t len, int prot ) -{ - os2_mmap *mm; - - for( mm = m_mmap; mm; mm = mm->prev ) - { - if( mm->addr == addr ) - break; - } - - if( mm ) - { - ULONG fl; - - fl = 0; - - if( prot & PROT_READ ) - fl |= PAG_READ; - - if( prot & PROT_WRITE ) - fl |= PAG_WRITE; - - if( prot & PROT_EXEC ) - fl |= PAG_EXECUTE; - - if( prot & PROT_NONE ) - fl |= PAG_GUARD; - - if( DosSetMem( addr, len, fl ) == 0 ) - return 0; - } - - return -1; -} - -void *mmap_anon( void *addr, size_t len, int prot, int flags, off_t off ) -{ - return mmap( addr, len, prot, flags | MAP_ANON, -1, off ); -} diff -Nru mplayer2-2.0-426-gc32b3ed/osdep/mplayer.rc mplayer2-2.0-554-gf63dbad/osdep/mplayer.rc --- mplayer2-2.0-426-gc32b3ed/osdep/mplayer.rc 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/osdep/mplayer.rc 2012-05-17 14:38:00.000000000 +0000 @@ -35,7 +35,7 @@ VALUE "CompanyName", "\000" VALUE "FileDescription", "mplayer2 - Movie Player\000" VALUE "FileVersion",VERSION - VALUE "LegalCopyright", " (C) 2000-2011 MPlayer Team\000" + VALUE "LegalCopyright", " (C) 2000-2012 MPlayer Team\000" //VALUE "LegalTrademarks"," \000"; VALUE "OriginalFilename", "mplayer.exe\000" VALUE "ProductName", "mplayer2 - The Movie Player\000" diff -Nru mplayer2-2.0-426-gc32b3ed/osdep/osdep.h mplayer2-2.0-554-gf63dbad/osdep/osdep.h --- mplayer2-2.0-426-gc32b3ed/osdep/osdep.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/osdep/osdep.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -/* - * Header in order to include OS-specific headers, macros, types and so on - * - * Copyright (c) 2010 by KO Myung-Hun (komh@chollian.net) - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPLAYER_OSDEP_H -#define MPLAYER_OSDEP_H - -#ifdef __OS2__ -#define INCL_DOS -#define INCL_DOSDEVIOCTL -#include - -#include /* getpid() */ - -#define REALTIME_PRIORITY_CLASS MAKESHORT(0, PRTYC_TIMECRITICAL) -#define HIGH_PRIORITY_CLASS MAKESHORT(PRTYD_MAXIMUM, PRTYC_REGULAR) -#define ABOVE_NORMAL_PRIORITY_CLASS MAKESHORT(PRTYD_MAXIMUM / 2, PRTYC_REGULAR) -#define NORMAL_PRIORITY_CLASS MAKESHORT(0, PRTYC_REGULAR) -#define BELOW_NORMAL_PRIORITY_CLASS MAKESHORT(PRTYD_MAXIMUM, PRTYC_IDLETIME) -#define IDLE_PRIORITY_CLASS MAKESHORT(0, PRTYC_IDLETIME) - -#define SetPriorityClass(pid, prio) \ - DosSetPriority(PRTYS_PROCESS, \ - HIBYTE(prio), \ - LOBYTE(prio), \ - pid) - -#define GetCurrentProcess() getpid() -#endif /* __OS2__ */ - -#endif /* MPLAYER_OSDEP_H */ - diff -Nru mplayer2-2.0-426-gc32b3ed/osdep/priority.c mplayer2-2.0-554-gf63dbad/osdep/priority.c --- mplayer2-2.0-426-gc32b3ed/osdep/priority.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/osdep/priority.c 2012-05-17 14:38:00.000000000 +0000 @@ -20,8 +20,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "osdep.h" - #if defined(__MINGW32__) || defined(__CYGWIN__) #include #endif diff -Nru mplayer2-2.0-426-gc32b3ed/osdep/setenv.c mplayer2-2.0-554-gf63dbad/osdep/setenv.c --- mplayer2-2.0-426-gc32b3ed/osdep/setenv.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/osdep/setenv.c 2012-05-17 14:38:00.000000000 +0000 @@ -24,6 +24,8 @@ #include #include +int setenv(const char *name, const char *val, int overwrite); + int setenv(const char *name, const char *val, int overwrite) { int len = strlen(name) + strlen(val) + 2; diff -Nru mplayer2-2.0-426-gc32b3ed/parser-cfg.c mplayer2-2.0-554-gf63dbad/parser-cfg.c --- mplayer2-2.0-426-gc32b3ed/parser-cfg.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/parser-cfg.c 2012-05-17 14:38:00.000000000 +0000 @@ -25,6 +25,8 @@ #include #include +#include "osdep/io.h" + #include "parser-cfg.h" #include "mp_msg.h" #include "m_option.h" diff -Nru mplayer2-2.0-426-gc32b3ed/parser-mpcmd.c mplayer2-2.0-554-gf63dbad/parser-mpcmd.c --- mplayer2-2.0-426-gc32b3ed/parser-mpcmd.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/parser-mpcmd.c 2012-05-17 14:38:00.000000000 +0000 @@ -308,7 +308,8 @@ * command line parsing), and --really-quiet suppresses messages printed * during normal options parsing. */ -int m_config_preparse_command_line(m_config_t *config, int argc, char **argv) +int m_config_preparse_command_line(m_config_t *config, int argc, char **argv, + int *verbose) { int ret = 0; @@ -330,6 +331,11 @@ // Ignore invalid options if (map_to_option(config, old_syntax, NULL, &opt, ¶m) < 0) continue; + // "-v" is handled here + if (!bstrcmp0(opt, "v")) { + (*verbose)++; + continue; + } // Set, non-pre-parse options will be ignored int r = m_config_set_option(config, opt, param, old_syntax); if (r < 0) diff -Nru mplayer2-2.0-426-gc32b3ed/parser-mpcmd.h mplayer2-2.0-554-gf63dbad/parser-mpcmd.h --- mplayer2-2.0-426-gc32b3ed/parser-mpcmd.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/parser-mpcmd.h 2012-05-17 14:38:00.000000000 +0000 @@ -24,6 +24,7 @@ play_tree_t *m_config_parse_mp_command_line(m_config_t *config, int argc, char **argv); -int m_config_preparse_command_line(m_config_t *config, int argc, char **argv); +int m_config_preparse_command_line(m_config_t *config, int argc, char **argv, + int *verbose); #endif /* MPLAYER_PARSER_MPCMD_H */ diff -Nru mplayer2-2.0-426-gc32b3ed/path.c mplayer2-2.0-554-gf63dbad/path.c --- mplayer2-2.0-426-gc32b3ed/path.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/path.c 2012-05-17 14:38:00.000000000 +0000 @@ -27,14 +27,15 @@ #include #include #include +#include +#include +#include #include "config.h" #include "mp_msg.h" #include "path.h" #ifdef CONFIG_MACOSX_BUNDLE #include -#include -#include #include #elif defined(__MINGW32__) #include @@ -45,7 +46,7 @@ #include "talloc.h" -#include "osdep/osdep.h" +#include "osdep/io.h" char *get_path(const char *filename){ char *homedir; @@ -55,6 +56,9 @@ #else static char *config_dir = "/.mplayer"; #endif +#if defined(__MINGW32__) || defined(__CYGWIN__) + char exedir[260]; +#endif int len; #ifdef CONFIG_MACOSX_BUNDLE struct stat dummy; @@ -72,33 +76,13 @@ /* Hack to get fonts etc. loaded outside of Cygwin environment. */ { int i,imax=0; - char exedir[260]; - GetModuleFileNameA(NULL, exedir, 260); - for (i=0; i< strlen(exedir); i++) + len = (int)GetModuleFileNameA(NULL, exedir, 260); + for (i=0; i < len; i++) if (exedir[i] =='\\') {exedir[i]='/'; imax=i;} exedir[imax]='\0'; homedir = exedir; } -#elif defined(__OS2__) - { - PPIB ppib; - char path[260]; - - // Get process info blocks - DosGetInfoBlocks(NULL, &ppib); - - // Get full path of the executable - DosQueryModuleName(ppib->pib_hmte, sizeof( path ), path); - - // Truncate name part including last backslash - *strrchr(path, '\\') = 0; - - // Convert backslash to slash - _fnslashify(path); - - homedir = path; - } #else return NULL; #endif @@ -232,3 +216,15 @@ return talloc_asprintf(talloc_ctx, "%.*s%s%.*s", BSTR_P(p1), have_separator ? "" : "/", BSTR_P(p2)); } + +bool mp_path_exists(const char *path) +{ + struct stat st; + return mp_stat(path, &st) == 0; +} + +bool mp_path_isdir(const char *path) +{ + struct stat st; + return mp_stat(path, &st) == 0 && S_ISDIR(st.st_mode); +} diff -Nru mplayer2-2.0-426-gc32b3ed/path.h mplayer2-2.0-554-gf63dbad/path.h --- mplayer2-2.0-426-gc32b3ed/path.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/path.h 2012-05-17 14:38:00.000000000 +0000 @@ -21,6 +21,7 @@ #ifndef MPLAYER_PATH_H #define MPLAYER_PATH_H +#include #include "bstr.h" extern char *codec_path; @@ -44,4 +45,7 @@ */ char *mp_path_join(void *talloc_ctx, struct bstr p1, struct bstr p2); +bool mp_path_exists(const char *path); +bool mp_path_isdir(const char *path); + #endif /* MPLAYER_PATH_H */ diff -Nru mplayer2-2.0-426-gc32b3ed/screenshot.c mplayer2-2.0-554-gf63dbad/screenshot.c --- mplayer2-2.0-426-gc32b3ed/screenshot.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/screenshot.c 2012-05-17 14:38:00.000000000 +0000 @@ -20,10 +20,7 @@ #include #include #include - -#include -#include -#include +#include #include #include @@ -33,6 +30,7 @@ #include "screenshot.h" #include "mp_core.h" #include "mp_msg.h" +#include "path.h" #include "libmpcodecs/img_format.h" #include "libmpcodecs/mp_image.h" #include "libmpcodecs/dec_video.h" @@ -46,6 +44,7 @@ #include "libvo/csputils.h" typedef struct screenshot_ctx { + AVFrame *pic; int full_window; int each_frame; int using_vf_screenshot; @@ -54,10 +53,22 @@ char fname[102]; } screenshot_ctx; +static int destroy_ctx(void *ptr) +{ + struct screenshot_ctx *ctx = ptr; + av_free(ctx->pic); + return 0; +} + static screenshot_ctx *screenshot_get_ctx(MPContext *mpctx) { - if (!mpctx->screenshot_ctx) - mpctx->screenshot_ctx = talloc_zero(mpctx, screenshot_ctx); + if (!mpctx->screenshot_ctx) { + struct screenshot_ctx *ctx = talloc_zero(mpctx, screenshot_ctx); + talloc_set_destructor(ctx, destroy_ctx); + ctx->pic = avcodec_alloc_frame(); + assert(ctx->pic); + mpctx->screenshot_ctx = ctx; + } return mpctx->screenshot_ctx; } @@ -68,36 +79,44 @@ void *outbuffer = NULL; int success = 0; - AVCodecContext *avctx = avcodec_alloc_context(); + struct AVCodec *png_codec = avcodec_find_encoder(CODEC_ID_PNG); + AVCodecContext *avctx = NULL; + if (!png_codec) + goto print_open_fail; + avctx = avcodec_alloc_context3(png_codec); if (!avctx) - goto error_exit; - - if (avcodec_open(avctx, avcodec_find_encoder(CODEC_ID_PNG))) { - mp_msg(MSGT_CPLAYER, MSGL_INFO, "Could not open libavcodec PNG encoder" - " for saving screenshot\n"); - goto error_exit; - } + goto print_open_fail; + avctx->time_base = AV_TIME_BASE_Q; avctx->width = image->width; avctx->height = image->height; avctx->pix_fmt = PIX_FMT_RGB24; avctx->compression_level = 0; + if (avcodec_open2(avctx, png_codec, NULL) < 0) { + print_open_fail: + mp_msg(MSGT_CPLAYER, MSGL_INFO, "Could not open libavcodec PNG encoder" + " for saving screenshot\n"); + goto error_exit; + } + size_t outbuffer_size = image->width * image->height * 3 * 2; outbuffer = malloc(outbuffer_size); if (!outbuffer) goto error_exit; - AVFrame pic; - pic.data[0] = image->planes[0]; - pic.linesize[0] = image->stride[0]; - int size = avcodec_encode_video(avctx, outbuffer, outbuffer_size, &pic); + AVFrame *pic = ctx->pic; + avcodec_get_frame_defaults(pic); + for (int n = 0; n < 4; n++) { + pic->data[n] = image->planes[n]; + pic->linesize[n] = image->stride[n]; + } + int size = avcodec_encode_video(avctx, outbuffer, outbuffer_size, pic); if (size < 1) goto error_exit; fp = fopen(fname, "wb"); if (fp == NULL) { - avcodec_close(avctx); mp_msg(MSGT_CPLAYER, MSGL_ERR, "\nPNG Error opening %s for writing!\n", fname); goto error_exit; @@ -113,6 +132,7 @@ error_exit: if (avctx) avcodec_close(avctx); + av_free(avctx); if (fp) fclose(fp); free(outbuffer); @@ -121,11 +141,7 @@ static int fexists(char *fname) { - struct stat dummy; - if (stat(fname, &dummy) == 0) - return 1; - else - return 0; + return mp_path_exists(fname); } static void gen_fname(screenshot_ctx *ctx) diff -Nru mplayer2-2.0-426-gc32b3ed/stream/ai_alsa.c mplayer2-2.0-554-gf63dbad/stream/ai_alsa.c --- mplayer2-2.0-426-gc32b3ed/stream/ai_alsa.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/stream/ai_alsa.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,184 +0,0 @@ -/* - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include -#include - -#include "config.h" - -#include -#include "audio_in.h" -#include "mp_msg.h" - -int ai_alsa_setup(audio_in_t *ai) -{ - snd_pcm_hw_params_t *params; - snd_pcm_sw_params_t *swparams; - int buffer_size; - int err; - unsigned int rate; - - snd_pcm_hw_params_alloca(¶ms); - snd_pcm_sw_params_alloca(&swparams); - - err = snd_pcm_hw_params_any(ai->alsa.handle, params); - if (err < 0) { - mp_tmsg(MSGT_TV, MSGL_ERR, "Broken configuration for this PCM: no configurations available.\n"); - return -1; - } - err = snd_pcm_hw_params_set_access(ai->alsa.handle, params, - SND_PCM_ACCESS_RW_INTERLEAVED); - if (err < 0) { - mp_tmsg(MSGT_TV, MSGL_ERR, "Access type not available.\n"); - return -1; - } - err = snd_pcm_hw_params_set_format(ai->alsa.handle, params, SND_PCM_FORMAT_S16_LE); - if (err < 0) { - mp_tmsg(MSGT_TV, MSGL_ERR, "Sample format not available.\n"); - return -1; - } - err = snd_pcm_hw_params_set_channels(ai->alsa.handle, params, ai->req_channels); - if (err < 0) { - ai->channels = snd_pcm_hw_params_get_channels(params); - mp_tmsg(MSGT_TV, MSGL_ERR, "Channel count not available - reverting to default: %d\n", - ai->channels); - } else { - ai->channels = ai->req_channels; - } - - err = snd_pcm_hw_params_set_rate_near(ai->alsa.handle, params, ai->req_samplerate, 0); - assert(err >= 0); - rate = err; - ai->samplerate = rate; - - ai->alsa.buffer_time = 1000000; - ai->alsa.buffer_time = snd_pcm_hw_params_set_buffer_time_near(ai->alsa.handle, params, - ai->alsa.buffer_time, 0); - assert(ai->alsa.buffer_time >= 0); - ai->alsa.period_time = ai->alsa.buffer_time / 4; - ai->alsa.period_time = snd_pcm_hw_params_set_period_time_near(ai->alsa.handle, params, - ai->alsa.period_time, 0); - assert(ai->alsa.period_time >= 0); - err = snd_pcm_hw_params(ai->alsa.handle, params); - if (err < 0) { - mp_tmsg(MSGT_TV, MSGL_ERR, "Unable to install hardware parameters: %s"); - snd_pcm_hw_params_dump(params, ai->alsa.log); - return -1; - } - ai->alsa.chunk_size = snd_pcm_hw_params_get_period_size(params, 0); - buffer_size = snd_pcm_hw_params_get_buffer_size(params); - if (ai->alsa.chunk_size == buffer_size) { - mp_tmsg(MSGT_TV, MSGL_ERR, "Can't use period equal to buffer size (%u == %lu)\n", ai->alsa.chunk_size, (long)buffer_size); - return -1; - } - snd_pcm_sw_params_current(ai->alsa.handle, swparams); - err = snd_pcm_sw_params_set_sleep_min(ai->alsa.handle, swparams,0); - assert(err >= 0); - err = snd_pcm_sw_params_set_avail_min(ai->alsa.handle, swparams, ai->alsa.chunk_size); - assert(err >= 0); - - err = snd_pcm_sw_params_set_start_threshold(ai->alsa.handle, swparams, 0); - assert(err >= 0); - err = snd_pcm_sw_params_set_stop_threshold(ai->alsa.handle, swparams, buffer_size); - assert(err >= 0); - - assert(err >= 0); - if (snd_pcm_sw_params(ai->alsa.handle, swparams) < 0) { - mp_tmsg(MSGT_TV, MSGL_ERR, "Unable to install software parameters:\n"); - snd_pcm_sw_params_dump(swparams, ai->alsa.log); - return -1; - } - - if (mp_msg_test(MSGT_TV, MSGL_V)) { - snd_pcm_dump(ai->alsa.handle, ai->alsa.log); - } - - ai->alsa.bits_per_sample = snd_pcm_format_physical_width(SND_PCM_FORMAT_S16_LE); - ai->alsa.bits_per_frame = ai->alsa.bits_per_sample * ai->channels; - ai->blocksize = ai->alsa.chunk_size * ai->alsa.bits_per_frame / 8; - ai->samplesize = ai->alsa.bits_per_sample; - ai->bytes_per_sample = ai->alsa.bits_per_sample/8; - - return 0; -} - -int ai_alsa_init(audio_in_t *ai) -{ - int err; - - err = snd_pcm_open(&ai->alsa.handle, ai->alsa.device, SND_PCM_STREAM_CAPTURE, 0); - if (err < 0) { - mp_tmsg(MSGT_TV, MSGL_ERR, "Error opening audio: %s\n", snd_strerror(err)); - return -1; - } - - err = snd_output_stdio_attach(&ai->alsa.log, stderr, 0); - - if (err < 0) { - return -1; - } - - err = ai_alsa_setup(ai); - - return err; -} - -#ifndef timersub -#define timersub(a, b, result) \ -do { \ - (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ - (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ - if ((result)->tv_usec < 0) { \ - --(result)->tv_sec; \ - (result)->tv_usec += 1000000; \ - } \ -} while (0) -#endif - -int ai_alsa_xrun(audio_in_t *ai) -{ - snd_pcm_status_t *status; - int res; - - snd_pcm_status_alloca(&status); - if ((res = snd_pcm_status(ai->alsa.handle, status))<0) { - mp_tmsg(MSGT_TV, MSGL_ERR, "ALSA status error: %s", snd_strerror(res)); - return -1; - } - if (snd_pcm_status_get_state(status) == SND_PCM_STATE_XRUN) { - struct timeval now, diff, tstamp; - gettimeofday(&now, 0); - snd_pcm_status_get_trigger_tstamp(status, &tstamp); - timersub(&now, &tstamp, &diff); - mp_tmsg(MSGT_TV, MSGL_ERR, "ALSA xrun!!! (at least %.3f ms long)\n", - diff.tv_sec * 1000 + diff.tv_usec / 1000.0); - if (mp_msg_test(MSGT_TV, MSGL_V)) { - mp_tmsg(MSGT_TV, MSGL_ERR, "ALSA Status:\n"); - snd_pcm_status_dump(status, ai->alsa.log); - } - if ((res = snd_pcm_prepare(ai->alsa.handle))<0) { - mp_tmsg(MSGT_TV, MSGL_ERR, "ALSA xrun: prepare error: %s", snd_strerror(res)); - return -1; - } - return 0; /* ok, data should be accepted again */ - } - mp_tmsg(MSGT_TV, MSGL_ERR, "ALSA read/write error"); - return -1; -} diff -Nru mplayer2-2.0-426-gc32b3ed/stream/asf_streaming.c mplayer2-2.0-554-gf63dbad/stream/asf_streaming.c --- mplayer2-2.0-426-gc32b3ed/stream/asf_streaming.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/stream/asf_streaming.c 2012-05-17 14:38:00.000000000 +0000 @@ -23,6 +23,8 @@ #include #include +#include + #include "config.h" #include "mp_msg.h" #include "options.h" @@ -41,8 +43,6 @@ #include "network.h" #include "tcp.h" -#include "ffmpeg_files/intreadwrite.h" - #include "libmpdemux/asfguid.h" extern int network_bandwidth; diff -Nru mplayer2-2.0-426-gc32b3ed/stream/cache2.c mplayer2-2.0-554-gf63dbad/stream/cache2.c --- mplayer2-2.0-426-gc32b3ed/stream/cache2.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/stream/cache2.c 2012-05-17 14:38:00.000000000 +0000 @@ -45,10 +45,6 @@ #if defined(__MINGW32__) #include static void ThreadProc( void *s ); -#elif defined(__OS2__) -#define INCL_DOS -#include -static void ThreadProc( void *s ); #elif defined(PTHREAD_CACHE) #include static void *ThreadProc(void *s); @@ -367,6 +363,7 @@ s->cache_data = NULL; } +#if FORKED_CACHE static void exit_sighandler(int x){ // close stream exit(0); @@ -374,6 +371,7 @@ static void dummy_sighandler(int x) { } +#endif /** * Main loop of the cache process or thread. @@ -451,8 +449,6 @@ s->stream=stream2; #if defined(__MINGW32__) stream->cache_pid = _beginthread( ThreadProc, 0, s ); -#elif defined(__OS2__) - stream->cache_pid = _beginthread( ThreadProc, NULL, 256 * 1024, s ); #else { pthread_t tid; @@ -497,7 +493,7 @@ } #if !FORKED_CACHE -#if defined(__MINGW32__) || defined(__OS2__) +#if defined(__MINGW32__) static void ThreadProc( void *s ){ cache_mainloop(s); _endthread(); diff -Nru mplayer2-2.0-426-gc32b3ed/stream/cookies.c mplayer2-2.0-554-gf63dbad/stream/cookies.c --- mplayer2-2.0-426-gc32b3ed/stream/cookies.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/stream/cookies.c 2012-05-17 14:38:00.000000000 +0000 @@ -31,6 +31,8 @@ #include #include +#include "osdep/io.h" + #include "cookies.h" #include "http.h" #include "mp_msg.h" diff -Nru mplayer2-2.0-426-gc32b3ed/stream/pnm.c mplayer2-2.0-554-gf63dbad/stream/pnm.c --- mplayer2-2.0-426-gc32b3ed/stream/pnm.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/stream/pnm.c 2012-05-17 14:38:00.000000000 +0000 @@ -23,8 +23,6 @@ * based upon code from joschka */ -#include "config.h" - #include #include #include @@ -35,6 +33,10 @@ #include #include #include + +#include + +#include "config.h" #if !HAVE_WINSOCK2_H #include //#include @@ -43,8 +45,6 @@ #include #endif -#include "ffmpeg_files/intreadwrite.h" - #include "stream.h" #include "libmpdemux/demuxer.h" #include "osdep/timer.h" diff -Nru mplayer2-2.0-426-gc32b3ed/stream/realrtsp/real.c mplayer2-2.0-554-gf63dbad/stream/realrtsp/real.c --- mplayer2-2.0-426-gc32b3ed/stream/realrtsp/real.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/stream/realrtsp/real.c 2012-05-17 14:38:00.000000000 +0000 @@ -30,18 +30,18 @@ #include #include +#include +#include +#include +#include +#include +#include + #include "config.h" -#include "libavutil/common.h" -#include "libavutil/attributes.h" #include "real.h" #include "asmrp.h" #include "sdpplin.h" #include "xbuffer.h" -#include "libavutil/md5.h" -#include "ffmpeg_files/intreadwrite.h" -#include "libavutil/base64.h" - -#include #include "stream/http.h" #include "mp_msg.h" diff -Nru mplayer2-2.0-426-gc32b3ed/stream/realrtsp/rmff.c mplayer2-2.0-554-gf63dbad/stream/realrtsp/rmff.c --- mplayer2-2.0-426-gc32b3ed/stream/realrtsp/rmff.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/stream/realrtsp/rmff.c 2012-05-17 14:38:00.000000000 +0000 @@ -26,10 +26,11 @@ * adopted from joschkas real tools */ +#include + #include "rmff.h" #include "xbuffer.h" #include "mp_msg.h" -#include "ffmpeg_files/intreadwrite.h" /* #define LOG diff -Nru mplayer2-2.0-426-gc32b3ed/stream/stream.c mplayer2-2.0-554-gf63dbad/stream/stream.c --- mplayer2-2.0-426-gc32b3ed/stream/stream.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/stream/stream.c 2012-05-17 14:38:00.000000000 +0000 @@ -30,6 +30,9 @@ #include #include +#include +#include + #include "talloc.h" #include "config.h" @@ -38,15 +41,12 @@ #include #endif -#include - #include "mp_msg.h" #include "osdep/shmem.h" #include "osdep/timer.h" #include "network.h" #include "stream.h" #include "libmpdemux/demuxer.h" -#include "ffmpeg_files/intreadwrite.h" #include "m_option.h" #include "m_struct.h" diff -Nru mplayer2-2.0-426-gc32b3ed/stream/stream_cdda.c mplayer2-2.0-554-gf63dbad/stream/stream_cdda.c --- mplayer2-2.0-426-gc32b3ed/stream/stream_cdda.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/stream/stream_cdda.c 2012-05-17 14:38:00.000000000 +0000 @@ -17,15 +17,13 @@ */ #include "config.h" -#ifndef CONFIG_LIBCDIO -#include -#include -#else #include #include -#endif +#include + #include #include +#include #include "talloc.h" @@ -40,442 +38,457 @@ #include "mp_msg.h" -#ifndef CD_FRAMESIZE_RAW -#define CD_FRAMESIZE_RAW CDIO_CD_FRAMESIZE_RAW -#endif - - extern char *cdrom_device; typedef struct { -#ifndef CONFIG_LIBCDIO - cdrom_drive* cd; - cdrom_paranoia* cdp; -#else - cdrom_drive_t* cd; - cdrom_paranoia_t* cdp; -#endif - int sector; - int start_sector; - int end_sector; - cd_info_t *cd_info; + cdrom_drive_t *cd; + cdrom_paranoia_t *cdp; + int sector; + int start_sector; + int end_sector; + cd_info_t *cd_info; } cdda_priv; static struct cdda_params { - int speed; - int paranoia_mode; - char* generic_dev; - int sector_size; - int search_overlap; - int toc_bias; - int toc_offset; - int no_skip; - char* device; - m_span_t span; + int speed; + int paranoia_mode; + char *generic_dev; + int sector_size; + int search_overlap; + int toc_bias; + int toc_offset; + int no_skip; + char *device; + m_span_t span; } cdda_dflts = { - -1, - 0, - NULL, - 0, - -1, - 0, - 0, - 0, - NULL, - { 0, 0 } + .search_overlap = -1, }; -#define ST_OFF(f) M_ST_OFF(struct cdda_params,f) +#define ST_OFF(f) M_ST_OFF(struct cdda_params, f) static const m_option_t cdda_params_fields[] = { - { "speed", ST_OFF(speed), CONF_TYPE_INT, M_OPT_RANGE,1,100, NULL }, - { "paranoia", ST_OFF(paranoia_mode), CONF_TYPE_INT,M_OPT_RANGE, 0, 2, NULL }, - { "generic-dev", ST_OFF(generic_dev), CONF_TYPE_STRING, 0, 0, 0, NULL }, - { "sector-size", ST_OFF(sector_size), CONF_TYPE_INT, M_OPT_RANGE,1,100, NULL }, - { "overlap", ST_OFF(search_overlap), CONF_TYPE_INT, M_OPT_RANGE,0,75, NULL }, - { "toc-bias", ST_OFF(toc_bias), CONF_TYPE_INT, 0, 0, 0, NULL }, - { "toc-offset", ST_OFF(toc_offset), CONF_TYPE_INT, 0, 0, 0, NULL }, - { "noskip", ST_OFF(no_skip), CONF_TYPE_FLAG, 0 , 0, 1, NULL }, - { "skip", ST_OFF(no_skip), CONF_TYPE_FLAG, 0 , 1, 0, NULL }, - { "device", ST_OFF(device), CONF_TYPE_STRING, 0, 0, 0, NULL }, - { "span", ST_OFF(span), CONF_TYPE_OBJ_PARAMS, 0, 0, 0, (void *)&m_span_params_def }, - /// For url parsing - { "hostname", ST_OFF(span), CONF_TYPE_OBJ_PARAMS, 0, 0, 0, (void *)&m_span_params_def }, - { "port", ST_OFF(speed), CONF_TYPE_INT, M_OPT_RANGE,1,100, NULL }, - { "filename", ST_OFF(device), CONF_TYPE_STRING, 0, 0, 0, NULL }, - {NULL, NULL, 0, 0, 0, 0, NULL} + {"speed", ST_OFF(speed), CONF_TYPE_INT, M_OPT_RANGE, 0, 100, NULL}, + {"paranoia", ST_OFF(paranoia_mode), CONF_TYPE_INT, M_OPT_RANGE, 0, 2, + NULL}, + {"generic-dev", ST_OFF(generic_dev), CONF_TYPE_STRING, 0, 0, 0, NULL}, + {"sector-size", ST_OFF(sector_size), CONF_TYPE_INT, M_OPT_RANGE, 1, 100, + NULL}, + {"overlap", ST_OFF(search_overlap), CONF_TYPE_INT, M_OPT_RANGE, -1, 75, + NULL}, + {"toc-bias", ST_OFF(toc_bias), CONF_TYPE_INT, 0, 0, 0, NULL}, + {"toc-offset", ST_OFF(toc_offset), CONF_TYPE_INT, 0, 0, 0, NULL}, + {"noskip", ST_OFF(no_skip), CONF_TYPE_FLAG, 0, 0, 1, NULL}, + {"skip", ST_OFF(no_skip), CONF_TYPE_FLAG, 0, 1, 0, NULL}, + {"device", ST_OFF(device), CONF_TYPE_STRING, 0, 0, 0, NULL}, + {"span", ST_OFF(span), CONF_TYPE_OBJ_PARAMS, 0, 0, 0, + (void *)&m_span_params_def}, + /// For url parsing + {"hostname", ST_OFF(span), CONF_TYPE_OBJ_PARAMS, 0, 0, 0, + (void *)&m_span_params_def}, + {"port", ST_OFF(speed), CONF_TYPE_INT, M_OPT_RANGE, 1, 100, NULL}, + {"filename", ST_OFF(device), CONF_TYPE_STRING, 0, 0, 0, NULL}, + {0} }; static const struct m_struct_st stream_opts = { - "cdda", - sizeof(struct cdda_params), - &cdda_dflts, - cdda_params_fields + "cdda", + sizeof(struct cdda_params), + &cdda_dflts, + cdda_params_fields }; /// We keep these options but now they set the defaults const m_option_t cdda_opts[] = { - { "speed", &cdda_dflts.speed, CONF_TYPE_INT, M_OPT_RANGE,1,100, NULL }, - { "paranoia", &cdda_dflts.paranoia_mode, CONF_TYPE_INT,M_OPT_RANGE, 0, 2, NULL }, - { "generic-dev", &cdda_dflts.generic_dev, CONF_TYPE_STRING, 0, 0, 0, NULL }, - { "sector-size", &cdda_dflts.sector_size, CONF_TYPE_INT, M_OPT_RANGE,1,100, NULL }, - { "overlap", &cdda_dflts.search_overlap, CONF_TYPE_INT, M_OPT_RANGE,0,75, NULL }, - { "toc-bias", &cdda_dflts.toc_bias, CONF_TYPE_INT, 0, 0, 0, NULL }, - { "toc-offset", &cdda_dflts.toc_offset, CONF_TYPE_INT, 0, 0, 0, NULL }, - { "noskip", &cdda_dflts.no_skip, CONF_TYPE_FLAG, 0 , 0, 1, NULL }, - { "skip", &cdda_dflts.no_skip, CONF_TYPE_FLAG, 0 , 1, 0, NULL }, - { "device", &cdda_dflts.device, CONF_TYPE_STRING, 0, 0, 0, NULL }, - { "span", &cdda_dflts.span, CONF_TYPE_OBJ_PARAMS, 0, 0, 0, (void *)&m_span_params_def }, - {NULL, NULL, 0, 0, 0, 0, NULL} + {"speed", &cdda_dflts.speed, CONF_TYPE_INT, M_OPT_RANGE, 1, 100, NULL}, + {"paranoia", &cdda_dflts.paranoia_mode, CONF_TYPE_INT, M_OPT_RANGE, 0, 2, + NULL}, + {"generic-dev", &cdda_dflts.generic_dev, CONF_TYPE_STRING, 0, 0, 0, NULL}, + {"sector-size", &cdda_dflts.sector_size, CONF_TYPE_INT, M_OPT_RANGE, 1, + 100, NULL}, + {"overlap", &cdda_dflts.search_overlap, CONF_TYPE_INT, M_OPT_RANGE, 0, 75, + NULL}, + {"toc-bias", &cdda_dflts.toc_bias, CONF_TYPE_INT, 0, 0, 0, NULL}, + {"toc-offset", &cdda_dflts.toc_offset, CONF_TYPE_INT, 0, 0, 0, NULL}, + {"noskip", &cdda_dflts.no_skip, CONF_TYPE_FLAG, 0, 0, 1, NULL}, + {"skip", &cdda_dflts.no_skip, CONF_TYPE_FLAG, 0, 1, 0, NULL}, + {"device", &cdda_dflts.device, CONF_TYPE_STRING, 0, 0, 0, NULL}, + {"span", &cdda_dflts.span, CONF_TYPE_OBJ_PARAMS, 0, 0, 0, + (void *)&m_span_params_def}, + {NULL, NULL, 0, 0, 0, 0, NULL} }; -#ifndef CONFIG_LIBCDIO -static void cdparanoia_callback(long inpos, int function) { -#else -static void cdparanoia_callback(long int inpos, paranoia_cb_mode_t function) { -#endif +static const char *cdtext_name[] = { + [CDTEXT_ARRANGER] = "Arranger", + [CDTEXT_COMPOSER] = "Composer", + [CDTEXT_MESSAGE] = "Message", + [CDTEXT_ISRC] = "ISRC", + [CDTEXT_PERFORMER] = "Performer", + [CDTEXT_SONGWRITER] = "Songwriter", + [CDTEXT_TITLE] = "Title", + [CDTEXT_UPC_EAN] = "UPC_EAN", +}; + +static bool print_cdtext(stream_t *s, int track) +{ + cdda_priv* p = (cdda_priv*)s->priv; + cdtext_t *text = cdio_get_cdtext(p->cd->p_cdio, track); + if (text) { + mp_msg(MSGT_SEEK, MSGL_INFO, "CD-Text (%s):\n", track ? "track" : "CD"); + for (int i = 0; i < sizeof(cdtext_name) / sizeof(cdtext_name[0]); i++) { + const char *name = cdtext_name[i]; + const char *value = cdtext_get_const(i, text); + if (name && value) + mp_msg(MSGT_SEEK, MSGL_INFO, " %s: '%s'\n", name, value); + } + return true; + } + return false; } -static int fill_buffer(stream_t* s, char* buffer, int max_len) { - cdda_priv* p = (cdda_priv*)s->priv; - cd_track_t *cd_track; - int16_t * buf; - int i; - - if((p->sector < p->start_sector) || (p->sector > p->end_sector)) { - s->eof = 1; - return 0; - } - - buf = paranoia_read(p->cdp,cdparanoia_callback); - if (!buf) - return 0; +static void print_track_info(stream_t *s, int track) +{ + cdda_priv* p = (cdda_priv*)s->priv; + cd_track_t *cd_track = cd_info_get_track(p->cd_info, track); + if( cd_track!=NULL ) { + mp_msg(MSGT_SEEK, MSGL_INFO, "\n%s\n", cd_track->name); + mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CDDA_TRACK=%d\n", + cd_track->track_nb); + } + if (print_cdtext(s, track)) { + // hack for term OSD overwriting the last line of CDTEXT + mp_msg(MSGT_SEEK, MSGL_INFO, "\n"); + } +} + +static void cdparanoia_callback(long int inpos, paranoia_cb_mode_t function) +{ +} + +static int fill_buffer(stream_t *s, char *buffer, int max_len) +{ + cdda_priv *p = (cdda_priv *)s->priv; + int16_t *buf; + int i; + + if ((p->sector < p->start_sector) || (p->sector > p->end_sector)) { + s->eof = 1; + return 0; + } + + buf = paranoia_read(p->cdp, cdparanoia_callback); + if (!buf) + return 0; #if HAVE_BIGENDIAN - for(i=0;isector++; - memcpy(buffer,buf,CD_FRAMESIZE_RAW); - - for(i=0;icd->tracks;i++){ - if(p->cd->disc_toc[i].dwStartSector==p->sector-1) { - cd_track = cd_info_get_track(p->cd_info, i+1); -//printf("Track %d, sector=%d\n", i, p->sector-1); - if( cd_track!=NULL ) { - mp_msg(MSGT_SEEK, MSGL_INFO, "\n%s\n", cd_track->name); - mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CDDA_TRACK=%d\n", cd_track->track_nb); - } - break; - } - } + p->sector++; + memcpy(buffer, buf, CDIO_CD_FRAMESIZE_RAW); + for (i = 0; i < p->cd->tracks; i++) { + if (p->cd->disc_toc[i].dwStartSector == p->sector - 1) { + print_track_info(s, i + 1); + break; + } + } - return CD_FRAMESIZE_RAW; + return CDIO_CD_FRAMESIZE_RAW; } -static int seek(stream_t* s,off_t newpos) { - cdda_priv* p = (cdda_priv*)s->priv; - cd_track_t *cd_track; - int sec; - int current_track=0, seeked_track=0; - int seek_to_track = 0; - int i; - - s->pos = newpos; - sec = s->pos/CD_FRAMESIZE_RAW; - if (s->pos < 0 || sec > p->end_sector) { - s->eof = 1; - return 0; - } - -//printf("pos: %d, sec: %d ## %d\n", (int)s->pos, (int)sec, CD_FRAMESIZE_RAW); -//printf("sector: %d new: %d\n", p->sector, sec ); - - for(i=0;icd->tracks;i++){ -// printf("trk #%d: %d .. %d\n",i,p->cd->disc_toc[i].dwStartSector,p->cd->disc_toc[i+1].dwStartSector); - if( p->sector>=p->cd->disc_toc[i].dwStartSector && p->sectorcd->disc_toc[i+1].dwStartSector ) { - current_track = i; - } - if( sec>=p->cd->disc_toc[i].dwStartSector && seccd->disc_toc[i+1].dwStartSector ) { - seeked_track = i; - seek_to_track = sec == p->cd->disc_toc[i].dwStartSector; - } - } -//printf("current: %d, seeked: %d\n", current_track, seeked_track); - if (current_track != seeked_track && !seek_to_track) { -//printf("Track %d, sector=%d\n", seeked_track, sec); - cd_track = cd_info_get_track(p->cd_info, seeked_track+1); - if( cd_track!=NULL ) { - mp_msg(MSGT_SEEK, MSGL_INFO, "\n%s\n", cd_track->name); - mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_CDDA_TRACK=%d\n", cd_track->track_nb); - } - - } -#if 0 - if(sec < p->start_sector) - sec = p->start_sector; - else if(sec > p->end_sector) - sec = p->end_sector; -#endif +static int seek(stream_t *s, off_t newpos) +{ + cdda_priv *p = (cdda_priv *)s->priv; + int sec; + int current_track = 0, seeked_track = 0; + int seek_to_track = 0; + int i; + + s->pos = newpos; + sec = s->pos / CDIO_CD_FRAMESIZE_RAW; + if (s->pos < 0 || sec > p->end_sector) { + s->eof = 1; + p->sector = p->end_sector + 1; + return 0; + } + + for (i = 0; i < p->cd->tracks; i++) { + if (p->sector >= p->cd->disc_toc[i].dwStartSector + && p->sector < p->cd->disc_toc[i + 1].dwStartSector) + current_track = i; + if (sec >= p->cd->disc_toc[i].dwStartSector + && sec < p->cd->disc_toc[i + 1].dwStartSector) + { + seeked_track = i; + seek_to_track = sec == p->cd->disc_toc[i].dwStartSector; + } + } + if (current_track != seeked_track && !seek_to_track) + print_track_info(s, seeked_track + 1); - p->sector = sec; -// s->pos = sec*CD_FRAMESIZE_RAW; + p->sector = sec; -//printf("seek: %d, sec: %d\n", (int)s->pos, sec); - paranoia_seek(p->cdp,sec,SEEK_SET); - return 1; + paranoia_seek(p->cdp, sec, SEEK_SET); + return 1; } -static void close_cdda(stream_t* s) { - cdda_priv* p = (cdda_priv*)s->priv; - paranoia_free(p->cdp); - cdda_close(p->cd); - cd_info_free(p->cd_info); - free(p); +static void close_cdda(stream_t *s) +{ + cdda_priv *p = (cdda_priv *)s->priv; + paranoia_free(p->cdp); + cdda_close(p->cd); + cd_info_free(p->cd_info); + free(p); } -static int get_track_by_sector(cdda_priv *p, unsigned int sector) { - int i; - for (i = p->cd->tracks; i >= 0 ; --i) - if (p->cd->disc_toc[i].dwStartSector <= sector) - break; - return i; +static int get_track_by_sector(cdda_priv *p, unsigned int sector) +{ + int i; + for (i = p->cd->tracks; i >= 0; --i) + if (p->cd->disc_toc[i].dwStartSector <= sector) + break; + return i; } -static int control(stream_t *stream, int cmd, void *arg) { - cdda_priv* p = stream->priv; - switch(cmd) { +static int control(stream_t *stream, int cmd, void *arg) +{ + cdda_priv *p = stream->priv; + switch (cmd) { case STREAM_CTRL_GET_NUM_CHAPTERS: { - int start_track = get_track_by_sector(p, p->start_sector); - int end_track = get_track_by_sector(p, p->end_sector); - *(unsigned int *)arg = end_track + 1 - start_track; - return STREAM_OK; + int start_track = get_track_by_sector(p, p->start_sector); + int end_track = get_track_by_sector(p, p->end_sector); + if (start_track == -1 || end_track == -1) + return STREAM_ERROR; + *(unsigned int *)arg = end_track + 1 - start_track; + return STREAM_OK; } case STREAM_CTRL_SEEK_TO_CHAPTER: { - int r; - unsigned int track = *(unsigned int *)arg; - int start_track = get_track_by_sector(p, p->start_sector); - int seek_sector; - track += start_track; - if (track >= p->cd->tracks) { - stream->eof = 1; - return STREAM_ERROR; - } - seek_sector = track <= 0 ? p->start_sector - : p->cd->disc_toc[track].dwStartSector; - r = seek(stream, seek_sector * CD_FRAMESIZE_RAW); - if (r) - return STREAM_OK; - break; + int r; + unsigned int track = *(unsigned int *)arg; + int start_track = get_track_by_sector(p, p->start_sector); + int end_track = get_track_by_sector(p, p->end_sector); + int seek_sector; + if (start_track == -1 || end_track == -1) + return STREAM_ERROR; + track += start_track; + if (track > end_track) { + seek(stream, (p->end_sector + 1) * CDIO_CD_FRAMESIZE_RAW); + // seeking beyond EOF should not be an error, + // the cache cannot handle changing stream pos and + // returning error. + return STREAM_OK; + } + seek_sector = track <= 0 ? p->start_sector + : p->cd->disc_toc[track].dwStartSector; + r = seek(stream, seek_sector * CDIO_CD_FRAMESIZE_RAW); + if (r) + return STREAM_OK; + break; } case STREAM_CTRL_GET_CURRENT_CHAPTER: { - int start_track = get_track_by_sector(p, p->start_sector); - int cur_track = get_track_by_sector(p, p->sector); - *(unsigned int *)arg = cur_track - start_track; - return STREAM_OK; + int start_track = get_track_by_sector(p, p->start_sector); + int cur_track = get_track_by_sector(p, p->sector); + if (start_track == -1 || cur_track == -1) + return STREAM_ERROR; + *(unsigned int *)arg = cur_track - start_track; + return STREAM_OK; + } } - } - return STREAM_UNSUPPORTED; + return STREAM_UNSUPPORTED; } -static int open_cdda(stream_t *st,int m, void* opts, int* file_format) { - struct cdda_params* p = (struct cdda_params*)opts; - int mode = p->paranoia_mode; - int offset = p->toc_offset; -#ifndef CONFIG_LIBCDIO - cdrom_drive* cdd = NULL; -#else - cdrom_drive_t* cdd = NULL; -#endif - cdda_priv* priv; - cd_info_t *cd_info,*cddb_info = NULL; - unsigned int audiolen=0; - int last_track; - int i; - char *xmcd_file = NULL; +static int open_cdda(stream_t *st, int m, void *opts, int *file_format) +{ + struct cdda_params *p = (struct cdda_params *)opts; + int mode = p->paranoia_mode; + int offset = p->toc_offset; + cdrom_drive_t *cdd = NULL; + cdda_priv *priv; + cd_info_t *cd_info, *cddb_info = NULL; + unsigned int audiolen = 0; + int last_track; + int i; + char *xmcd_file = NULL; - if(m != STREAM_READ) { - m_struct_free(&stream_opts,opts); - return STREAM_UNSUPPORTED; - } + if (m != STREAM_READ) { + m_struct_free(&stream_opts, opts); + return STREAM_UNSUPPORTED; + } - if(!p->device) { - if (cdrom_device) - p->device = talloc_strdup(NULL, cdrom_device); - else - p->device = talloc_strdup(NULL, DEFAULT_CDROM_DEVICE); - } + if (!p->device) { + if (cdrom_device) + p->device = talloc_strdup(NULL, cdrom_device); + else + p->device = talloc_strdup(NULL, DEFAULT_CDROM_DEVICE); + } #ifdef CONFIG_CDDB - // cdd_identify returns -1 if it cannot read the TOC, - // in which case there is no point in calling cddb_resolve - if(cdd_identify(p->device) >= 0 && strncmp(st->url,"cddb",4) == 0) { - i = cddb_resolve(p->device, &xmcd_file); - if(i == 0) { - cddb_info = cddb_parse_xmcd(xmcd_file); - free(xmcd_file); + // cdd_identify returns -1 if it cannot read the TOC, + // in which case there is no point in calling cddb_resolve + if (cdd_identify(p->device) >= 0 && strncmp(st->url, "cddb", 4) == 0) { + i = cddb_resolve(p->device, &xmcd_file); + if (i == 0) { + cddb_info = cddb_parse_xmcd(xmcd_file); + free(xmcd_file); + } } - } #endif -#ifndef CONFIG_LIBCDIO - if(p->generic_dev) - cdd = cdda_identify_scsi(p->generic_dev,p->device,0,NULL); - else -#endif #if defined(__NetBSD__) - cdd = cdda_identify_scsi(p->device,p->device,0,NULL); + cdd = cdda_identify_scsi(p->device, p->device, 0, NULL); #else - cdd = cdda_identify(p->device,0,NULL); + cdd = cdda_identify(p->device, 0, NULL); #endif - if(!cdd) { - mp_tmsg(MSGT_OPEN,MSGL_ERR,"Can't open CDDA device.\n"); - m_struct_free(&stream_opts,opts); - free(cddb_info); - return STREAM_ERROR; - } - - cdda_verbose_set(cdd, CDDA_MESSAGE_FORGETIT, CDDA_MESSAGE_FORGETIT); - - if(p->sector_size) { - cdd->nsectors = p->sector_size; -#ifndef CONFIG_LIBCDIO - cdd->bigbuff = p->sector_size * CD_FRAMESIZE_RAW; -#endif - } + if (!cdd) { + mp_tmsg(MSGT_OPEN, MSGL_ERR, "Can't open CDDA device.\n"); + m_struct_free(&stream_opts, opts); + free(cddb_info); + return STREAM_ERROR; + } - if(cdda_open(cdd) != 0) { - mp_tmsg(MSGT_OPEN,MSGL_ERR,"Can't open disc.\n"); - cdda_close(cdd); - m_struct_free(&stream_opts,opts); - free(cddb_info); - return STREAM_ERROR; - } - - cd_info = cd_info_new(); - mp_tmsg(MSGT_OPEN,MSGL_INFO,"Found audio CD with %d tracks.\n", (int)cdda_tracks(cdd)); - for(i=0;itracks;i++) { - char track_name[80]; - long sec=cdda_track_firstsector(cdd,i+1); - long off=cdda_track_lastsector(cdd,i+1)-sec+1; - - sprintf(track_name, "Track %d", i+1); - cd_info_add_track(cd_info, track_name, i+1, (unsigned int)(off/(60*75)), (unsigned int)((off/75)%60), (unsigned int)(off%75), sec, off ); - audiolen += off; - } - cd_info->min = (unsigned int)(audiolen/(60*75)); - cd_info->sec = (unsigned int)((audiolen/75)%60); - cd_info->msec = (unsigned int)(audiolen%75); - - priv = malloc(sizeof(cdda_priv)); - memset(priv, 0, sizeof(cdda_priv)); - priv->cd = cdd; - priv->cd_info = cd_info; + cdda_verbose_set(cdd, CDDA_MESSAGE_FORGETIT, CDDA_MESSAGE_FORGETIT); - if(p->toc_bias) - offset -= cdda_track_firstsector(cdd,1); + if (p->sector_size) + cdd->nsectors = p->sector_size; - if(offset) { - int i; - for(i = 0 ; i < cdd->tracks + 1 ; i++) - cdd->disc_toc[i].dwStartSector += offset; - } - - if(p->speed) - cdda_speed_set(cdd,p->speed); - - last_track = cdda_tracks(cdd); - if (p->span.start > last_track) p->span.start = last_track; - if (p->span.end < p->span.start) p->span.end = p->span.start; - if (p->span.end > last_track) p->span.end = last_track; - if(p->span.start) - priv->start_sector = cdda_track_firstsector(cdd,p->span.start); - else - priv->start_sector = cdda_disc_firstsector(cdd); - - if(p->span.end) { - priv->end_sector = cdda_track_lastsector(cdd,p->span.end); - } else - priv->end_sector = cdda_disc_lastsector(cdd); - - priv->cdp = paranoia_init(cdd); - if(priv->cdp == NULL) { - cdda_close(cdd); - free(priv); - cd_info_free(cd_info); - m_struct_free(&stream_opts,opts); - free(cddb_info); - return STREAM_ERROR; - } - - if(mode == 0) - mode = PARANOIA_MODE_DISABLE; - else if(mode == 1) - mode = PARANOIA_MODE_OVERLAP; - else - mode = PARANOIA_MODE_FULL; - - if(p->no_skip) - mode |= PARANOIA_MODE_NEVERSKIP; -#ifndef CONFIG_LIBCDIO - // HACK against libcdparanoia's stupid caching model that - // queues up a huge number of requests leading to stuttering - paranoia_cachemodel_size(priv->cdp, 24); - paranoia_modeset(cdd, mode); + if (cdda_open(cdd) != 0) { + mp_tmsg(MSGT_OPEN, MSGL_ERR, "Can't open disc.\n"); + cdda_close(cdd); + m_struct_free(&stream_opts, opts); + free(cddb_info); + return STREAM_ERROR; + } - if(p->search_overlap >= 0) - paranoia_overlapset(cdd,p->search_overlap); -#else - paranoia_modeset(priv->cdp, mode); + cd_info = cd_info_new(); + mp_tmsg(MSGT_OPEN, MSGL_INFO, "Found audio CD with %d tracks.\n", + (int)cdda_tracks(cdd)); + for (i = 0; i < cdd->tracks; i++) { + char track_name[80]; + long sec = cdda_track_firstsector(cdd, i + 1); + long off = cdda_track_lastsector(cdd, i + 1) - sec + 1; + + sprintf(track_name, "Track %d", i + 1); + cd_info_add_track(cd_info, track_name, i + 1, + (unsigned int)(off / (60 * 75)), + (unsigned int)((off / 75) % 60), + (unsigned int)(off % 75), sec, off); + audiolen += off; + } + cd_info->min = (unsigned int)(audiolen / (60 * 75)); + cd_info->sec = (unsigned int)((audiolen / 75) % 60); + cd_info->msec = (unsigned int)(audiolen % 75); + + priv = malloc(sizeof(cdda_priv)); + memset(priv, 0, sizeof(cdda_priv)); + priv->cd = cdd; + priv->cd_info = cd_info; + + if (p->toc_bias) + offset -= cdda_track_firstsector(cdd, 1); + + if (offset) { + int i; + for (i = 0; i < cdd->tracks + 1; i++) + cdd->disc_toc[i].dwStartSector += offset; + } - if(p->search_overlap >= 0) - paranoia_overlapset(priv->cdp,p->search_overlap); -#endif + if (p->speed > 0) + cdda_speed_set(cdd, p->speed); + + last_track = cdda_tracks(cdd); + if (p->span.start > last_track) + p->span.start = last_track; + if (p->span.end < p->span.start) + p->span.end = p->span.start; + if (p->span.end > last_track) + p->span.end = last_track; + if (p->span.start) + priv->start_sector = cdda_track_firstsector(cdd, p->span.start); + else + priv->start_sector = cdda_disc_firstsector(cdd); + + if (p->span.end) + priv->end_sector = cdda_track_lastsector(cdd, p->span.end); + else + priv->end_sector = cdda_disc_lastsector(cdd); + + priv->cdp = paranoia_init(cdd); + if (priv->cdp == NULL) { + cdda_close(cdd); + free(priv); + cd_info_free(cd_info); + m_struct_free(&stream_opts, opts); + free(cddb_info); + return STREAM_ERROR; + } + + if (mode == 0) + mode = PARANOIA_MODE_DISABLE; + else if (mode == 1) + mode = PARANOIA_MODE_OVERLAP; + else + mode = PARANOIA_MODE_FULL; + + if (p->no_skip) + mode |= PARANOIA_MODE_NEVERSKIP; + else + mode &= ~PARANOIA_MODE_NEVERSKIP; + + if (p->search_overlap > 0) + mode |= PARANOIA_MODE_OVERLAP; + else if (p->search_overlap == 0) + mode &= ~PARANOIA_MODE_OVERLAP; + + paranoia_modeset(priv->cdp, mode); - paranoia_seek(priv->cdp,priv->start_sector,SEEK_SET); - priv->sector = priv->start_sector; + if (p->search_overlap > 0) + paranoia_overlapset(priv->cdp, p->search_overlap); + + paranoia_seek(priv->cdp, priv->start_sector, SEEK_SET); + priv->sector = priv->start_sector; #ifdef CONFIG_CDDB - if(cddb_info) { - cd_info_free(cd_info); - priv->cd_info = cddb_info; - cd_info_debug( cddb_info ); - } + if (cddb_info) { + cd_info_free(cd_info); + priv->cd_info = cddb_info; + cd_info_debug(cddb_info); + } #endif - st->priv = priv; - st->start_pos = priv->start_sector*CD_FRAMESIZE_RAW; - st->end_pos = (priv->end_sector + 1) * CD_FRAMESIZE_RAW; - st->type = STREAMTYPE_CDDA; - st->sector_size = CD_FRAMESIZE_RAW; - - st->fill_buffer = fill_buffer; - st->seek = seek; - st->control = control; - st->close = close_cdda; + st->priv = priv; + st->start_pos = priv->start_sector * CDIO_CD_FRAMESIZE_RAW; + st->end_pos = (priv->end_sector + 1) * CDIO_CD_FRAMESIZE_RAW; + st->type = STREAMTYPE_CDDA; + st->sector_size = CDIO_CD_FRAMESIZE_RAW; + + st->fill_buffer = fill_buffer; + st->seek = seek; + st->control = control; + st->close = close_cdda; + + *file_format = DEMUXER_TYPE_RAWAUDIO; - *file_format = DEMUXER_TYPE_RAWAUDIO; + m_struct_free(&stream_opts, opts); - m_struct_free(&stream_opts,opts); + print_cdtext(st, 0); - return STREAM_OK; + return STREAM_OK; } const stream_info_t stream_info_cdda = { - "CDDA", - "cdda", - "Albeu", - "", - open_cdda, - { "cdda", + "CDDA", + "cdda", + "Albeu", + "", + open_cdda, + {"cdda", #ifdef CONFIG_CDDB - "cddb", + "cddb", #endif - NULL }, - &stream_opts, - 1 // Urls are an option string + NULL }, + &stream_opts, + .opts_url = 1, }; diff -Nru mplayer2-2.0-426-gc32b3ed/stream/stream_cddb.c mplayer2-2.0-554-gf63dbad/stream/stream_cddb.c --- mplayer2-2.0-426-gc32b3ed/stream/stream_cddb.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/stream/stream_cddb.c 2012-05-17 14:38:00.000000000 +0000 @@ -36,11 +36,8 @@ #include #include #include +#include "osdep/io.h" #if defined(__MINGW32__) || defined(__CYGWIN__) -#ifdef __MINGW32__ -#include -#define mkdir(a,b) mkdir(a) -#endif #include #if HAVE_WINSOCK2_H #include @@ -53,6 +50,7 @@ #include #include "mp_msg.h" +#include "path.h" #if defined(__linux__) #include @@ -68,8 +66,6 @@ #include "mpbswap.h" #endif -#include "osdep/osdep.h" - #include "cdd.h" #include "mpcommon.h" #include "stream.h" @@ -128,78 +124,6 @@ } CloseHandle(drive); -#elif defined(__OS2__) - UCHAR auchParamDisk[4] = {'C', 'D', '0', '1'}; - - struct { - BYTE bFirstTrack; - BYTE bLastTrack; - BYTE bLeadOutF; - BYTE bLeadOutS; - BYTE bLeadOutM; - BYTE bLeadOutReserved; - } __attribute__((packed)) sDataDisk; - - struct { - UCHAR auchSign[4]; - BYTE bTrack; - } __attribute__((packed)) sParamTrack = {{'C', 'D', '0', '1'},}; - - struct { - BYTE bStartF; - BYTE bStartS; - BYTE bStartM; - BYTE bStartReserved; - BYTE bControlInfo; - } __attribute__((packed)) sDataTrack; - - HFILE hcd; - ULONG ulAction; - ULONG ulParamLen; - ULONG ulDataLen; - ULONG rc; - - rc = DosOpen(dev, &hcd, &ulAction, 0, FILE_NORMAL, - OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW, - OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE | OPEN_FLAGS_DASD, - NULL); - if (rc) { - mp_tmsg(MSGT_OPEN, MSGL_ERR, "Failed to read TOC.\n"); - return -1; - } - - rc = DosDevIOCtl(hcd, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIODISK, - auchParamDisk, sizeof(auchParamDisk), &ulParamLen, - &sDataDisk, sizeof(sDataDisk), &ulDataLen); - if (!rc) { - first = sDataDisk.bFirstTrack - 1; - last = sDataDisk.bLastTrack; - for (i = first; i <= last; i++) { - if (i == last) { - sDataTrack.bStartM = sDataDisk.bLeadOutM; - sDataTrack.bStartS = sDataDisk.bLeadOutS; - sDataTrack.bStartF = sDataDisk.bLeadOutF; - } else { - sParamTrack.bTrack = i + 1; - rc = DosDevIOCtl(hcd, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIOTRACK, - &sParamTrack, sizeof(sParamTrack), &ulParamLen, - &sDataTrack, sizeof(sDataTrack), &ulDataLen); - if (rc) - break; - } - - cdtoc[i].min = sDataTrack.bStartM; - cdtoc[i].sec = sDataTrack.bStartS; - cdtoc[i].frame = sDataTrack.bStartF; - } - } - - DosClose(hcd); - - if (rc) { - mp_tmsg(MSGT_OPEN, MSGL_ERR, "Failed to read TOC.\n"); - return -1; - } #else int drive; drive = open(dev, O_RDONLY | O_NONBLOCK); @@ -472,7 +396,6 @@ static int cddb_write_cache(cddb_data_t *cddb_data) { // We have the file, save it for cache. - struct stat file_stat; char file_name[100]; int file_fd, ret; int wrote = 0; @@ -481,8 +404,7 @@ return -1; // Check if the CDDB cache dir exist - ret = stat(cddb_data->cache_dir, &file_stat); - if (ret < 0) { + if (!mp_path_exists(cddb_data->cache_dir)) { // Directory not present, create it. ret = mkdir(cddb_data->cache_dir, 0755); #ifdef __MINGW32__ diff -Nru mplayer2-2.0-426-gc32b3ed/stream/stream_dvd_common.c mplayer2-2.0-554-gf63dbad/stream/stream_dvd_common.c --- mplayer2-2.0-426-gc32b3ed/stream/stream_dvd_common.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/stream/stream_dvd_common.c 2012-05-17 14:38:00.000000000 +0000 @@ -16,13 +16,17 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "config.h" #include #include #include #include #include +#include + +#include "config.h" + #include + #ifdef __FreeBSD__ #include #endif @@ -37,7 +41,6 @@ #include "mp_msg.h" #include "stream_dvd_common.h" -#include "ffmpeg_files/intreadwrite.h" const char * const dvd_audio_stream_types[8] = { "ac3","unknown","mpeg1","mpeg2ext","lpcm","unknown","dts" }; const char * const dvd_audio_stream_channels[6] = { "mono", "stereo", "unknown", "unknown", "5.1/6.1", "5.1" }; diff -Nru mplayer2-2.0-426-gc32b3ed/stream/stream_ffmpeg.c mplayer2-2.0-554-gf63dbad/stream/stream_ffmpeg.c --- mplayer2-2.0-426-gc32b3ed/stream/stream_ffmpeg.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/stream/stream_ffmpeg.c 2012-05-17 14:38:00.000000000 +0000 @@ -56,7 +56,7 @@ static int control(stream_t *s, int cmd, void *arg) { - AVIOContext *avio = avio; + AVIOContext *avio = s->priv; int64_t size, ts; double pts; switch(cmd) { @@ -101,9 +101,9 @@ int dummy; if (mode == STREAM_READ) - flags = URL_RDONLY; + flags = AVIO_FLAG_READ; else if (mode == STREAM_WRITE) - flags = URL_WRONLY; + flags = AVIO_FLAG_WRITE; else { mp_msg(MSGT_OPEN, MSGL_ERR, "[ffmpeg] Unknown open mode %d\n", mode); res = STREAM_UNSUPPORTED; diff -Nru mplayer2-2.0-426-gc32b3ed/stream/stream_file.c mplayer2-2.0-554-gf63dbad/stream/stream_file.c --- mplayer2-2.0-426-gc32b3ed/stream/stream_file.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/stream/stream_file.c 2012-05-17 14:38:00.000000000 +0000 @@ -24,6 +24,8 @@ #include #include +#include "osdep/io.h" + #include "mp_msg.h" #include "stream.h" #include "m_option.h" diff -Nru mplayer2-2.0-426-gc32b3ed/stream/stream_pvr.c mplayer2-2.0-554-gf63dbad/stream/stream_pvr.c --- mplayer2-2.0-426-gc32b3ed/stream/stream_pvr.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/stream/stream_pvr.c 2012-05-17 14:38:00.000000000 +0000 @@ -89,7 +89,7 @@ char *pvr_param_stream_type = NULL; typedef struct station_elem_s { - char name[8]; + char name[PVR_STATION_NAME_SIZE]; int freq; char station[PVR_STATION_NAME_SIZE]; int enabled; diff -Nru mplayer2-2.0-426-gc32b3ed/stream/stream_vcd.c mplayer2-2.0-554-gf63dbad/stream/stream_vcd.c --- mplayer2-2.0-426-gc32b3ed/stream/stream_vcd.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/stream/stream_vcd.c 2012-05-17 14:38:00.000000000 +0000 @@ -22,8 +22,6 @@ #include #endif -#include "osdep/osdep.h" - #include "mp_msg.h" #include "stream.h" #include "m_option.h" @@ -37,14 +35,14 @@ #endif #include +#include "talloc.h" + #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) #include "vcd_read_fbsd.h" #elif defined(__APPLE__) #include "vcd_read_darwin.h" #elif defined(__MINGW32__) || defined(__CYGWIN__) #include "vcd_read_win32.h" -#elif defined(__OS2__) -#include "vcd_read_os2.h" #else #include "vcd_read.h" #endif @@ -139,12 +137,6 @@ HANDLE hd; char device[] = "\\\\.\\?:"; #endif -#if defined(__OS2__) - char device[] = "X:"; - HFILE hcd; - ULONG ulAction; - ULONG rc; -#endif if(mode != STREAM_READ #if defined(__MINGW32__) || defined(__CYGWIN__) @@ -157,9 +149,9 @@ if (!p->device) { if(cdrom_device) - p->device = strdup(cdrom_device); + p->device = talloc_strdup(NULL, cdrom_device); else - p->device = strdup(DEFAULT_CDROM_DEVICE); + p->device = talloc_strdup(NULL, DEFAULT_CDROM_DEVICE); } #if defined(__MINGW32__) || defined(__CYGWIN__) @@ -168,13 +160,6 @@ hd = CreateFile(device, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL); f = _open_osfhandle((long)hd, _O_RDONLY); -#elif defined(__OS2__) - device[0] = p->device[0]; - rc = DosOpen(device, &hcd, &ulAction, 0, FILE_NORMAL, - OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW, - OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE | OPEN_FLAGS_DASD, - NULL); - f = rc ? -1 : hcd; #else f=open(p->device,O_RDONLY); #endif diff -Nru mplayer2-2.0-426-gc32b3ed/stream/stream_vstream.c mplayer2-2.0-554-gf63dbad/stream/stream_vstream.c --- mplayer2-2.0-426-gc32b3ed/stream/stream_vstream.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/stream/stream_vstream.c 2012-05-17 14:38:00.000000000 +0000 @@ -56,7 +56,7 @@ va_start(va, format); vsnprintf(buf, 1024, format, va); va_end(va); - mp_msg(MSGT_STREAM, MSGL_ERR, buf); + mp_msg(MSGT_STREAM, MSGL_ERR, "%s", buf); } static struct stream_priv_s { @@ -152,7 +152,8 @@ stream->start_pos = 0; stream->end_pos = vstream_streamsize(); - mp_msg(MSGT_OPEN, MSGL_DBG2, "Tivo stream size is %d\n", stream->end_pos); + mp_msg(MSGT_OPEN, MSGL_DBG2, "Tivo stream size is %lld\n", + (long long)stream->end_pos); stream->priv = p; stream->fill_buffer = fill_buffer; diff -Nru mplayer2-2.0-426-gc32b3ed/stream/vcd_read.h mplayer2-2.0-554-gf63dbad/stream/vcd_read.h --- mplayer2-2.0-426-gc32b3ed/stream/vcd_read.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/stream/vcd_read.h 2012-05-17 14:38:00.000000000 +0000 @@ -23,9 +23,11 @@ #include #include #include + +#include + #include "mp_msg.h" #include "stream.h" -#include "ffmpeg_files/intreadwrite.h" //=================== VideoCD ========================== #if defined(__linux__) || defined(sun) || defined(__bsdi__) diff -Nru mplayer2-2.0-426-gc32b3ed/stream/vcd_read_fbsd.h mplayer2-2.0-554-gf63dbad/stream/vcd_read_fbsd.h --- mplayer2-2.0-426-gc32b3ed/stream/vcd_read_fbsd.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/stream/vcd_read_fbsd.h 2012-05-17 14:38:00.000000000 +0000 @@ -24,9 +24,11 @@ #include #include #include -#include "ffmpeg_files/intreadwrite.h" #include #include + +#include + #if defined(__NetBSD__) || defined(__OpenBSD__) #define VCD_NETBSD 1 #endif diff -Nru mplayer2-2.0-426-gc32b3ed/stream/vcd_read_os2.h mplayer2-2.0-554-gf63dbad/stream/vcd_read_os2.h --- mplayer2-2.0-426-gc32b3ed/stream/vcd_read_os2.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/stream/vcd_read_os2.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,242 +0,0 @@ -/* - * implementation of VCD IO for OS/2 - * - * Copyright (c) 2009 KO Myung-Hun (komh@chollian.net) - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPLAYER_VCD_READ_OS2_H -#define MPLAYER_VCD_READ_OS2_H - -#include "mp_msg.h" - -struct __attribute__((packed)) msf { - BYTE bFrame; - BYTE bSecond; - BYTE bMinute; - BYTE bReserved; -}; - -typedef struct { - HFILE hcd; - struct msf msfCurrent; - int iFirstTrack; - int iLastTrack; - struct msf msfLeadOut; - BYTE abVCDSector[VCD_SECTOR_SIZE]; -} mp_vcd_priv_t; - -static inline void vcd_set_msf(mp_vcd_priv_t *vcd, unsigned sect) -{ - sect += 150; - vcd->msfCurrent.bFrame = sect % 75; - sect = sect / 75; - vcd->msfCurrent.bSecond = sect % 60; - sect = sect / 60; - vcd->msfCurrent.bMinute = sect; -} - -static inline unsigned vcd_get_msf(mp_vcd_priv_t *vcd) -{ - return vcd->msfCurrent.bFrame + - (vcd->msfCurrent.bSecond + vcd->msfCurrent.bMinute * 60) * 75 - 150; -} - -static int vcd_seek_to_track(mp_vcd_priv_t *vcd, int track) -{ - struct { - UCHAR auchSign[4]; - BYTE bTrack; - } __attribute__((packed)) sParam = {{'C', 'D', '0', '1'},}; - - struct { - struct msf msfStart; - BYTE bControlInfo; - } __attribute__((packed)) sData; - - ULONG ulParamLen; - ULONG ulDataLen; - ULONG rc; - - sParam.bTrack = track; - rc = DosDevIOCtl(vcd->hcd, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIOTRACK, - &sParam, sizeof(sParam), &ulParamLen, - &sData, sizeof(sData), &ulDataLen); - if (rc) { - mp_msg(MSGT_STREAM, MSGL_ERR, "DosDevIOCtl(GETAUDIOTRACK) = 0x%lx\n", rc); - return -1; - } - - vcd->msfCurrent = sData.msfStart; - - return VCD_SECTOR_DATA * vcd_get_msf(vcd); -} - -static int vcd_get_track_end(mp_vcd_priv_t *vcd, int track) -{ - if (track < vcd->iLastTrack) - return vcd_seek_to_track(vcd, track + 1); - - vcd->msfCurrent = vcd->msfLeadOut; - - return VCD_SECTOR_DATA * vcd_get_msf(vcd); -} - -static mp_vcd_priv_t *vcd_read_toc(int fd) -{ - mp_vcd_priv_t *vcd; - - UCHAR auchParamDisk[4] = {'C', 'D', '0', '1'}; - - struct { - BYTE bFirstTrack; - BYTE bLastTrack; - struct msf msfLeadOut; - } __attribute__((packed)) sDataDisk; - - struct { - UCHAR auchSign[4]; - BYTE bTrack; - } __attribute__((packed)) sParamTrack = {{'C', 'D', '0', '1'},}; - - struct { - struct msf msfStart; - BYTE bControlInfo; - } __attribute__((packed)) sDataTrack; - - ULONG ulParamLen; - ULONG ulDataLen; - ULONG rc; - int i, iMinute = 0, iSecond = 0, iFrame = 0; - - rc = DosDevIOCtl(fd, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIODISK, - auchParamDisk, sizeof(auchParamDisk), &ulParamLen, - &sDataDisk, sizeof(sDataDisk), &ulDataLen); - if (rc) { - mp_msg(MSGT_OPEN, MSGL_ERR, "DosDevIOCtl(GETAUDIODISK) = 0x%lx\n", rc); - return NULL; - } - - mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_START_TRACK=%d\n", sDataDisk.bFirstTrack); - mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_END_TRACK=%d\n", sDataDisk.bLastTrack); - - for (i = sDataDisk.bFirstTrack; i <= sDataDisk.bLastTrack + 1; i++) { - if (i <= sDataDisk.bLastTrack) { - sParamTrack.bTrack = i; - rc = DosDevIOCtl(fd, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIOTRACK, - &sParamTrack, sizeof(sParamTrack), &ulParamLen, - &sDataTrack, sizeof(sDataTrack), &ulDataLen); - if (rc) { - mp_msg(MSGT_OPEN, MSGL_ERR, "DosDevIOCtl(GETAUDIOTRACK) = 0x%lx\n", rc); - return NULL; - } - - mp_msg(MSGT_OPEN, MSGL_INFO, "track %02d: adr=%d ctrl=%d %02d:%02d:%02d\n", - i, - sDataTrack.bControlInfo & 0x0F, - sDataTrack.bControlInfo >> 4, - sDataTrack.msfStart.bMinute, - sDataTrack.msfStart.bSecond, - sDataTrack.msfStart.bFrame); - } else - sDataTrack.msfStart = sDataDisk.msfLeadOut; - - if (mp_msg_test(MSGT_IDENTIFY, MSGL_INFO)) { - if (i > sDataDisk.bFirstTrack) { - iMinute = sDataTrack.msfStart.bMinute - iMinute; - iSecond = sDataTrack.msfStart.bSecond - iSecond; - iFrame = sDataTrack.msfStart.bFrame - iFrame; - if (iFrame < 0) { - iFrame += 75; - iSecond--; - } - if (iSecond < 0) { - iSecond += 60; - iMinute--; - } - mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VCD_TRACK_%d_MSF=%02d:%02d:%02d\n", - i - 1, iMinute, iSecond, iFrame); - } - - iMinute = sDataTrack.msfStart.bMinute; - iSecond = sDataTrack.msfStart.bSecond; - iFrame = sDataTrack.msfStart.bFrame; - } - } - - vcd = calloc(1, sizeof(mp_vcd_priv_t)); - vcd->hcd = fd; - vcd->iFirstTrack = sDataDisk.bFirstTrack; - vcd->iLastTrack = sDataDisk.bLastTrack; - vcd->msfLeadOut = sDataDisk.msfLeadOut; - - return vcd; -} - -static int vcd_end_track(mp_vcd_priv_t* vcd) -{ - return vcd->iLastTrack; -} - -static int vcd_read(mp_vcd_priv_t *vcd, char *mem) -{ - struct { - UCHAR auchSign[4]; - BYTE bAddrMode; - USHORT usSectors; - struct msf msfStart; - BYTE bReserved; - BYTE bInterleavedSize; - } __attribute__((packed)) sParam = {{'C', 'D', '0', '1'}, 1, 1,}; - - ULONG ulParamLen; - ULONG ulDataLen; - ULONG rc; - - /* lead-out ? */ - if (vcd->msfCurrent.bMinute == vcd->msfLeadOut.bMinute && - vcd->msfCurrent.bSecond == vcd->msfLeadOut.bSecond && - vcd->msfCurrent.bFrame == vcd->msfLeadOut.bFrame) - return 0; - - sParam.msfStart = vcd->msfCurrent; - rc = DosDevIOCtl(vcd->hcd, IOCTL_CDROMDISK, CDROMDISK_READLONG, - &sParam, sizeof(sParam), &ulParamLen, - vcd->abVCDSector, sizeof(vcd->abVCDSector), &ulDataLen); - if (rc) { - mp_msg(MSGT_STREAM, MSGL_ERR, "DosDevIOCtl(READLONG) = 0x%lx\n", rc); - return 0; - } - - memcpy(mem, &vcd->abVCDSector[VCD_SECTOR_OFFS], VCD_SECTOR_DATA); - - vcd->msfCurrent.bFrame++; - if (vcd->msfCurrent.bFrame == 75) { - vcd->msfCurrent.bFrame = 0; - vcd->msfCurrent.bSecond++; - if (vcd->msfCurrent.bSecond == 60) { - vcd->msfCurrent.bSecond = 0; - vcd->msfCurrent.bMinute++; - } - } - - return VCD_SECTOR_DATA; -} - -#endif /* MPLAYER_VCD_READ_OS2_H */ - diff -Nru mplayer2-2.0-426-gc32b3ed/sub/ass_mp.c mplayer2-2.0-554-gf63dbad/sub/ass_mp.c --- mplayer2-2.0-426-gc32b3ed/sub/ass_mp.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/sub/ass_mp.c 2012-05-17 14:38:00.000000000 +0000 @@ -266,8 +266,13 @@ path = strdup(sub_font_name); else if (font_fontconfig < 0 && font_name) path = strdup(font_name); - else + else { path = get_path("subfont.ttf"); + if (!mp_path_exists(path)) { + free(path); + path = NULL; + } + } if (font_fontconfig >= 0 && sub_font_name) family = strdup(sub_font_name); else if (font_fontconfig >= 0 && font_name) diff -Nru mplayer2-2.0-426-gc32b3ed/sub/av_sub.c mplayer2-2.0-554-gf63dbad/sub/av_sub.c --- mplayer2-2.0-426-gc32b3ed/sub/av_sub.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/sub/av_sub.c 2012-05-17 14:38:00.000000000 +0000 @@ -63,9 +63,14 @@ pkt.convergence_duration = duration * 1000; if (!ctx) { AVCodec *sub_codec; - ctx = avcodec_alloc_context(); sub_codec = avcodec_find_decoder(cid); - if (!ctx || !sub_codec || avcodec_open(ctx, sub_codec) < 0) { + if (!sub_codec) + goto error; + ctx = avcodec_alloc_context3(sub_codec); + if (!ctx) + goto error; + if (avcodec_open2(ctx, sub_codec, NULL) < 0) { + error: mp_msg(MSGT_SUBREADER, MSGL_FATAL, "Could not open subtitle decoder\n"); av_freep(&ctx); diff -Nru mplayer2-2.0-426-gc32b3ed/sub/find_subfiles.c mplayer2-2.0-554-gf63dbad/sub/find_subfiles.c --- mplayer2-2.0-426-gc32b3ed/sub/find_subfiles.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/sub/find_subfiles.c 2012-05-17 14:38:00.000000000 +0000 @@ -4,6 +4,8 @@ #include #include +#include "osdep/io.h" + #include "mp_msg.h" #include "options.h" #include "path.h" diff -Nru mplayer2-2.0-426-gc32b3ed/sub/font_load.c mplayer2-2.0-554-gf63dbad/sub/font_load.c --- mplayer2-2.0-426-gc32b3ed/sub/font_load.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/sub/font_load.c 2012-05-17 14:38:00.000000000 +0000 @@ -21,9 +21,8 @@ #include #include #include -#include -#include -#include + +#include "osdep/io.h" #include "font_load.h" #include "mp_msg.h" @@ -72,7 +71,6 @@ font_desc_t *desc; FILE *f = NULL; char *dn; -//struct stat fstate; char section[64]; int i,j; int chardb=0; @@ -93,10 +91,6 @@ desc->fpath = dn; // search in the same dir as fonts.desc -// desc->fpath=get_path("font/"); -// if (stat(desc->fpath, &fstate)!=0) desc->fpath=DATADIR"/font"; - - // set up some defaults, and erase table diff -Nru mplayer2-2.0-426-gc32b3ed/sub/font_load_ft.c mplayer2-2.0-554-gf63dbad/sub/font_load_ft.c --- mplayer2-2.0-426-gc32b3ed/sub/font_load_ft.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/sub/font_load_ft.c 2012-05-17 14:38:00.000000000 +0000 @@ -1160,7 +1160,7 @@ FcConfigSubstitute(0, fc_pattern, FcMatchPattern); FcDefaultSubstitute(fc_pattern); fc_pattern2 = fc_pattern; - fc_pattern = FcFontMatch(0, fc_pattern, 0); + fc_pattern = FcFontMatch(0, fc_pattern, &result); FcPatternDestroy(fc_pattern2); } // s doesn't need to be freed according to fontconfig docs diff -Nru mplayer2-2.0-426-gc32b3ed/sub/spudec.c mplayer2-2.0-554-gf63dbad/sub/spudec.c --- mplayer2-2.0-426-gc32b3ed/sub/spudec.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/sub/spudec.c 2012-05-17 14:38:00.000000000 +0000 @@ -27,9 +27,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "config.h" -#include "mp_msg.h" - #include #include #include @@ -37,12 +34,17 @@ #include #include #include + +#include +#include +#include + +#include "config.h" +#include "mp_msg.h" + #include "libvo/video_out.h" #include "spudec.h" #include "vobsub.h" -#include "libavutil/avutil.h" -#include "ffmpeg_files/intreadwrite.h" -#include "libswscale/swscale.h" #include "mpcommon.h" /* Valid values for spu_aamode: diff -Nru mplayer2-2.0-426-gc32b3ed/sub/sub.h mplayer2-2.0-554-gf63dbad/sub/sub.h --- mplayer2-2.0-426-gc32b3ed/sub/sub.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/sub/sub.h 2012-05-17 14:38:00.000000000 +0000 @@ -76,6 +76,7 @@ struct font_desc *sub_font; struct ass_track *ass_track; double pts; + double sub_offset; bool ass_track_changed; bool vsfilter_aspect; }; diff -Nru mplayer2-2.0-426-gc32b3ed/sub/subassconvert.c mplayer2-2.0-554-gf63dbad/sub/subassconvert.c --- mplayer2-2.0-426-gc32b3ed/sub/subassconvert.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/sub/subassconvert.c 2012-05-17 14:38:00.000000000 +0000 @@ -106,6 +106,32 @@ #define SUBRIP_MAX_STACKED_FONT_TAGS 16 +/* Read the HTML-style attribute starting at *s, and skip *s past the value. + * Set attr and val to the parsed attribute name and value. + * Return 0 on success, or -1 if no valid attribute was found. + */ +static int read_attr(char **s, struct bstr *attr, struct bstr *val) +{ + char *eq = strchr(*s, '='); + if (!eq) + return -1; + attr->start = *s; + attr->len = eq - *s; + for (int i = 0; i < attr->len; i++) + if (!isalnum(attr->start[i])) + return -1; + val->start = eq + 1; + bool quoted = val->start[0] == '"'; + if (quoted) + val->start++; + unsigned char *end = strpbrk(val->start, quoted ? "\"" : " >"); + if (!end) + return -1; + val->len = end - val->start; + *s = end + quoted; + return 0; +} + void subassconvert_subrip(const char *orig, char *dest, int dest_buffer_size) { /* line is not const to avoid warnings with strtol, etc. @@ -174,34 +200,34 @@ line += 6; while (*line && *line != '>') { - if (strncmp(line, "size=\"", 6) == 0) { - line += 6; - tag->size = strtol(line, &line, 10); - if (*line != '"') + if (*line == ' ') { + line++; + continue; + } + struct bstr attr, val; + if (read_attr(&line, &attr, &val) < 0) + break; + if (!bstrcmp0(attr, "size")) { + tag->size = bstrtoll(val, &val, 10); + if (val.len) break; append_text(&new_line, "{\\fs%d}", tag->size); tag->has_size = true; has_valid_attr = true; - } else if (strncmp(line, "color=\"", 7) == 0) { - line += 7; - if (*line == '#') { + } else if (!bstrcmp0(attr, "color")) { + if (bstr_eatstart(&val, bstr("#"))) { // #RRGGBB format - line++; - tag->color = strtol(line, &line, 16) & 0x00ffffff; - if (*line != '"') + tag->color = bstrtoll(val, &val, 16) & 0x00ffffff; + if (val.len) break; tag->color = ((tag->color & 0xff) << 16) | (tag->color & 0xff00) | ((tag->color & 0xff0000) >> 16); } else { // Standard web colors - int len = indexof(line, '"'); - if (len <= 0) - break; for (int i = 0; i < FF_ARRAY_ELEMS(subrip_web_colors); i++) { char *color = subrip_web_colors[i].s; - if (strlen(color) == len - && strncasecmp(line, color, len) == 0) { + if (bstrcasecmp(val, bstr(color)) == 0) { tag->color = subrip_web_colors[i].v; goto foundcolor; } @@ -211,29 +237,22 @@ mp_tmsg(MSGT_SUBREADER, MSGL_WARN, "SubRip: unknown font color in subtitle: %s\n", orig); append_text(&new_line, "{\\c}"); - line += len + 1; continue; - foundcolor: - line += len; + foundcolor: ; } append_text(&new_line, "{\\c&H%06X&}", tag->color); tag->has_color = true; has_valid_attr = true; - } else if (strncmp(line, "face=\"", 6) == 0) { + } else if (!bstrcmp0(attr, "face")) { /* Font face attribute */ - line += 6; - int len = indexof(line, '"'); - if (len <= 0) - break; - tag->face.start = line; - tag->face.len = len; - line += len; + tag->face = val; append_text(&new_line, "{\\fn%.*s}", BSTR_P(tag->face)); tag->has_face = true; has_valid_attr = true; - } - line++; + } else + mp_tmsg(MSGT_SUBREADER, MSGL_WARN,"SubRip: unrecognized " + "attribute \"%.*s\" in font tag\n", BSTR_P(attr)); } if (!has_valid_attr || *line != '>') { /* Not valid font tag */ diff -Nru mplayer2-2.0-426-gc32b3ed/sub/vobsub.c mplayer2-2.0-554-gf63dbad/sub/vobsub.c --- mplayer2-2.0-426-gc32b3ed/sub/vobsub.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/sub/vobsub.c 2012-05-17 14:38:00.000000000 +0000 @@ -695,8 +695,8 @@ static int vobsub_parse_timestamp(vobsub_t *vob, const char *line) { int h, m, s, ms; - off_t filepos; - if (sscanf(line, " %02d:%02d:%02d:%03d, filepos: %09lx", + int64_t filepos; + if (sscanf(line, " %02d:%02d:%02d:%03d, filepos: %09"SCNx64, &h, &m, &s, &ms, &filepos) != 5) return -1; return vobsub_add_timestamp(vob, filepos, vob->delay + ms + 1000 * (s + 60 * (m + 60 * h))); diff -Nru mplayer2-2.0-426-gc32b3ed/talloc.h mplayer2-2.0-554-gf63dbad/talloc.h --- mplayer2-2.0-426-gc32b3ed/talloc.h 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/talloc.h 2012-05-17 14:38:00.000000000 +0000 @@ -29,6 +29,8 @@ #include #include +#include "mpcommon.h" + /* HACK: libsmbclient uses dynamically linked libtalloc.so which has * identically named symbols. This name collision caused a crash under * stream_smb when trying to play anything with smb://. This hack @@ -54,18 +56,6 @@ #define TALLOC_DEPRECATED 0 #endif -#ifndef PRINTF_ATTRIBUTE -#if (__GNUC__ >= 3) -/** Use gcc attribute to check printf fns. a1 is the 1-based index of - * the parameter containing the format, and a2 the index of the first - * argument. Note that some gcc 2.x versions don't handle this - * properly **/ -#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2))) -#else -#define PRINTF_ATTRIBUTE(a1, a2) -#endif -#endif - /* try to make talloc_set_destructor() and talloc_steal() type safe, if we have a recent gcc */ #if (__GNUC__ >= 3) diff -Nru mplayer2-2.0-426-gc32b3ed/timeline/tl_matroska.c mplayer2-2.0-554-gf63dbad/timeline/tl_matroska.c --- mplayer2-2.0-426-gc32b3ed/timeline/tl_matroska.c 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/timeline/tl_matroska.c 2012-05-17 14:38:00.000000000 +0000 @@ -23,6 +23,8 @@ #include #include +#include "osdep/io.h" + #include "talloc.h" #include "mp_core.h" diff -Nru mplayer2-2.0-426-gc32b3ed/version.sh mplayer2-2.0-554-gf63dbad/version.sh --- mplayer2-2.0-426-gc32b3ed/version.sh 2012-01-02 04:15:52.000000000 +0000 +++ mplayer2-2.0-554-gf63dbad/version.sh 2012-05-17 14:38:00.000000000 +0000 @@ -15,7 +15,7 @@ NEW_REVISION="#define VERSION \"${version}${extra}\"" OLD_REVISION=$(head -n 1 version.h 2> /dev/null) -TITLE='#define MP_TITLE "%s "VERSION" (C) 2000-2011 MPlayer Team\n"' +TITLE='#define MP_TITLE "%s "VERSION" (C) 2000-2012 MPlayer Team\n"' # Update version.h only on revision changes to avoid spurious rebuilds if test "$NEW_REVISION" != "$OLD_REVISION"; then