From f045c1552e94cb2bf8380b19a73ae50e9aff0593 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Thu, 5 Apr 2012 00:04:01 +0300 Subject: core: fix problems in video EOF detection Fix a missing check that could sometimes result in video frames being shown after specified end pts (end of timeline segment or --endpos). Fix mistaken video EOF detection after aspect change in video stream, when there is no current valid visible frame but the next frame is already buffered in VO. --- mplayer.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/mplayer.c b/mplayer.c index eb278353e3..cc56cc802b 100644 --- a/mplayer.c +++ b/mplayer.c @@ -3452,12 +3452,12 @@ static void run_playloop(struct MPContext *mpctx) 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; - video_left = mpctx->video_out->hasframe; - if (!mpctx->video_out->frame_loaded - && (!mpctx->paused || mpctx->restart_playback)) { + video_left = vo->hasframe || vo->frame_loaded; + if (!vo->frame_loaded && (!mpctx->paused || mpctx->restart_playback)) { double frame_time = update_video(mpctx); mp_dbg(MSGT_AVSYNC, MSGL_DBG2, "*** ftime=%5.3f ***\n", frame_time); if (mpctx->sh_video->vf_initialized < 0) { @@ -3468,18 +3468,19 @@ static void run_playloop(struct MPContext *mpctx) return; } video_left = frame_time >= 0; - if (endpts != MP_NOPTS_VALUE) - video_left &= mpctx->sh_video->pts < endpts; if (video_left && !mpctx->restart_playback) { mpctx->time_frame += frame_time / opts->playback_speed; adjust_sync(mpctx, frame_time); } } + 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) { @@ -3498,7 +3499,7 @@ static void run_playloop(struct MPContext *mpctx) if (!video_left || (mpctx->paused && !mpctx->restart_playback)) break; - if (!mpctx->video_out->frame_loaded) { + if (!vo->frame_loaded) { sleeptime = 0; break; } @@ -3536,7 +3537,7 @@ static void run_playloop(struct MPContext *mpctx) mpctx->time_frame = 0; } - double vsleep = mpctx->time_frame - mpctx->video_out->flip_queue_offset; + double vsleep = mpctx->time_frame - vo->flip_queue_offset; if (vsleep > 0.050) { sleeptime = FFMIN(sleeptime, vsleep - 0.040); break; @@ -3546,7 +3547,7 @@ static void run_playloop(struct MPContext *mpctx) //=================== FLIP PAGE (VIDEO BLT): ====================== current_module = "flip_page"; - vo_new_frame_imminent(mpctx->video_out); + 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); @@ -3558,12 +3559,12 @@ static void run_playloop(struct MPContext *mpctx) vf->control(vf, VFCTRL_DRAW_OSD, mpctx->osd); vo_osd_changed(0); - mpctx->time_frame -= mpctx->video_out->flip_queue_offset; + 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 += mpctx->video_out->flip_queue_offset; + mpctx->time_frame += vo->flip_queue_offset; unsigned int t2 = GetTimer(); /* Playing with playback speed it's possible to get pathological @@ -3572,7 +3573,7 @@ static void run_playloop(struct MPContext *mpctx) 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; + double pts2 = vo->next_pts2; if (pts2 != MP_NOPTS_VALUE && opts->correct_pts && !mpctx->restart_playback) { // expected A/V sync correction is ignored @@ -3586,11 +3587,11 @@ static void run_playloop(struct MPContext *mpctx) diff = 10; duration = diff * 1e6; } - vo_flip_page(mpctx->video_out, pts_us | 1, duration); + 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 (mpctx->video_out->driver->flip_page_timed) { + 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 -- cgit v1.2.3 From 87ae9d3e45ef6e331b34fa92ac1d0c68495f5379 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Thu, 5 Apr 2012 00:23:32 +0300 Subject: core: in VO flip timing, recheck time after OSD draw Make the code read current real time again after drawing OSD. This ensures time taken in OSD drawing is properly deducted from the duration of the following sleep. The main practical effect is to avoid the A-V field on the status line staying at a value a couple of milliseconds above 0 (depending on VO). --- mplayer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mplayer.c b/mplayer.c index cc56cc802b..edeffef9e4 100644 --- a/mplayer.c +++ b/mplayer.c @@ -3559,6 +3559,7 @@ static void run_playloop(struct MPContext *mpctx) vf->control(vf, VFCTRL_DRAW_OSD, mpctx->osd); vo_osd_changed(0); + 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 -- cgit v1.2.3 From b93ed278362185ff980e0ce8f4ab3029f8fe395f Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Fri, 6 Apr 2012 14:24:26 +0300 Subject: input: stop trying to read terminal input on EOF Stop trying to read terminal input if a read attempt returns EOF. The most important case where this matters is when someone runs the player with stdin redirected from /dev/null and without specifying --no-consolecontrols. This used to cause 100% CPU load while paused, as select() would continuously trigger on stdin (the need for --no-consolecontrols was not apparent to people with older mplayer versions, as input reading was less efficient and latencies like hardcoded sleeps kept CPU use well below 100%). Now this will only cause a "Dead key input" error message. --- mplayer.c | 5 +++-- osdep/getch2-win.c | 3 ++- osdep/getch2.c | 11 +++++++++-- osdep/getch2.h | 4 +++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/mplayer.c b/mplayer.c index edeffef9e4..26555e3c20 100644 --- a/mplayer.c +++ b/mplayer.c @@ -3798,8 +3798,9 @@ static void run_playloop(struct MPContext *mpctx) 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) diff --git a/osdep/getch2-win.c b/osdep/getch2-win.c index 326cf1a7d0..f1ccea6359 100644 --- a/osdep/getch2-win.c +++ b/osdep/getch2-win.c @@ -158,11 +158,12 @@ static int getch2_internal(void) 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) diff --git a/osdep/getch2.c b/osdep/getch2.c index 1a92866afd..dcd5b1ad84 100644 --- a/osdep/getch2.c +++ b/osdep/getch2.c @@ -158,11 +158,17 @@ void get_screen_size(void){ #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)) { @@ -279,6 +285,7 @@ void getch2(struct mp_fifo *fifo) getch2_buf[i] = getch2_buf[len+i]; mplayer_put_key(fifo, code); } + return true; } static int getch2_status=0; diff --git a/osdep/getch2.h b/osdep/getch2.h index 8fb346d4f7..458881c15f 100644 --- a/osdep/getch2.h +++ b/osdep/getch2.h @@ -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 @@ void getch2_disable(void); /* 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 /** -- cgit v1.2.3 From e2fc1f640fdf473fdf8f1de6fd1212731b8ffa13 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Fri, 6 Apr 2012 16:58:39 +0300 Subject: build: remove OS/2 support --- Makefile | 4 - configure | 109 +---- cpudetect.c | 30 -- libao2/ao_dart.c | 276 ------------- libao2/ao_kai.c | 332 --------------- libvo/vo_kva.c | 1090 ------------------------------------------------- loader/ldt_keeper.c | 3 - loader/module.c | 20 - mplayer.c | 2 +- osdep/getch2-os2.c | 200 --------- osdep/getch2.c | 2 +- osdep/getch2.h | 4 +- osdep/mmap-os2.c | 211 ---------- osdep/osdep.h | 50 --- osdep/priority.c | 2 - path.c | 20 - stream/cache2.c | 8 +- stream/stream_cddb.c | 74 ---- stream/stream_vcd.c | 17 - stream/vcd_read_os2.h | 242 ----------- 20 files changed, 13 insertions(+), 2683 deletions(-) delete mode 100644 libao2/ao_dart.c delete mode 100644 libao2/ao_kai.c delete mode 100644 libvo/vo_kva.c delete mode 100644 osdep/getch2-os2.c delete mode 100644 osdep/mmap-os2.c delete mode 100644 osdep/osdep.h delete mode 100644 stream/vcd_read_os2.h diff --git a/Makefile b/Makefile index b3b0634d6d..43d04464a7 100644 --- a/Makefile +++ b/Makefile @@ -115,7 +115,6 @@ SRCS_COMMON-$(NATIVE_RTSP) += stream/stream_rtsp.c \ 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 @@ -438,7 +437,6 @@ 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-$(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 @@ -459,8 +457,6 @@ SRCS_MPLAYER-$(IVTV) += libao2/ao_ivtv.c libvo/vo_ivtv.c 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 diff --git a/configure b/configure index 4374d745b6..12f5e9db31 100755 --- a/configure +++ b/configure @@ -215,7 +215,6 @@ 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; } @@ -402,7 +401,6 @@ Video output: --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] @@ -450,8 +448,6 @@ Audio output: --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] @@ -575,7 +571,6 @@ _dga2=auto _xv=auto _vdpau=auto _sdl=auto -_kva=auto _direct3d=auto _directx=auto _win32waveout=auto @@ -608,8 +603,6 @@ _esd=auto _rsound=auto _pulse=auto _jack=auto -_kai=auto -_dart=auto _openal=no _libcdio=auto _mad=auto @@ -866,8 +859,6 @@ for ac_option do --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 ;; @@ -936,10 +927,6 @@ for ac_option do --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 ;; @@ -1409,15 +1396,6 @@ if qnx ; then 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 - TMPC="$mplayer_tmpdir/tmp.c" TMPCPP="$mplayer_tmpdir/tmp.cpp" TMPEXE="$mplayer_tmpdir/tmp$_exesuf" @@ -3103,7 +3081,6 @@ if test "$_mman" = yes ; then 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" @@ -3480,8 +3457,7 @@ int main(void) {int nfds = 1; fd_set readfds; struct timeval timeout; select(nfd 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" @@ -4611,24 +4587,6 @@ fi 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" @@ -5034,41 +4992,8 @@ 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" @@ -5089,7 +5014,7 @@ else 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" @@ -5101,7 +5026,7 @@ fi 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 @@ -5144,7 +5069,7 @@ if test "$_dvdread_internal" = auto ; then 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" @@ -5198,8 +5123,6 @@ if test "$_libdvdcss_internal" = yes ; then 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" @@ -5622,7 +5545,7 @@ fi # Fall back on default directory. if test -z "$_codecsdir" ; then _codecsdir="$_libdir/codecs" - mingw32 || os2 && _codecsdir="codecs" + mingw32 && _codecsdir="codecs" fi @@ -5674,7 +5597,7 @@ if test "$_real" = auto ; then _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 @@ -6249,7 +6172,7 @@ fi # (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 @@ -6302,15 +6225,6 @@ echores "$_lircc" ############################################################################# -# 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" @@ -6433,7 +6347,6 @@ MPLAYER = $_mplayer NEED_GETTIMEOFDAY = $need_gettimeofday NEED_GLOB = $need_glob -NEED_MMAP = $need_mmap NEED_SETENV = $need_setenv NEED_SHMEM = $need_shmem NEED_STRSEP = $need_strsep @@ -6455,7 +6368,6 @@ CDDA = $_cdda CDDB = $_cddb COREAUDIO = $_coreaudio COREVIDEO = $_corevideo -DART = $_dart DGA = $_dga DIRECT3D = $_direct3d DIRECTFB = $_directfb @@ -6485,8 +6397,6 @@ IVTV = $_ivtv JACK = $_jack JOYSTICK = $_joystick JPEG = $_jpeg -KAI = $_kai -KVA = $_kva LADSPA = $_ladspa LIBA52 = $_liba52 LIBASS = $_ass @@ -6787,11 +6697,9 @@ $def_xmms $def_alsa $def_arts $def_coreaudio -$def_dart $def_esd $def_esd_latency $def_jack -$def_kai $def_nas $def_openal $def_openal_h @@ -6881,7 +6789,6 @@ $def_gl_x11 $def_gl_sdl $def_ivtv $def_jpeg -$def_kva $def_md5sum $def_mga $def_mng diff --git a/cpudetect.c b/cpudetect.c index 160ec955ea..fb93116c80 100644 --- a/cpudetect.c +++ b/cpudetect.c @@ -40,9 +40,6 @@ CpuCaps gCpuCaps; #include #elif defined(__MINGW32__) || defined(__CYGWIN__) #include -#elif defined(__OS2__) -#define INCL_DOS -#include #elif defined(__AMIGAOS4__) #include #endif @@ -89,24 +86,6 @@ LONG CALLBACK win32_sig_handler_sse(EXCEPTION_POINTERS* ep) } #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 @@ static void check_os_katmai_support( void ) 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 --git a/libao2/ao_dart.c b/libao2/ao_dart.c deleted file mode 100644 index e1df7d32f7..0000000000 --- a/libao2/ao_dart.c +++ /dev/null @@ -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 --git a/libao2/ao_kai.c b/libao2/ao_kai.c deleted file mode 100644 index 98a3e49b44..0000000000 --- a/libao2/ao_kai.c +++ /dev/null @@ -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 --git a/libvo/vo_kva.c b/libvo/vo_kva.c deleted file mode 100644 index 878911c438..0000000000 --- a/libvo/vo_kva.c +++ /dev/null @@ -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.hwndSysMen