From 1b915e419e1454b8d568fa3b9c97e83fc5a95965 Mon Sep 17 00:00:00 2001 From: diego Date: Mon, 16 Feb 2009 02:00:29 +0000 Subject: Replace double semicolon by single semicolon. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28611 b3059339-0415-0410-9bf9-f77b7e298cf2 --- drivers/3dfx.h | 2 +- libmpdemux/demux_ts.c | 2 +- libmpdemux/muxer_mpeg.c | 2 +- libvo/vo_xvmc.c | 2 +- loader/dshow/DS_AudioDecoder.c | 2 +- stream/stream.h | 2 +- stream/stream_dvdnav.c | 2 +- stream/tvi_dshow.c | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/3dfx.h b/drivers/3dfx.h index 99d6ef0a75..123541c865 100644 --- a/drivers/3dfx.h +++ b/drivers/3dfx.h @@ -66,7 +66,7 @@ struct voodoo_2d_reg_t { uint32_t lineStipple; uint32_t lineStyle; uint32_t pattern0Alias; - uint32_t pattern1Alias;; + uint32_t pattern1Alias; uint32_t clip1Min; uint32_t clip1Max; uint32_t srcFormat; diff --git a/libmpdemux/demux_ts.c b/libmpdemux/demux_ts.c index 94de6fbc28..3d15281644 100644 --- a/libmpdemux/demux_ts.c +++ b/libmpdemux/demux_ts.c @@ -322,7 +322,7 @@ static void ts_add_stream(demuxer_t * demuxer, ES_stream_t *es) sh_video_t *sh = new_sh_video_vid(demuxer, priv->last_vid, es->pid); if(sh) { - sh->format = IS_VIDEO(es->type) ? es->type : es->subtype;; + sh->format = IS_VIDEO(es->type) ? es->type : es->subtype; sh->ds = demuxer->video; priv->ts.streams[es->pid].id = priv->last_vid; diff --git a/libmpdemux/muxer_mpeg.c b/libmpdemux/muxer_mpeg.c index 7e88686483..a4504caa99 100644 --- a/libmpdemux/muxer_mpeg.c +++ b/libmpdemux/muxer_mpeg.c @@ -538,7 +538,7 @@ static void write_mpeg2_scr(unsigned char *b, uint64_t ts) scr_ext = ts % 300ULL; ts /= 300ULL; ts &= 0x1FFFFFFFFULL; //33 bits - t1 = (ts >> 30) & 0x7;; + t1 = (ts >> 30) & 0x7; t2 = (ts >> 15) & 0x7fff; t3 = ts & 0x7fff; diff --git a/libvo/vo_xvmc.c b/libvo/vo_xvmc.c index ad18fb3231..ac06f668ad 100644 --- a/libvo/vo_xvmc.c +++ b/libvo/vo_xvmc.c @@ -529,7 +529,7 @@ int vm = flags & VOFLAG_MODESWITCHING; surface_render[i].data_blocks = data_blocks.blocks; surface_render[i].mv_blocks = mv_blocks.macro_blocks; surface_render[i].allocated_mv_blocks = numblocks; - surface_render[i].allocated_data_blocks = numblocks*blocks_per_macroblock;; + surface_render[i].allocated_data_blocks = numblocks*blocks_per_macroblock; surface_render[i].idct = (surface_info.mc_type & XVMC_IDCT) == XVMC_IDCT; surface_render[i].unsigned_intra = (surface_info.flags & XVMC_INTRA_UNSIGNED) == XVMC_INTRA_UNSIGNED; surface_render[i].p_surface = &surface_array[i]; diff --git a/loader/dshow/DS_AudioDecoder.c b/loader/dshow/DS_AudioDecoder.c index 2ac48cd25e..645c8b517b 100644 --- a/loader/dshow/DS_AudioDecoder.c +++ b/loader/dshow/DS_AudioDecoder.c @@ -184,7 +184,7 @@ int DS_AudioDecoder_GetSrcSize(DS_AudioDecoder *this, int dest_size) { double efficiency =(double) this->in_fmt.nAvgBytesPerSec / (this->in_fmt.nSamplesPerSec*this->in_fmt.nBlockAlign); - int frames = (int)(dest_size*efficiency);; + int frames = (int)(dest_size*efficiency); if (frames < 1) frames = 1; diff --git a/stream/stream.h b/stream/stream.h index 686288071f..484c6a2232 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -224,7 +224,7 @@ inline static int stream_read(stream_t *s,char* mem,int total){ inline static unsigned char* stream_read_line(stream_t *s,unsigned char* mem, int max) { int len; - unsigned char* end,*ptr = mem;; + unsigned char* end,*ptr = mem; do { len = s->buf_len-s->buf_pos; // try to fill the buffer diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c index 403016b372..85d86713c2 100644 --- a/stream/stream_dvdnav.c +++ b/stream/stream_dvdnav.c @@ -733,7 +733,7 @@ int mp_dvdnav_aid_from_lang(stream_t *stream, unsigned char *language) { dvdnav_priv_t * priv = stream->priv; int k; uint8_t lg; - uint16_t lang, lcode;; + uint16_t lang, lcode; while(language && strlen(language)>=2) { lcode = (language[0] << 8) | (language[1]); diff --git a/stream/tvi_dshow.c b/stream/tvi_dshow.c index e06f4dc346..4a524852cd 100644 --- a/stream/tvi_dshow.c +++ b/stream/tvi_dshow.c @@ -3312,7 +3312,7 @@ static int control(priv_t * priv, int cmd, void *arg) if (!priv->chains[1]->arpmt[0]) return TVI_CONTROL_FALSE; - samplerate = *(int *) arg;; + samplerate = *(int *) arg; for (i = 0; priv->chains[1]->arpmt[i]; i++) if (check_audio_format -- cgit v1.2.3 From 398332888968b9eca5c756cbaa1c1866136fe596 Mon Sep 17 00:00:00 2001 From: diego Date: Mon, 16 Feb 2009 17:02:16 +0000 Subject: Make configure recognize avr32. patch by Hans-Christian Egtvedt, hans-christian.egtvedt atmel com git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28612 b3059339-0415-0410-9bf9-f77b7e298cf2 --- configure | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/configure b/configure index b310a82226..62e9493a4f 100755 --- a/configure +++ b/configure @@ -1695,7 +1695,7 @@ fi def_fast_64bit='#define HAVE_FAST_64BIT 0' -_arch_all='X86 X86_32 X86_64 IA64 SPARC ARM SH4 PPC ALPHA SGI_MIPS PA_RISC S390 S390X VAX BFIN XTENSA GENERIC' +_arch_all='X86 X86_32 X86_64 IA64 SPARC ARM AVR32 SH4 PPC ALPHA SGI_MIPS PA_RISC S390 S390X VAX BFIN XTENSA GENERIC' case "$host_arch" in i[3-9]86|x86|x86pc|k5|k6|k6-2|k6-3|pentium*|athlon*|i586-i686) _arch='X86 X86_32' @@ -2054,6 +2054,12 @@ EOF iproc='arm' ;; + avr32) + _arch='AVR32' + _target_arch='ARCH_AVR32 = yes' + iproc='avr32' + ;; + sh|sh4) _arch='SH4' _target_arch='ARCH_SH4 = yes' -- cgit v1.2.3 From e3847132b5680a910982b4274a674c7e97796cfd Mon Sep 17 00:00:00 2001 From: diego Date: Mon, 16 Feb 2009 17:05:58 +0000 Subject: Use fixed-point implementation on avr32. patch by Hans-Christian Egtvedt, hans-christian.egtvedt atmel com git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28613 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libfaad2/common.h | 2 +- libfaad2/local_changes.diff | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libfaad2/common.h b/libfaad2/common.h index 29a30d089e..576e9ca115 100644 --- a/libfaad2/common.h +++ b/libfaad2/common.h @@ -69,7 +69,7 @@ extern "C" { /* Use if target platform has address generators with autoincrement */ //#define PREFER_POINTERS -#if defined(_WIN32_WCE) || defined(__arm__) +#if defined(_WIN32_WCE) || defined(__arm__) || defined(__avr32__) #define FIXED_POINT #endif diff --git a/libfaad2/local_changes.diff b/libfaad2/local_changes.diff index a6400eb0b8..0e3fe95d41 100644 --- a/libfaad2/local_changes.diff +++ b/libfaad2/local_changes.diff @@ -52,7 +52,7 @@ //#define PREFER_POINTERS -#ifdef _WIN32_WCE -+#if defined(_WIN32_WCE) || defined(__arm__) ++#if defined(_WIN32_WCE) || defined(__arm__) || defined(__avr32__) #define FIXED_POINT #endif -- cgit v1.2.3 From 8e9029769862ac35e5a46592b0c4a139f23be5c4 Mon Sep 17 00:00:00 2001 From: reimar Date: Mon, 16 Feb 2009 18:38:54 +0000 Subject: 100l, do 0-filling on resume (to avoid desync after pause) in ao_oss only when the we output a PCM format, not for e.g. AC3. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28614 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libao2/ao_oss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libao2/ao_oss.c b/libao2/ao_oss.c index 44f0c7d857..8e3f76285e 100644 --- a/libao2/ao_oss.c +++ b/libao2/ao_oss.c @@ -479,7 +479,7 @@ static void audio_resume(void) int fillcnt; reset(); fillcnt = get_space() - prepause_space; - if (fillcnt > 0) { + if (fillcnt > 0 && !(ao_data.format & AF_FORMAT_SPECIAL_MASK)) { void *silence = calloc(fillcnt, 1); play(silence, fillcnt, 0); free(silence); -- cgit v1.2.3 From 113055c9cf4f278cf0e8f050ee7750ab44c6af87 Mon Sep 17 00:00:00 2001 From: bircoph Date: Mon, 16 Feb 2009 20:03:32 +0000 Subject: Add ccache usage suggestion to speed up compilation. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28615 b3059339-0415-0410-9bf9-f77b7e298cf2 --- DOCS/xml/en/bugreports.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DOCS/xml/en/bugreports.xml b/DOCS/xml/en/bugreports.xml index d541230f4f..de716463b2 100644 --- a/DOCS/xml/en/bugreports.xml +++ b/DOCS/xml/en/bugreports.xml @@ -113,6 +113,8 @@ you need to go back. earlier version, so if you do not make a backup copy of your original source tree, you will have to recompile everything in it when you come back to the present.) +Alternatively you may use ccache +to speed up compilation. -- cgit v1.2.3 From 47b6eb3758c4331171f21030463436a9c705234b Mon Sep 17 00:00:00 2001 From: bircoph Date: Mon, 16 Feb 2009 20:07:52 +0000 Subject: Synced with r28615. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28616 b3059339-0415-0410-9bf9-f77b7e298cf2 --- DOCS/xml/ru/bugreports.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DOCS/xml/ru/bugreports.xml b/DOCS/xml/ru/bugreports.xml index 1b28ff3592..8a33797b4a 100644 --- a/DOCS/xml/ru/bugreports.xml +++ b/DOCS/xml/ru/bugreports.xml @@ -1,5 +1,5 @@ - + Как сообщать об ошибках @@ -109,6 +109,8 @@ make (Как правило необходимо выполнять 'make distclean' до перекомпиляции более ранней версии, поэтому при отсутствии сохраненной копии Вам придется перекомпилировать весь проект.) +Также Вы можете использовать ccache +для ускорения компиляции. -- cgit v1.2.3 From 7e9fd9351c21071e288d38a103bb5f8482b2b871 Mon Sep 17 00:00:00 2001 From: reimar Date: Mon, 16 Feb 2009 20:58:13 +0000 Subject: Add support for VDPAU video out, including hardware decoding. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28617 b3059339-0415-0410-9bf9-f77b7e298cf2 --- DOCS/man/en/mplayer.1 | 5 + Makefile | 1 + configure | 33 +- libmpcodecs/vd_ffmpeg.c | 20 +- libvo/video_out.c | 4 + libvo/vo_vdpau.c | 809 ++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 866 insertions(+), 6 deletions(-) create mode 100644 libvo/vo_vdpau.c diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1 index f1923d38a8..0a87922db3 100644 --- a/DOCS/man/en/mplayer.1 +++ b/DOCS/man/en/mplayer.1 @@ -3423,6 +3423,11 @@ Select the driver to use as source to overlay on top of X11. .PD 1 . .TP +.B vdpau (with \-vc ffmpeg12vdpau, ffvc1vdpau or ffh264vdpau) +Video output that uses VDPAU to decode video via hardware. +Also supports displaying of software-decoded video. +. +.TP .B xvmc (X11 with \-vc ffmpeg12mc only) Video output driver that uses the XvMC (X Video Motion Compensation) extension of XFree86 4.x to speed up MPEG-1/2 and VCR2 decoding. diff --git a/Makefile b/Makefile index 81426b471f..d4afdd524e 100644 --- a/Makefile +++ b/Makefile @@ -630,6 +630,7 @@ SRCS_MPLAYER-$(TDFXVID) += libvo/vo_tdfx_vid.c SRCS_MPLAYER-$(TGA) += libvo/vo_tga.c SRCS_MPLAYER-$(V4L2) += libvo/vo_v4l2.c SRCS_MPLAYER-$(V4L2) += libao2/ao_v4l2.c +SRCS_MPLAYER-$(VDPAU) += libvo/vo_vdpau.c SRCS_MPLAYER-$(VESA) += libvo/gtf.c libvo/vo_vesa.c libvo/vesa_lvo.c SRCS_MPLAYER-$(VIDIX) += libvo/vo_cvidix.c \ libvo/vosub_vidix.c \ diff --git a/configure b/configure index 62e9493a4f..8eed59c29c 100755 --- a/configure +++ b/configure @@ -382,6 +382,7 @@ Video output: --enable-xmga enable mga_vid X11 video output [autodetect] --enable-xv enable Xv video output [autodetect] --enable-xvmc enable XvMC acceleration [disable] + --enable-vdpau enable VDPAU acceleration [autodetect] --enable-vm enable XF86VidMode support [autodetect] --enable-xinerama enable Xinerama support [autodetect] --enable-x11 enable X11 video output [autodetect] @@ -523,7 +524,7 @@ _libavcodec_a=auto _libamr_nb=auto _libamr_wb=auto _libavdecoders_all=`sed -n 's/^[^#]*DEC.*(.*, *\(.*\)).*/\1_decoder/p' libavcodec/allcodecs.c | tr '[a-z]' '[A-Z]'` -_libavdecoders=` echo $_libavdecoders_all | sed -e 's/ LIB[A-Z0-9_]*_DECODER//g' -e s/MPEG4AAC_DECODER// -e s/H264_VDPAU_DECODER// -e s/MPEG_VDPAU_DECODER// -e s/MPEG1_VDPAU_DECODER// -e s/VC1_VDPAU_DECODER// -e s/WMV3_VDPAU_DECODER// ` +_libavdecoders=` echo $_libavdecoders_all | sed -e 's/ LIB[A-Z0-9_]*_DECODER//g' -e s/MPEG4AAC_DECODER//` _libavencoders_all=`sed -n 's/^[^#]*ENC.*(.*, *\(.*\)).*/\1_encoder/p' libavcodec/allcodecs.c | tr '[a-z]' '[A-Z]'` _libavencoders=` echo $_libavencoders_all | sed 's/ LIB[A-Z0-9_]*_ENCODER//g'` _libavparsers_all=`sed -n 's/^[^#]*PARSER.*(.*, *\(.*\)).*/\1_parser/p' libavcodec/allcodecs.c | tr '[a-z]' '[A-Z]'` @@ -552,6 +553,7 @@ _dga1=auto _dga2=auto _xv=auto _xvmc=no #auto when complete +_vdpau=auto _sdl=auto _direct3d=auto _directx=auto @@ -880,6 +882,8 @@ for ac_option do --disable-xv) _xv=no ;; --enable-xvmc) _xvmc=yes ;; --disable-xvmc) _xvmc=no ;; + --enable-vdpau) _vdpau=yes ;; + --disable-vdpau) _vdpau=no ;; --enable-sdl) _sdl=yes ;; --disable-sdl) _sdl=no ;; --enable-direct3d) _direct3d=yes ;; @@ -4179,7 +4183,7 @@ else _novomodules="x11 $_novomodules" _res_comment="check if the dev(el) packages are installed" # disable stuff that depends on X - _xv=no ; _xvmc=no ; _xinerama=no ; _vm=no ; _xf86keysym=no + _xv=no ; _xvmc=no ; _xinerama=no ; _vm=no ; _xf86keysym=no ; _vdpau=no fi echores "$_x11" @@ -4290,6 +4294,28 @@ fi echores "$_xvmc" +echocheck "VDPAU" +if test "$_vdpau" = auto ; then + _vdpau=no + if test "$_dl" = yes ; then + cat > $TMPC < +int main(void) {return 0;} +EOF + cc_check && _vdpau=yes + fi +fi +if test "$_vdpau" = yes ; then + def_vdpau='#define CONFIG_VDPAU 1' + _vomodules="vdpau $_vomodules" +else + def_vdpau='#define CONFIG_VDPAU 0' + _novomodules="vdpau $_novomodules" + _libavdecoders=`echo $_libavdecoders | sed -e s/MPEG_VDPAU_DECODER// -e s/H264_VDPAU_DECODER// -e s/WMV3_VDPAU_DECODER// -e s/VC1_VDPAU_DECODER//` +fi +echores "$_vdpau" + + echocheck "Xinerama" if test "$_xinerama" = auto ; then cat > $TMPC <capabilities&CODEC_CAP_DR1 && !do_vis_debug && lavc_codec->id != CODEC_ID_H264 && lavc_codec->id != CODEC_ID_INTERPLAY_VIDEO && lavc_codec->id != CODEC_ID_ROQ) ctx->do_dr1=1; + if (lavc_codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) + 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; @@ -239,6 +241,13 @@ static int init(sh_video_t *sh){ ctx->avctx = avcodec_alloc_context(); avctx = ctx->avctx; +#if CONFIG_VDPAU + if(lavc_codec->capabilities & CODEC_CAP_HWACCEL_VDPAU){ + avctx->get_format = get_format; + avctx->draw_horiz_band = draw_slice; + avctx->slice_flags = SLICE_FLAG_CODED_ORDER|SLICE_FLAG_ALLOW_FIELD; + } +#endif /* CONFIG_VDPAU */ #if CONFIG_XVMC if(lavc_codec->capabilities & CODEC_CAP_HWACCEL){ @@ -545,7 +554,7 @@ static int get_buffer(AVCodecContext *avctx, AVFrame *pic){ return avctx->get_buffer(avctx, pic); } - if (IMGFMT_IS_XVMC(ctx->best_csp)) { + if (IMGFMT_IS_XVMC(ctx->best_csp) || IMGFMT_IS_VDPAU(ctx->best_csp)) { type = MP_IMGTYPE_NUMBERED | (0xffff << 16); } else if (!pic->buffer_hints) { @@ -575,6 +584,9 @@ static int get_buffer(AVCodecContext *avctx, AVFrame *pic){ avctx->draw_horiz_band= draw_slice; } else avctx->draw_horiz_band= NULL; + if(IMGFMT_IS_VDPAU(mpi->imgfmt)) { + avctx->draw_horiz_band= draw_slice; + } #if CONFIG_XVMC if(IMGFMT_IS_XVMC(mpi->imgfmt)) { struct xvmc_pix_fmt *render = mpi->priv; //same as data[2] @@ -879,7 +891,7 @@ static mp_image_t *decode(sh_video_t *sh, void *data, int len, int flags){ return mpi; } -#if CONFIG_XVMC +#if CONFIG_XVMC || CONFIG_VDPAU static enum PixelFormat get_format(struct AVCodecContext *avctx, const enum PixelFormat *fmt){ enum PixelFormat selected_format = fmt[0]; @@ -889,7 +901,7 @@ static enum PixelFormat get_format(struct AVCodecContext *avctx, for(i=0;fmt[i]!=PIX_FMT_NONE;i++){ imgfmt = pixfmt2imgfmt(fmt[i]); - if(!IMGFMT_IS_XVMC(imgfmt)) continue; + if(!IMGFMT_IS_XVMC(imgfmt) && !IMGFMT_IS_VDPAU(imgfmt)) continue; mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_MPCODECS_TryingPixfmt, i); if(init_vo(sh, fmt[i]) >= 0) { selected_format = fmt[i]; @@ -897,7 +909,7 @@ static enum PixelFormat get_format(struct AVCodecContext *avctx, } } imgfmt = pixfmt2imgfmt(selected_format); - if(IMGFMT_IS_XVMC(imgfmt)) { + if(IMGFMT_IS_XVMC(imgfmt) || IMGFMT_IS_VDPAU(imgfmt)) { vd_ffmpeg_ctx *ctx = sh->context; avctx->get_buffer= get_buffer; avctx->release_buffer= release_buffer; diff --git a/libvo/video_out.c b/libvo/video_out.c index 27853d5ed4..54291cfce9 100644 --- a/libvo/video_out.c +++ b/libvo/video_out.c @@ -87,6 +87,7 @@ extern vo_functions_t video_out_xmga; extern vo_functions_t video_out_x11; extern vo_functions_t video_out_xover; extern vo_functions_t video_out_xvmc; +extern vo_functions_t video_out_vdpau; extern vo_functions_t video_out_xv; extern vo_functions_t video_out_gl; extern vo_functions_t video_out_gl2; @@ -169,6 +170,9 @@ const vo_functions_t* const video_out_drivers[] = #ifdef CONFIG_3DFX &video_out_3dfx, #endif +#ifdef CONFIG_VDPAU + &video_out_vdpau, +#endif #ifdef CONFIG_XV &video_out_xv, #endif diff --git a/libvo/vo_vdpau.c b/libvo/vo_vdpau.c new file mode 100644 index 0000000000..46e897615c --- /dev/null +++ b/libvo/vo_vdpau.c @@ -0,0 +1,809 @@ +/* + * VDPAU video output driver + * + * Copyright (C) 2008 NVIDIA + * + * 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. + */ + +/** + * \defgroup VDPAU_Presentation VDPAU Presentation + * \ingroup Decoder + * + * Actual decoding and presentation are implemented here. + * All necessary frame information is collected through + * the "vdpau_render_state" structure after parsing all headers + * etc. in libavcodec for different codecs. + * + * @{ + */ + +#include +#include + +#include "config.h" +#include "mp_msg.h" +#include "video_out.h" +#include "video_out_internal.h" +#include "x11_common.h" +#include "aspect.h" +#include "sub.h" + +#include "libavcodec/vdpau.h" + +#include "gui/interface.h" + +#include "libavutil/common.h" + +static vo_info_t info = { + "VDPAU with X11", + "vdpau", + "Rajib Mahapatra and others", + "" +}; + +LIBVO_EXTERN(vdpau) + +#define CHECK_ST_ERROR(message) \ + if (vdp_st != VDP_STATUS_OK) { \ + mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] %s: %s\n", \ + message, vdp_get_error_string(vdp_st)); \ + return -1; \ + } + +#define CHECK_ST_WARNING(message) \ + if (vdp_st != VDP_STATUS_OK) \ + mp_msg(MSGT_VO, MSGL_WARN, "[vdpau] %s: %s\n", \ + message, vdp_get_error_string(vdp_st)); + +/* number of video and output surfaces */ +#define NUM_OUTPUT_SURFACES 3 +#define MAX_VIDEO_SURFACES 50 + +/* number of palette entries */ +#define PALETTE_SIZE 256 + +/* + * Global variable declaration - VDPAU specific + */ + +/* Declaration for all variables of win_x11_init_vdpau_procs() and + * win_x11_init_vdpau_flip_queue() functions + */ +static VdpDevice vdp_device; +static VdpDeviceCreateX11 *vdp_device_create; +static VdpGetProcAddress *vdp_get_proc_address; + +static VdpPresentationQueueTarget vdp_flip_target; +static VdpPresentationQueue vdp_flip_queue; + +static VdpDeviceDestroy *vdp_device_destroy; +static VdpVideoSurfaceCreate *vdp_video_surface_create; +static VdpVideoSurfaceDestroy *vdp_video_surface_destroy; + +static VdpGetErrorString *vdp_get_error_string; + +/* May be used in software filtering/postprocessing options + * in MPlayer (./mplayer -vf ..) if we copy video_surface data to + * system memory. + */ +static VdpVideoSurfacePutBitsYCbCr *vdp_video_surface_put_bits_y_cb_cr; +static VdpOutputSurfacePutBitsNative *vdp_output_surface_put_bits_native; + +static VdpOutputSurfaceCreate *vdp_output_surface_create; +static VdpOutputSurfaceDestroy *vdp_output_surface_destroy; + +/* VideoMixer puts video_surface data on displayable output_surface. */ +static VdpVideoMixerCreate *vdp_video_mixer_create; +static VdpVideoMixerDestroy *vdp_video_mixer_destroy; +static VdpVideoMixerRender *vdp_video_mixer_render; + +static VdpPresentationQueueTargetDestroy *vdp_presentation_queue_target_destroy; +static VdpPresentationQueueCreate *vdp_presentation_queue_create; +static VdpPresentationQueueDestroy *vdp_presentation_queue_destroy; +static VdpPresentationQueueDisplay *vdp_presentation_queue_display; +static VdpPresentationQueueBlockUntilSurfaceIdle *vdp_presentation_queue_block_until_surface_idle; +static VdpPresentationQueueTargetCreateX11 *vdp_presentation_queue_target_create_x11; + +/* output_surfaces[2] is used in composite-picture. */ +static VdpOutputSurfaceRenderOutputSurface *vdp_output_surface_render_output_surface; +static VdpOutputSurfacePutBitsIndexed *vdp_output_surface_put_bits_indexed; + +static VdpDecoderCreate *vdp_decoder_create; +static VdpDecoderDestroy *vdp_decoder_destroy; +static VdpDecoderRender *vdp_decoder_render; + +static void *vdpau_lib_handle; +static VdpOutputSurface output_surfaces[NUM_OUTPUT_SURFACES]; +static int output_surface_width, output_surface_height; + +static VdpVideoMixer video_mixer; + +static VdpDecoder decoder; +static int decoder_max_refs; + +static VdpRect src_rect_vid; +static VdpRect out_rect_vid; + +static struct vdpau_render_state surface_render[MAX_VIDEO_SURFACES]; +static int surface_num; +static int vid_surface_num; +static uint32_t vid_width, vid_height; +static uint32_t image_format; +static const VdpChromaType vdp_chroma_type = VDP_CHROMA_TYPE_420; + +/* draw_osd */ +static unsigned char *index_data; +static int index_data_size; +static uint32_t palette[PALETTE_SIZE]; + +/* + * X11 specific + */ +static int visible_buf; +static int int_pause; + +static void video_to_output_surface(void) +{ + VdpTime dummy; + VdpStatus vdp_st; + VdpOutputSurface output_surface = output_surfaces[surface_num]; + if (vid_surface_num < 0) + return; + + vdp_st = vdp_presentation_queue_block_until_surface_idle(vdp_flip_queue, + output_surface, + &dummy); + CHECK_ST_WARNING("Error when calling vdp_presentation_queue_block_until_surface_idle") + + vdp_st = vdp_video_mixer_render(video_mixer, VDP_INVALID_HANDLE, 0, + VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME, + 0, NULL, surface_render[vid_surface_num].surface, 0, NULL, &src_rect_vid, + output_surface, + NULL, &out_rect_vid, 0, NULL); + CHECK_ST_WARNING("Error when calling vdp_video_mixer_render") +} + +static void resize(void) +{ + VdpStatus vdp_st; + int i; + struct vo_rect src_rect; + struct vo_rect dst_rect; + calc_src_dst_rects(vid_width, vid_height, &src_rect, &dst_rect, NULL); + out_rect_vid.x0 = dst_rect.left; + out_rect_vid.x1 = dst_rect.right; + out_rect_vid.y0 = dst_rect.top; + out_rect_vid.y1 = dst_rect.bottom; + src_rect_vid.x0 = src_rect.left; + src_rect_vid.x1 = src_rect.right; + src_rect_vid.y0 = src_rect.top; + src_rect_vid.y1 = src_rect.bottom; +#ifdef CONFIG_FREETYPE + // adjust font size to display size + force_load_font = 1; +#endif + vo_osd_changed(OSDTYPE_OSD); + + if (output_surface_width < vo_dwidth || output_surface_height < vo_dheight) { + if (output_surface_width < vo_dwidth) { + output_surface_width += output_surface_width >> 1; + output_surface_width = FFMAX(output_surface_width, vo_dwidth); + } + if (output_surface_height < vo_dheight) { + output_surface_height += output_surface_height >> 1; + output_surface_height = FFMAX(output_surface_height, vo_dheight); + } + // Creation of output_surfaces + for (i = 0; i < NUM_OUTPUT_SURFACES; i++) { + if (output_surfaces[i] != VDP_INVALID_HANDLE) + vdp_output_surface_destroy(output_surfaces[i]); + vdp_st = vdp_output_surface_create(vdp_device, VDP_RGBA_FORMAT_B8G8R8A8, + output_surface_width, output_surface_height, + &output_surfaces[i]); + CHECK_ST_WARNING("Error when calling vdp_output_surface_create") + mp_msg(MSGT_VO, MSGL_DBG2, "OUT CREATE: %u\n", output_surfaces[i]); + } + } + video_to_output_surface(); + if (visible_buf) + flip_page(); +} + +/* Initialize vdp_get_proc_address, called from preinit() */ +static int win_x11_init_vdpau_procs(void) +{ + VdpStatus vdp_st; + + struct vdp_function { + const int id; + void *pointer; + }; + + const struct vdp_function *dsc; + + static const struct vdp_function vdp_func[] = { + {VDP_FUNC_ID_GET_ERROR_STRING, &vdp_get_error_string}, + {VDP_FUNC_ID_DEVICE_DESTROY, &vdp_device_destroy}, + {VDP_FUNC_ID_VIDEO_SURFACE_CREATE, &vdp_video_surface_create}, + {VDP_FUNC_ID_VIDEO_SURFACE_DESTROY, &vdp_video_surface_destroy}, + {VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR, + &vdp_video_surface_put_bits_y_cb_cr}, + {VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE, + &vdp_output_surface_put_bits_native}, + {VDP_FUNC_ID_OUTPUT_SURFACE_CREATE, &vdp_output_surface_create}, + {VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY, &vdp_output_surface_destroy}, + {VDP_FUNC_ID_VIDEO_MIXER_CREATE, &vdp_video_mixer_create}, + {VDP_FUNC_ID_VIDEO_MIXER_DESTROY, &vdp_video_mixer_destroy}, + {VDP_FUNC_ID_VIDEO_MIXER_RENDER, &vdp_video_mixer_render}, + {VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY, + &vdp_presentation_queue_target_destroy}, + {VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE, &vdp_presentation_queue_create}, + {VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY, + &vdp_presentation_queue_destroy}, + {VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY, + &vdp_presentation_queue_display}, + {VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE, + &vdp_presentation_queue_block_until_surface_idle}, + {VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11, + &vdp_presentation_queue_target_create_x11}, + {VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE, + &vdp_output_surface_render_output_surface}, + {VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED, + &vdp_output_surface_put_bits_indexed}, + {VDP_FUNC_ID_DECODER_CREATE, &vdp_decoder_create}, + {VDP_FUNC_ID_DECODER_RENDER, &vdp_decoder_render}, + {VDP_FUNC_ID_DECODER_DESTROY, &vdp_decoder_destroy}, + {0, NULL} + }; + + vdp_st = vdp_device_create(mDisplay, mScreen, + &vdp_device, &vdp_get_proc_address); + if (vdp_st != VDP_STATUS_OK) { + mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] Error when calling vdp_device_create_x11: %i\n", vdp_st); + return -1; + } + + for (dsc = vdp_func; dsc->pointer; dsc++) { + vdp_st = vdp_get_proc_address(vdp_device, dsc->id, dsc->pointer); + if (vdp_st != VDP_STATUS_OK) { + mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] Error when calling vdp_get_proc_address(function id %d): %s\n", dsc->id, vdp_get_error_string ? vdp_get_error_string(vdp_st) : "?"); + return -1; + } + } + return 0; +} + +/* Initialize vdpau_flip_queue, called from config() */ +static int win_x11_init_vdpau_flip_queue(void) +{ + VdpStatus vdp_st; + + vdp_st = vdp_presentation_queue_target_create_x11(vdp_device, vo_window, + &vdp_flip_target); + CHECK_ST_ERROR("Error when calling vdp_presentation_queue_target_create_x11") + + vdp_st = vdp_presentation_queue_create(vdp_device, vdp_flip_target, + &vdp_flip_queue); + CHECK_ST_ERROR("Error when calling vdp_presentation_queue_create") + + return 0; +} + +static int create_vdp_mixer(VdpChromaType vdp_chroma_type) { +#define VDP_NUM_MIXER_PARAMETER 3 + VdpStatus vdp_st; + static const VdpVideoMixerParameter parameters[VDP_NUM_MIXER_PARAMETER] = { + VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH, + VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT, + VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE + }; + const void *const parameter_values[VDP_NUM_MIXER_PARAMETER] = { + &vid_width, + &vid_height, + &vdp_chroma_type + }; + + vdp_st = vdp_video_mixer_create(vdp_device, 0, 0, + VDP_NUM_MIXER_PARAMETER, + parameters, parameter_values, + &video_mixer); + CHECK_ST_ERROR("Error when calling vdp_video_mixer_create") + + return 0; +} + +// Free everything specific to a certain video file +static void free_video_specific(void) { + int i; + VdpStatus vdp_st; + + if (decoder != VDP_INVALID_HANDLE) + vdp_decoder_destroy(decoder); + decoder = VDP_INVALID_HANDLE; + decoder_max_refs = -1; + + for (i = 0; i < MAX_VIDEO_SURFACES; i++) { + if (surface_render[i].surface != VDP_INVALID_HANDLE) { + vdp_st = vdp_video_surface_destroy(surface_render[i].surface); + CHECK_ST_WARNING("Error when calling vdp_video_surface_destroy") + } + surface_render[i].surface = VDP_INVALID_HANDLE; + } + + if (video_mixer != VDP_INVALID_HANDLE) + vdp_st = vdp_video_mixer_destroy(video_mixer); + CHECK_ST_WARNING("Error when calling vdp_video_mixer_destroy") + video_mixer = VDP_INVALID_HANDLE; +} + +/* + * connect to X server, create and map window, initialize all + * VDPAU objects, create different surfaces etc. + */ +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) +{ + XVisualInfo vinfo; + XSetWindowAttributes xswa; + XWindowAttributes attribs; + unsigned long xswamask; + int depth; + +#ifdef CONFIG_XF86VM + int vm = flags & VOFLAG_MODESWITCHING; +#endif + + image_format = format; + + int_pause = 0; + visible_buf = 0; + +#ifdef CONFIG_GUI + if (use_gui) + guiGetEvent(guiSetShVideo, 0); // the GUI will set up / resize our window + else +#endif + { +#ifdef CONFIG_XF86VM + if (vm) + vo_vm_switch(); + else +#endif + XGetWindowAttributes(mDisplay, DefaultRootWindow(mDisplay), &attribs); + depth = attribs.depth; + if (depth != 15 && depth != 16 && depth != 24 && depth != 32) + depth = 24; + XMatchVisualInfo(mDisplay, mScreen, depth, TrueColor, &vinfo); + + xswa.background_pixel = 0; + xswa.border_pixel = 0; + xswamask = CWBackPixel | CWBorderPixel; + + vo_x11_create_vo_window(&vinfo, vo_dx, vo_dy, d_width, d_height, + flags, CopyFromParent, "vdpau", title); + XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa); + +#ifdef CONFIG_XF86VM + if (vm) { + /* Grab the mouse pointer in our window */ + if (vo_grabpointer) + XGrabPointer(mDisplay, vo_window, True, 0, + GrabModeAsync, GrabModeAsync, + vo_window, None, CurrentTime); + XSetInputFocus(mDisplay, vo_window, RevertToNone, CurrentTime); + } +#endif + } + + if ((flags & VOFLAG_FULLSCREEN) && WinID <= 0) + vo_fs = 1; + + /* -----VDPAU related code here -------- */ + + free_video_specific(); + + if (vdp_flip_queue == VDP_INVALID_HANDLE && win_x11_init_vdpau_flip_queue()) + return -1; + + // video width and height + vid_width = width; + vid_height = height; + + if (create_vdp_mixer(vdp_chroma_type)) + return -1; + + surface_num = 0; + vid_surface_num = -1; + resize(); + + return 0; +} + +static void check_events(void) +{ + int e = vo_x11_check_events(mDisplay); + + if (e & VO_EVENT_RESIZE) + resize(); + + if ((e & VO_EVENT_EXPOSE || e & VO_EVENT_RESIZE) && int_pause) { + /* did we already draw a buffer */ + if (visible_buf) { + /* redraw the last visible buffer */ + VdpStatus vdp_st; + vdp_st = vdp_presentation_queue_display(vdp_flip_queue, + output_surfaces[surface_num], + vo_dwidth, vo_dheight, + 0); + CHECK_ST_WARNING("Error when calling vdp_presentation_queue_display") + } + } +} + +static void draw_osd_I8A8(int x0,int y0, int w,int h, unsigned char *src, + unsigned char *srca, int stride) +{ + VdpOutputSurface output_surface = output_surfaces[surface_num]; + VdpStatus vdp_st; + int i, j; + int pitch; + int index_data_size_required; + VdpRect output_indexed_rect_vid; + VdpOutputSurfaceRenderBlendState blend_state; + + if (!w || !h) + return; + + index_data_size_required = 2*w*h; + if (index_data_size < index_data_size_required) { + index_data = realloc(index_data, index_data_size_required); + index_data_size = index_data_size_required; + } + + // index_data creation, component order - I, A, I, A, ..... + for (i = 0; i < h; i++) + for (j = 0; j < w; j++) { + index_data[i*2*w + j*2] = src [i*stride+j]; + index_data[i*2*w + j*2 + 1] = -srca[i*stride+j]; + } + + output_indexed_rect_vid.x0 = x0; + output_indexed_rect_vid.y0 = y0; + output_indexed_rect_vid.x1 = x0 + w; + output_indexed_rect_vid.y1 = y0 + h; + + pitch = w*2; + + // write source_data to output_surfaces[2]. + vdp_st = vdp_output_surface_put_bits_indexed(output_surfaces[2], + VDP_INDEXED_FORMAT_I8A8, + (const void *const*)&index_data, + &pitch, + &output_indexed_rect_vid, + VDP_COLOR_TABLE_FORMAT_B8G8R8X8, + (void *)palette); + CHECK_ST_WARNING("Error when calling vdp_output_surface_put_bits_indexed") + + blend_state.struct_version = VDP_OUTPUT_SURFACE_RENDER_BLEND_STATE_VERSION; + blend_state.blend_factor_source_color = VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE; + blend_state.blend_factor_source_alpha = VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE; + blend_state.blend_factor_destination_color = VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; + blend_state.blend_factor_destination_alpha = VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; + blend_state.blend_equation_color = VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_ADD; + blend_state.blend_equation_alpha = VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_ADD; + + vdp_st = vdp_output_surface_render_output_surface(output_surface, + &output_indexed_rect_vid, + output_surfaces[2], + &output_indexed_rect_vid, + NULL, + &blend_state, + VDP_OUTPUT_SURFACE_RENDER_ROTATE_0); + CHECK_ST_WARNING("Error when calling vdp_output_surface_render_output_surface") +} + +static void draw_osd(void) +{ + mp_msg(MSGT_VO, MSGL_DBG2, "DRAW_OSD\n"); + + vo_draw_text(vo_dwidth, vo_dheight, draw_osd_I8A8); +} + +static void flip_page(void) +{ + VdpStatus vdp_st; + mp_msg(MSGT_VO, MSGL_DBG2, "\nFLIP_PAGE VID:%u -> OUT:%u\n", + surface_render[vid_surface_num].surface, output_surfaces[surface_num]); + + vdp_st = vdp_presentation_queue_display(vdp_flip_queue, output_surfaces[surface_num], + vo_dwidth, vo_dheight, + 0); + CHECK_ST_WARNING("Error when calling vdp_presentation_queue_display") + + surface_num = !surface_num; + visible_buf = 1; +} + +static int draw_slice(uint8_t *image[], int stride[], int w, int h, + int x, int y) +{ + VdpStatus vdp_st; + struct vdpau_render_state *rndr = (struct vdpau_render_state *)image[0]; + int max_refs = image_format == IMGFMT_VDPAU_H264 ? rndr->info.h264.num_ref_frames : 2; + if (!IMGFMT_IS_VDPAU(image_format)) + return VO_FALSE; + if (decoder == VDP_INVALID_HANDLE || decoder_max_refs < max_refs) { + VdpDecoderProfile vdp_decoder_profile; + if (decoder != VDP_INVALID_HANDLE) + vdp_decoder_destroy(decoder); + decoder = VDP_INVALID_HANDLE; + switch (image_format) { + case IMGFMT_VDPAU_MPEG1: + vdp_decoder_profile = VDP_DECODER_PROFILE_MPEG1; + break; + case IMGFMT_VDPAU_MPEG2: + vdp_decoder_profile = VDP_DECODER_PROFILE_MPEG2_MAIN; + break; + case IMGFMT_VDPAU_H264: + vdp_decoder_profile = VDP_DECODER_PROFILE_H264_HIGH; + break; + case IMGFMT_VDPAU_WMV3: + vdp_decoder_profile = VDP_DECODER_PROFILE_VC1_MAIN; + break; + case IMGFMT_VDPAU_VC1: + vdp_decoder_profile = VDP_DECODER_PROFILE_VC1_ADVANCED; + break; + } + vdp_st = vdp_decoder_create(vdp_device, vdp_decoder_profile, vid_width, vid_height, max_refs, &decoder); + CHECK_ST_WARNING("Failed creating VDPAU decoder"); + decoder_max_refs = max_refs; + } + vdp_st = vdp_decoder_render(decoder, rndr->surface, (void *)&rndr->info, rndr->bitstream_buffers_used, rndr->bitstream_buffers); + CHECK_ST_WARNING("Failed VDPAU decoder rendering"); + return VO_TRUE; +} + + +static int draw_frame(uint8_t *src[]) +{ + return VO_ERROR; +} + +static struct vdpau_render_state *get_surface(int number) +{ + if (number > MAX_VIDEO_SURFACES) + return NULL; + if (surface_render[number].surface == VDP_INVALID_HANDLE) { + VdpStatus vdp_st; + vdp_st = vdp_video_surface_create(vdp_device, vdp_chroma_type, + vid_width, vid_height, + &surface_render[number].surface); + CHECK_ST_WARNING("Error when calling vdp_video_surface_create") + if (vdp_st != VDP_STATUS_OK) + return NULL; + } + mp_msg(MSGT_VO, MSGL_DBG2, "VID CREATE: %u\n", surface_render[number].surface); + return &surface_render[number]; +} + +static uint32_t draw_image(mp_image_t *mpi) +{ + if (IMGFMT_IS_VDPAU(image_format)) { + struct vdpau_render_state *rndr = mpi->priv; + vid_surface_num = rndr - surface_render; + } else if (!(mpi->flags & MP_IMGFLAG_DRAW_CALLBACK)) { + VdpStatus vdp_st; + void *destdata[3] = {mpi->planes[0], mpi->planes[2], mpi->planes[1]}; + struct vdpau_render_state *rndr = get_surface(0); + vid_surface_num = rndr - surface_render; + vdp_st = vdp_video_surface_put_bits_y_cb_cr(rndr->surface, + VDP_YCBCR_FORMAT_YV12, + (const void *const*)destdata, + mpi->stride); // pitch + CHECK_ST_ERROR("Error when calling vdp_video_surface_put_bits_y_cb_cr") + } + + video_to_output_surface(); + return VO_TRUE; +} + +static uint32_t get_image(mp_image_t *mpi) +{ + struct vdpau_render_state *rndr; + + // no dr for non-decoding for now + if (!IMGFMT_IS_VDPAU(image_format)) return VO_FALSE; + if (mpi->type != MP_IMGTYPE_NUMBERED) return VO_FALSE; + + rndr = get_surface(mpi->number); + if (!rndr) { + mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] no surfaces available in get_image\n"); + // TODO: this probably breaks things forever, provide a dummy buffer? + return VO_FALSE; + } + mpi->flags |= MP_IMGFLAG_DIRECT; + mpi->stride[0] = mpi->stride[1] = mpi->stride[2] = 0; + mpi->planes[0] = mpi->planes[1] = mpi->planes[2] = NULL; + // hack to get around a check and to avoid a special-case in vd_ffmpeg.c + mpi->planes[0] = (void *)rndr; + mpi->num_planes = 1; + mpi->priv = rndr; + return VO_TRUE; +} + +static int query_format(uint32_t format) +{ + switch (format) { + case IMGFMT_YV12: + case IMGFMT_VDPAU_MPEG1: + case IMGFMT_VDPAU_MPEG2: + case IMGFMT_VDPAU_H264: + case IMGFMT_VDPAU_WMV3: + case IMGFMT_VDPAU_VC1: + return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_OSD; + } + return 0; +} + +static void DestroyVdpauObjects(void) +{ + int i; + VdpStatus vdp_st; + + free_video_specific(); + + vdp_st = vdp_presentation_queue_destroy(vdp_flip_queue); + CHECK_ST_WARNING("Error when calling vdp_presentation_queue_destroy") + + vdp_st = vdp_presentation_queue_target_destroy(vdp_flip_target); + CHECK_ST_WARNING("Error when calling vdp_presentation_queue_target_destroy") + + for (i = 0; i < NUM_OUTPUT_SURFACES; i++) { + vdp_st = vdp_output_surface_destroy(output_surfaces[i]); + output_surfaces[i] = VDP_INVALID_HANDLE; + CHECK_ST_WARNING("Error when calling vdp_output_surface_destroy") + } + + vdp_st = vdp_device_destroy(vdp_device); + CHECK_ST_WARNING("Error when calling vdp_device_destroy") +} + +static void uninit(void) +{ + if (!vo_config_count) + return; + visible_buf = 0; + + /* Destroy all vdpau objects */ + DestroyVdpauObjects(); + + free(index_data); + index_data = NULL; + +#ifdef CONFIG_XF86VM + vo_vm_close(); +#endif + vo_x11_uninit(); + + dlclose(vdpau_lib_handle); +} + +static int preinit(const char *arg) +{ + int i; + static const char *vdpaulibrary = "libvdpau.so.1"; + static const char *vdpau_device_create = "vdp_device_create_x11"; + + if (arg) { + mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] Unknown subdevice: %s\n", arg); + return ENOSYS; + } + + vdpau_lib_handle = dlopen(vdpaulibrary, RTLD_LAZY); + if (!vdpau_lib_handle) { + mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] Could not open dynamic library %s\n", + vdpaulibrary); + return -1; + } + vdp_device_create = dlsym(vdpau_lib_handle, vdpau_device_create); + if (!vdp_device_create) { + mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] Could not find function %s in %s\n", + vdpau_device_create, vdpaulibrary); + return -1; + } + if (!vo_init() || win_x11_init_vdpau_procs()) + return -1; + + decoder = VDP_INVALID_HANDLE; + for (i = 0; i < MAX_VIDEO_SURFACES; i++) + surface_render[i].surface = VDP_INVALID_HANDLE; + video_mixer = VDP_INVALID_HANDLE; + for (i = 0; i < NUM_OUTPUT_SURFACES; i++) + output_surfaces[i] = VDP_INVALID_HANDLE; + vdp_flip_queue = VDP_INVALID_HANDLE; + output_surface_width = output_surface_height = -1; + + // full grayscale palette. + for (i = 0; i < PALETTE_SIZE; ++i) + palette[i] = (i << 16) | (i << 8) | i; + index_data = NULL; + index_data_size = 0; + + return 0; +} + +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_QUERY_FORMAT: + return query_format(*(uint32_t *)data); + case VOCTRL_GET_IMAGE: + return get_image(data); + case VOCTRL_DRAW_IMAGE: + return draw_image(data); + case VOCTRL_GUISUPPORT: + return VO_TRUE; + case VOCTRL_BORDER: + vo_x11_border(); + resize(); + return VO_TRUE; + case VOCTRL_FULLSCREEN: + vo_x11_fullscreen(); + resize(); + return VO_TRUE; + case VOCTRL_GET_PANSCAN: + return VO_TRUE; + case VOCTRL_SET_PANSCAN: + resize(); + return VO_TRUE; + case VOCTRL_SET_EQUALIZER: { + va_list ap; + int value; + + va_start(ap, data); + value = va_arg(ap, int); + + va_end(ap); + return vo_x11_set_equalizer(data, value); + } + case VOCTRL_GET_EQUALIZER: { + va_list ap; + int *value; + + va_start(ap, data); + value = va_arg(ap, int *); + + va_end(ap); + return vo_x11_get_equalizer(data, value); + } + case VOCTRL_ONTOP: + vo_x11_ontop(); + return VO_TRUE; + case VOCTRL_UPDATE_SCREENINFO: + update_xinerama_info(); + return VO_TRUE; + } + return VO_NOTIMPL; +} + +/* @} */ -- cgit v1.2.3 From dea247e8b17e6d84b13b2061f2d7540d81a8beaa Mon Sep 17 00:00:00 2001 From: cehoyos Date: Mon, 16 Feb 2009 23:05:18 +0000 Subject: Add note about ffwmv3vdpau. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28618 b3059339-0415-0410-9bf9-f77b7e298cf2 --- DOCS/man/en/mplayer.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1 index 0a87922db3..7f36fbf564 100644 --- a/DOCS/man/en/mplayer.1 +++ b/DOCS/man/en/mplayer.1 @@ -3423,7 +3423,7 @@ Select the driver to use as source to overlay on top of X11. .PD 1 . .TP -.B vdpau (with \-vc ffmpeg12vdpau, ffvc1vdpau or ffh264vdpau) +.B vdpau (with \-vc ffmpeg12vdpau, ffwmv3vdpau, ffvc1vdpau or ffh264vdpau) Video output that uses VDPAU to decode video via hardware. Also supports displaying of software-decoded video. . -- cgit v1.2.3 From 288f25d8d9130e7515e854d2e65654b8667fb319 Mon Sep 17 00:00:00 2001 From: cehoyos Date: Mon, 16 Feb 2009 23:56:19 +0000 Subject: Fix #endif comment. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28619 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpcodecs/vd_ffmpeg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c index a6c9d3716b..a857c57a9d 100644 --- a/libmpcodecs/vd_ffmpeg.c +++ b/libmpcodecs/vd_ffmpeg.c @@ -922,4 +922,4 @@ static enum PixelFormat get_format(struct AVCodecContext *avctx, return selected_format; } -#endif /* CONFIG_XVMC */ +#endif /* CONFIG_XVMC || CONFIG_VDPAU */ -- cgit v1.2.3 From 991d64b31f076b9e2128dd47b17aa1554e166571 Mon Sep 17 00:00:00 2001 From: uau Date: Tue, 17 Feb 2009 00:09:15 +0000 Subject: Fix compilation without VDPAU The commit adding vo_vdpau had two bugs that broke compilation when VDPAU was not enabled. - video_out.c used "#ifdef CONFIG_VDPAU", but it's always set to 0 or 1 - In configure, MPEG1_VDPAU_DECODER was dropped from the list of libavcodec codecs to disable when moving VDPAU-related ones from the always-disabled list to a conditinal one. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28620 b3059339-0415-0410-9bf9-f77b7e298cf2 --- configure | 2 +- libvo/video_out.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 8eed59c29c..c519e40439 100755 --- a/configure +++ b/configure @@ -4311,7 +4311,7 @@ if test "$_vdpau" = yes ; then else def_vdpau='#define CONFIG_VDPAU 0' _novomodules="vdpau $_novomodules" - _libavdecoders=`echo $_libavdecoders | sed -e s/MPEG_VDPAU_DECODER// -e s/H264_VDPAU_DECODER// -e s/WMV3_VDPAU_DECODER// -e s/VC1_VDPAU_DECODER//` + _libavdecoders=`echo $_libavdecoders | sed -e s/MPEG_VDPAU_DECODER// -e s/MPEG1_VDPAU_DECODER// -e s/H264_VDPAU_DECODER// -e s/WMV3_VDPAU_DECODER// -e s/VC1_VDPAU_DECODER//` fi echores "$_vdpau" diff --git a/libvo/video_out.c b/libvo/video_out.c index 54291cfce9..2089eeb63d 100644 --- a/libvo/video_out.c +++ b/libvo/video_out.c @@ -170,7 +170,7 @@ const vo_functions_t* const video_out_drivers[] = #ifdef CONFIG_3DFX &video_out_3dfx, #endif -#ifdef CONFIG_VDPAU +#if CONFIG_VDPAU &video_out_vdpau, #endif #ifdef CONFIG_XV -- cgit v1.2.3 From de53a241ed491b9938ff49075db3842ef86c0d71 Mon Sep 17 00:00:00 2001 From: diego Date: Tue, 17 Feb 2009 02:57:10 +0000 Subject: The CONFIG_TV_TELETEXT preprocessor directive is defined/undefined, so use it with #ifdef instead of #if; fixes the warning: libvo/sub.c:1233:5: warning: "CONFIG_TV_TELETEXT" is not defined git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28621 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/sub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libvo/sub.c b/libvo/sub.c index cfd88ef9d8..196c8c9033 100644 --- a/libvo/sub.c +++ b/libvo/sub.c @@ -1230,7 +1230,7 @@ void vo_init_osd(void){ #ifdef CONFIG_DVDNAV new_osd_obj(OSDTYPE_DVDNAV); #endif -#if CONFIG_TV_TELETEXT +#ifdef CONFIG_TV_TELETEXT new_osd_obj(OSDTYPE_TELETEXT); #endif #ifdef CONFIG_FREETYPE -- cgit v1.2.3 From bc2834c3842898318932c5ac9d1db7ca54085578 Mon Sep 17 00:00:00 2001 From: diego Date: Tue, 17 Feb 2009 03:08:56 +0000 Subject: Move libavutil #includes below all others so that they do not override system functions and cause the warning: In file included from mp3lib/sr1.c:27: /mp_msg.h:115: warning: 'please_use_av_log_instead_of_printf' is an unrecognized format function type git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28622 b3059339-0415-0410-9bf9-f77b7e298cf2 --- mp3lib/sr1.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mp3lib/sr1.c b/mp3lib/sr1.c index aadb22c388..9aa4dec827 100644 --- a/mp3lib/sr1.c +++ b/mp3lib/sr1.c @@ -19,8 +19,6 @@ #include "mpg123.h" #include "huffman.h" #include "mp3.h" -#include "libavutil/common.h" -#include "libavutil/internal.h" #include "mpbswap.h" #include "cpudetect.h" //#include "liba52/mm_accel.h" @@ -28,6 +26,9 @@ #include "libvo/fastmemcpy.h" +#include "libavutil/common.h" +#include "libavutil/internal.h" + #undef fprintf #undef printf -- cgit v1.2.3 From 53067187b85ef66e7c472517cc308fe0ff29afae Mon Sep 17 00:00:00 2001 From: diego Date: Tue, 17 Feb 2009 03:15:10 +0000 Subject: Move FFmpeg #includes below all others so that they do not override system functions and cause the warning: In file included from libmpcodecs/vf_fspp.c:57: libmpcodecs/mp_image.h: In function 'new_mp_image': libmpcodecs/mp_image.h:214: warning: implicit declaration of function 'please_use_av_malloc' libmpcodecs/mp_image.h: In function 'free_mp_image': libmpcodecs/mp_image.h:226: warning: implicit declaration of function 'please_use_av_free' git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28623 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpcodecs/vf_fspp.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libmpcodecs/vf_fspp.c b/libmpcodecs/vf_fspp.c index cf3aac3768..7d5ea52e14 100644 --- a/libmpcodecs/vf_fspp.c +++ b/libmpcodecs/vf_fspp.c @@ -43,12 +43,6 @@ #include "mp_msg.h" #include "cpudetect.h" -#include "libavutil/internal.h" -#include "libavutil/intreadwrite.h" -#include "libavutil/mem.h" -#include "libavcodec/avcodec.h" -#include "libavcodec/dsputil.h" - #ifdef HAVE_MALLOC_H #include #endif @@ -58,6 +52,12 @@ #include "vf.h" #include "libvo/fastmemcpy.h" +#include "libavutil/internal.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/mem.h" +#include "libavcodec/avcodec.h" +#include "libavcodec/dsputil.h" + #undef free #undef malloc -- cgit v1.2.3 From b14c70b8f5e6a7baf3cc4af16750e5cc85d4dcd4 Mon Sep 17 00:00:00 2001 From: diego Date: Tue, 17 Feb 2009 03:20:40 +0000 Subject: Use FFmpeg instead of MPlayer MANGLE macro, they are equivalent in this particular case. Avoids the warning: In file included from libmpcodecs/vf_fspp.c:693: ./mangle.h:34:1: warning: "MANGLE" redefined In file included from libmpcodecs/vf_fspp.c:46: ./libavutil/internal.h:113:1: warning: this is the location of the previous definition git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28624 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpcodecs/vf_fspp.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libmpcodecs/vf_fspp.c b/libmpcodecs/vf_fspp.c index 7d5ea52e14..aef35ec835 100644 --- a/libmpcodecs/vf_fspp.c +++ b/libmpcodecs/vf_fspp.c @@ -690,7 +690,6 @@ const vf_info_t vf_info_fspp = { //Specific spp's dct, idct and threshold functions //I'd prefer to have them in the separate file. -#include "mangle.h" //#define MANGLE(a) #a //typedef int16_t DCTELEM; //! only int16_t -- cgit v1.2.3 From 4ed961f7e5f4c275722a826a996981c198375b47 Mon Sep 17 00:00:00 2001 From: reimar Date: Tue, 17 Feb 2009 08:05:14 +0000 Subject: 100l, reset ass_border when switching out of fullscreen mode. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28625 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_gl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c index 6126afa084..0ffcab00a4 100644 --- a/libvo/vo_gl.c +++ b/libvo/vo_gl.c @@ -155,6 +155,7 @@ static void resize(int x,int y){ glMatrixMode(GL_PROJECTION); glLoadIdentity(); + ass_border_x = ass_border_y = 0; if (vo_fs && use_aspect) { int new_w, new_h; GLdouble scale_x, scale_y; -- cgit v1.2.3 From a3dbab18138a9988f2a73cf8519094f8facd2e84 Mon Sep 17 00:00:00 2001 From: reimar Date: Tue, 17 Feb 2009 08:09:36 +0000 Subject: Cropping parameter to calc_src_dst_rects is const git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28626 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/video_out.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libvo/video_out.c b/libvo/video_out.c index 2089eeb63d..a444e680e4 100644 --- a/libvo/video_out.c +++ b/libvo/video_out.c @@ -388,7 +388,7 @@ static void src_dst_split_scaling(int src_size, int dst_size, int scaled_src_siz * * \param crop specifies the cropping border size in the left, right, top and bottom members, may be NULL */ -void calc_src_dst_rects(int src_width, int src_height, struct vo_rect *src, struct vo_rect *dst, struct vo_rect *crop) { +void calc_src_dst_rects(int src_width, int src_height, struct vo_rect *src, struct vo_rect *dst, const struct vo_rect *crop) { static const struct vo_rect no_crop = {0, 0, 0, 0, 0, 0}; int scaled_width = 0; int scaled_height = 0; -- cgit v1.2.3 From 4a8a46fafddfb4234fa99746c765e95d3a1ccd1d Mon Sep 17 00:00:00 2001 From: cehoyos Date: Tue, 17 Feb 2009 10:13:08 +0000 Subject: Fix compilation after last commit. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28627 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/video_out.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libvo/video_out.h b/libvo/video_out.h index bc63712826..61588f9efb 100644 --- a/libvo/video_out.h +++ b/libvo/video_out.h @@ -272,6 +272,6 @@ int lookup_keymap_table(const struct keymap *map, int key); struct vo_rect { int left, right, top, bottom, width, height; }; -void calc_src_dst_rects(int src_width, int src_height, struct vo_rect *src, struct vo_rect *dst, struct vo_rect *crop); +void calc_src_dst_rects(int src_width, int src_height, struct vo_rect *src, struct vo_rect *dst, const struct vo_rect *crop); #endif /* MPLAYER_VIDEO_OUT_H */ -- cgit v1.2.3 From e98a6e2bff65dbcec13eb41c99637c5e2ddcf317 Mon Sep 17 00:00:00 2001 From: diego Date: Tue, 17 Feb 2009 10:41:13 +0000 Subject: Convert HAVE_MEMALIGN into a 0/1 definition, fixes the warning: mem.c:67:7: warning: "HAVE_MEMALIGN" is not defined git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28628 b3059339-0415-0410-9bf9-f77b7e298cf2 --- configure | 2 +- liba52/liba52_changes.diff | 3 ++- liba52/parse.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/configure b/configure index c519e40439..b87532b0c0 100755 --- a/configure +++ b/configure @@ -3168,7 +3168,7 @@ cc_check && _memalign=yes if test "$_memalign" = yes ; then def_memalign='#define HAVE_MEMALIGN 1' else - def_memalign='#undef HAVE_MEMALIGN' + def_memalign='#define HAVE_MEMALIGN 0' def_map_memalign='#define memalign(a,b) malloc(b)' darwin || def_memalign_hack='#define CONFIG_MEMALIGN_HACK 1' fi diff --git a/liba52/liba52_changes.diff b/liba52/liba52_changes.diff index 9a559a5036..0e9e71c53f 100644 --- a/liba52/liba52_changes.diff +++ b/liba52/liba52_changes.diff @@ -2354,7 +2354,8 @@ +#include "mm_accel.h" +#include "libavutil/avutil.h" - #ifdef HAVE_MEMALIGN +-#ifdef HAVE_MEMALIGN ++#if HAVE_MEMALIGN /* some systems have memalign() but no declaration for it */ void * memalign (size_t align, size_t size); -#else diff --git a/liba52/parse.c b/liba52/parse.c index 92d38b482f..fff01aed5b 100644 --- a/liba52/parse.c +++ b/liba52/parse.c @@ -39,7 +39,7 @@ #include "mm_accel.h" #include "libavutil/avutil.h" -#ifdef HAVE_MEMALIGN +#if HAVE_MEMALIGN /* some systems have memalign() but no declaration for it */ void * memalign (size_t align, size_t size); #endif -- cgit v1.2.3 From be8c67909b4bb6bedf014706a53abef10ddb5a52 Mon Sep 17 00:00:00 2001 From: diego Date: Tue, 17 Feb 2009 11:16:19 +0000 Subject: Convert HAVE_MALLOC_H into a 0/1 definition, fixes the warning: mem.c:32:5: warning: "HAVE_MALLOC_H" is not defined git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28629 b3059339-0415-0410-9bf9-f77b7e298cf2 --- configure | 4 ++-- cpudetect.c | 2 +- libaf/af.c | 2 +- libmenu/vf_menu.c | 2 +- libmpcodecs/dec_audio.c | 2 +- libmpcodecs/dec_video.c | 2 +- libmpcodecs/mp_image.c | 2 +- libmpcodecs/vd.c | 2 +- libmpcodecs/vf.c | 2 +- libmpcodecs/vf_boxblur.c | 2 +- libmpcodecs/vf_delogo.c | 2 +- libmpcodecs/vf_denoise3d.c | 2 +- libmpcodecs/vf_fspp.c | 2 +- libmpcodecs/vf_hqdn3d.c | 2 +- libmpcodecs/vf_il.c | 2 +- libmpcodecs/vf_kerndeint.c | 2 +- libmpcodecs/vf_mcdeint.c | 2 +- libmpcodecs/vf_noise.c | 2 +- libmpcodecs/vf_ow.c | 2 +- libmpcodecs/vf_perspective.c | 2 +- libmpcodecs/vf_pp.c | 2 +- libmpcodecs/vf_pp7.c | 2 +- libmpcodecs/vf_qp.c | 2 +- libmpcodecs/vf_sab.c | 2 +- libmpcodecs/vf_screenshot.c | 2 +- libmpcodecs/vf_smartblur.c | 2 +- libmpcodecs/vf_spp.c | 2 +- libmpcodecs/vf_swapuv.c | 2 +- libmpcodecs/vf_unsharp.c | 2 +- libmpcodecs/vf_uspp.c | 2 +- libmpcodecs/vf_yadif.c | 2 +- libmpdemux/parse_mp4.c | 2 +- libmpdemux/video.c | 2 +- libvo/sub.c | 2 +- libvo/vo_dxr3.c | 2 +- libvo/vo_vesa.c | 2 +- loader/drv.c | 2 +- loader/ext.c | 2 +- loader/win32.c | 2 +- 39 files changed, 40 insertions(+), 40 deletions(-) diff --git a/configure b/configure index b87532b0c0..ada1be3853 100755 --- a/configure +++ b/configure @@ -3149,10 +3149,10 @@ cc_check && _malloc=yes if test "$_malloc" = yes ; then def_malloc_h='#define HAVE_MALLOC_H 1' else - def_malloc_h='#undef HAVE_MALLOC_H' + def_malloc_h='#define HAVE_MALLOC_H 0' fi # malloc.h emits a warning in FreeBSD and OpenBSD -freebsd || openbsd || dragonfly && def_malloc_h='#undef HAVE_MALLOC_H' +freebsd || openbsd || dragonfly && def_malloc_h='#define HAVE_MALLOC_H 0' echores "$_malloc" diff --git a/cpudetect.c b/cpudetect.c index 3dd3329d7e..8d306b1c3b 100644 --- a/cpudetect.c +++ b/cpudetect.c @@ -4,7 +4,7 @@ CpuCaps gCpuCaps; -#ifdef HAVE_MALLOC_H +#if HAVE_MALLOC_H #include #endif #include diff --git a/libaf/af.c b/libaf/af.c index 77fda8e320..7333896882 100644 --- a/libaf/af.c +++ b/libaf/af.c @@ -20,7 +20,7 @@ #include #include -#ifdef HAVE_MALLOC_H +#if HAVE_MALLOC_H #include #endif diff --git a/libmenu/vf_menu.c b/libmenu/vf_menu.c index 33eadf25b9..7f93b1a840 100644 --- a/libmenu/vf_menu.c +++ b/libmenu/vf_menu.c @@ -24,7 +24,7 @@ #include #include -#ifdef HAVE_MALLOC_H +#if HAVE_MALLOC_H #include #endif diff --git a/libmpcodecs/dec_audio.c b/libmpcodecs/dec_audio.c in