[Mplayerxp-cvslog] SF.net SVN: mplayerxp:[86] mplayerxp
Brought to you by:
olov
From: <nic...@us...> - 2010-01-08 15:24:06
|
Revision: 86 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=86&view=rev Author: nickols_k Date: 2010-01-08 15:23:59 +0000 (Fri, 08 Jan 2010) Log Message: ----------- use parallel video filtering Modified Paths: -------------- mplayerxp/cfg-mplayer.h mplayerxp/configure mplayerxp/libmpcodecs/dec_video.c mplayerxp/libmpcodecs/vd_ffmpeg.c mplayerxp/libvo/x11_common.c mplayerxp/mp_image.c mplayerxp/mplayer.c mplayerxp/postproc/vf.c mplayerxp/postproc/vf.h mplayerxp/postproc/vf_2xsai.c mplayerxp/postproc/vf_aspect.c mplayerxp/postproc/vf_format.c mplayerxp/postproc/vf_pp.c mplayerxp/postproc/vf_rectangle.c mplayerxp/postproc/vf_scale.c mplayerxp/postproc/vf_smartblur.c mplayerxp/postproc/vf_swapuv.c mplayerxp/postproc/vf_vo.c mplayerxp/postproc/vf_yuvcsp.c mplayerxp/postproc/vf_yuy2.c mplayerxp/postproc/vf_yvu9.c Modified: mplayerxp/cfg-mplayer.h =================================================================== --- mplayerxp/cfg-mplayer.h 2010-01-07 10:44:05 UTC (rev 85) +++ mplayerxp/cfg-mplayer.h 2010-01-08 15:23:59 UTC (rev 86) @@ -78,6 +78,7 @@ #endif extern int enable_xp; +extern int enable_gomp; extern int enable_xp_audio; extern unsigned vo_da_buffs; extern unsigned vo_use_bm; @@ -250,6 +251,8 @@ {"xp", &enable_xp, CONF_TYPE_INT, CONF_RANGE, 0, 4, NULL}, {"noxp", &enable_xp, CONF_TYPE_FLAG, 0, 1, 0, NULL}, + {"gomp", &enable_gomp, CONF_TYPE_FLAG, 0, 0, 1, NULL}, + {"nogomp", &enable_gomp, CONF_TYPE_FLAG, 0, 1, 0, NULL}, {"da_buffs", &vo_da_buffs, CONF_TYPE_INT, CONF_RANGE, 4, 1024, NULL}, {"enable_bm", &vo_use_bm, CONF_TYPE_FLAG, 0, 0, 1, NULL}, {"enable_bm2", &vo_use_bm, CONF_TYPE_FLAG, 0, 0, 2, NULL}, Modified: mplayerxp/configure =================================================================== --- mplayerxp/configure 2010-01-07 10:44:05 UTC (rev 85) +++ mplayerxp/configure 2010-01-08 15:23:59 UTC (rev 86) @@ -325,6 +325,7 @@ enabled gomp && check_ldflags -fopenmp || disable gomp enabled gomp && require2 gomp omp.h omp_get_thread_num -lgomp || disable gomp enabled gomp && check_cflags -fopenmp || disable gomp +print_config HAVE_ mp_config.h mp_config.mak gomp #enabled gomp && check_cflags -ftree-parallelize-loops=4 ##################################################### add_cflags "-Werror-implicit-function-declaration" Modified: mplayerxp/libmpcodecs/dec_video.c =================================================================== --- mplayerxp/libmpcodecs/dec_video.c 2010-01-07 10:44:05 UTC (rev 85) +++ mplayerxp/libmpcodecs/dec_video.c 2010-01-08 15:23:59 UTC (rev 86) @@ -1,5 +1,9 @@ #include "mp_config.h" +#ifdef HAVE_GOMP +#include <omp.h> +#endif + #include <stdio.h> #ifdef HAVE_MALLOC #include <malloc.h> @@ -76,9 +80,16 @@ sh_video->inited=0; } +#ifdef HAVE_GOMP +#define MPDEC_THREAD_COND (VF_FLAGS_THREADS|VF_FLAGS_SLICES) +static unsigned smp_num_cpus=1; +static unsigned use_vf_threads=0; +extern int enable_gomp; +#endif + extern char *video_codec; int init_video(sh_video_t *sh_video,const char* codecname,const char * vfm,int status){ - unsigned o_bps,bpp; + unsigned o_bps,bpp,vf_flags; sh_video->codec=NULL; MSG_DBG3("init_video(%p, %s, %s, %i)\n",sh_video,codecname,vfm,status); while((sh_video->codec=find_codec(sh_video->format, @@ -153,6 +164,20 @@ ,o_bps); // Yeah! We got it! sh_video->inited=1; +#ifdef HAVE_GOMP + if(enable_gomp) { + smp_num_cpus=omp_get_num_procs(); + vf_flags=vf_query_flags(sh_video->vfilter); + use_vf_threads=0; + MSG_V("[mpdec] vf_flags=%08X num_cpus=%u\n",vf_flags,smp_num_cpus); + if(((vf_flags&MPDEC_THREAD_COND)==MPDEC_THREAD_COND) && (smp_num_cpus>1)) { + MSG_OK("[VC] using %u threads for video filters\n",smp_num_cpus); + use_vf_threads=1; + } + } +#else + MSG_V("[mpdec] GOMP was not compiled-in! Using single threaded video filtering!\n"); +#endif return 1; } return 0; @@ -223,6 +248,33 @@ if(!(mpi->flags&(MP_IMGFLAG_DRAW_CALLBACK))){ MSG_DBG2("Put whole frame\n"); +#ifdef HAVE_GOMP + if(use_vf_threads) { + unsigned i,y,h_step,h; + mp_image_t ampi[smp_num_cpus]; + h_step = mpi->h/smp_num_cpus; + h=mpi->height; + mpi->height=h_step; + y=0; + for(i=0;i<smp_num_cpus;i++) { + ampi[i] = *mpi; + ampi[i].y = y; + ampi[i].height = h_step; + y+=h_step; + } +#pragma omp parallel for shared(vf) private(i) + for(i=0;i<smp_num_cpus;i++) { + MSG_V("Put slice[%u %u] in threads\n",ampi[i].y,h_step); + vf->put_slice(vf,&i[i]); + } + if(y<h) { + ampi[0].y = y; + ampi[0].height = h - ampi[0].y; + vf->put_slice(vf,&i[0]); + } + } + else +#endif vf->put_slice(vf,mpi); } t2=GetTimer()-t2; Modified: mplayerxp/libmpcodecs/vd_ffmpeg.c =================================================================== --- mplayerxp/libmpcodecs/vd_ffmpeg.c 2010-01-07 10:44:05 UTC (rev 85) +++ mplayerxp/libmpcodecs/vd_ffmpeg.c 2010-01-08 15:23:59 UTC (rev 86) @@ -549,7 +549,7 @@ mpi->qstride=vdff_ctx->lavc_picture->qstride; mpi->pict_type=vdff_ctx->lavc_picture->pict_type; mpi->qscale_type=vdff_ctx->lavc_picture->qscale_type; - + if(sh->codec->outfmt[sh->outfmtidx] == IMGFMT_I420 || sh->codec->outfmt[sh->outfmtidx] == IMGFMT_IYUV) { Modified: mplayerxp/libvo/x11_common.c =================================================================== --- mplayerxp/libvo/x11_common.c 2010-01-07 10:44:05 UTC (rev 85) +++ mplayerxp/libvo/x11_common.c 2010-01-08 15:23:59 UTC (rev 86) @@ -664,12 +664,13 @@ "ColormapNotify", "ClientMessage", "MappingNotify", +"GenericEvent", "LASTEvent" }; static const char * __FASTCALL__ evt_name(unsigned num) { - if(num >=2 && num <= 35) return evt_names[num-2]; + if(num >=2 && num <= 36) return evt_names[num-2]; else return "Unknown"; } @@ -692,7 +693,7 @@ ret|=VO_EVENT_EXPOSE; break; case ConfigureNotify: - nw = Event.xconfigure.width; + nw = Event.xconfigure.width; nh = Event.xconfigure.height; if(adjust_size) adj_ret = (*adjust_size)(vo_dwidth,vo_dheight,&nw,&nh); ow = vo_dwidth; @@ -717,7 +718,7 @@ ret|=VO_EVENT_RESIZE; break; case KeyPress: - { + { int key; XLookupString( &Event.xkey,buf,sizeof(buf),&keySym,&stat ); #ifdef XF86XK_AudioPause Modified: mplayerxp/mp_image.c =================================================================== --- mplayerxp/mp_image.c 2010-01-07 10:44:05 UTC (rev 85) +++ mplayerxp/mp_image.c 2010-01-08 15:23:59 UTC (rev 86) @@ -192,7 +192,7 @@ if(!mpi->stride[0]) mpi->stride[0]=mpi->width*mpi->bpp/8; } mpi->flags|=MP_IMGFLAG_ALLOCATED; - + return mpi; } Modified: mplayerxp/mplayer.c =================================================================== --- mplayerxp/mplayer.c 2010-01-07 10:44:05 UTC (rev 85) +++ mplayerxp/mplayer.c 2010-01-08 15:23:59 UTC (rev 86) @@ -97,6 +97,7 @@ #include "dec_ahead.h" int enable_xp=XP_VAPlay; +int enable_gomp=1; volatile int dec_ahead_active_frame=0; volatile unsigned abs_dec_ahead_active_frame=0; volatile unsigned loc_dec_ahead_active_frame=0; Modified: mplayerxp/postproc/vf.c =================================================================== --- mplayerxp/postproc/vf.c 2010-01-07 10:44:05 UTC (rev 85) +++ mplayerxp/postproc/vf.c 2010-01-08 15:23:59 UTC (rev 86) @@ -536,6 +536,18 @@ }while(next); } +unsigned __FASTCALL__ vf_query_flags(vf_instance_t*vfi) +{ + unsigned flags=0xFFFFFFFF; + vf_instance_t *next=vfi; + do{ + MSG_DBG2("[vf_%s] flags: %08X\n",next->info->name,next->info->flags); + flags &= next->info->flags; + next=next->next; + }while(next); + return flags; +} + static int __FASTCALL__ dummy_config(struct vf_instance_s* vf, int width, int height, int d_width, int d_height, unsigned int voflags, unsigned int outfmt,void *tune){ Modified: mplayerxp/postproc/vf.h =================================================================== --- mplayerxp/postproc/vf.h 2010-01-07 10:44:05 UTC (rev 85) +++ mplayerxp/postproc/vf.h 2010-01-08 15:23:59 UTC (rev 86) @@ -8,8 +8,9 @@ struct vf_instance_s; struct vf_priv_s; -#define VF_FLAGS_THREADS 0x00000000UL /**< requires to be applied within of threads */ -#define VF_FLAGS_OSD 0x00000001UL /**< requires to be applied during page flipping */ +#define VF_FLAGS_THREADS 0x00000001UL /**< Thread safe plugin (requires to be applied within of threads) */ +#define VF_FLAGS_OSD 0x00000002UL /**< requires to be applied during page flipping */ +#define VF_FLAGS_SLICES 0x00000004UL /**< really can draw slices (requires to be applied on SMP etc) */ typedef struct vf_info_s { const char *info; @@ -115,6 +116,9 @@ vf_instance_t* __FASTCALL__ append_filters(vf_instance_t* last); +/* returns ANDed flags of whole chain */ +unsigned __FASTCALL__ vf_query_flags(vf_instance_t*vfi); + void vf_help(); void __FASTCALL__ vf_uninit_filter(vf_instance_t* vf); Modified: mplayerxp/postproc/vf_2xsai.c =================================================================== --- mplayerxp/postproc/vf_2xsai.c 2010-01-07 10:44:05 UTC (rev 85) +++ mplayerxp/postproc/vf_2xsai.c 2010-01-08 15:23:59 UTC (rev 86) @@ -291,7 +291,7 @@ dmpi->planes[0], dmpi->stride[0], mpi->x, mpi->y, mpi->w, mpi->h); - + return vf_next_put_slice(vf,dmpi); } @@ -319,7 +319,7 @@ "2xsai", "A'rpi", "http://elektron.its.tudelft.nl/~dalikifa/", - VF_FLAGS_THREADS, + VF_FLAGS_THREADS|VF_FLAGS_SLICES, vf_open }; Modified: mplayerxp/postproc/vf_aspect.c =================================================================== --- mplayerxp/postproc/vf_aspect.c 2010-01-07 10:44:05 UTC (rev 85) +++ mplayerxp/postproc/vf_aspect.c 2010-01-08 15:23:59 UTC (rev 86) @@ -66,7 +66,7 @@ "aspect", "Rich Felker", "", - VF_FLAGS_THREADS, + VF_FLAGS_THREADS|VF_FLAGS_SLICES, vf_open }; Modified: mplayerxp/postproc/vf_format.c =================================================================== --- mplayerxp/postproc/vf_format.c 2010-01-07 10:44:05 UTC (rev 85) +++ mplayerxp/postproc/vf_format.c 2010-01-08 15:23:59 UTC (rev 86) @@ -118,7 +118,7 @@ "noformat", "A'rpi", "FIXME! get_image()/put_image()", - VF_FLAGS_THREADS, + VF_FLAGS_THREADS|VF_FLAGS_SLICES, vf_no_open }; Modified: mplayerxp/postproc/vf_pp.c =================================================================== --- mplayerxp/postproc/vf_pp.c 2010-01-07 10:44:05 UTC (rev 85) +++ mplayerxp/postproc/vf_pp.c 2010-01-08 15:23:59 UTC (rev 86) @@ -109,7 +109,7 @@ MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_PREFER_ALIGNED_STRIDE, (mpi->w+7)&(~7),(mpi->h+7)&(~7)); } - + if(vf->priv->pp || !(mpi->flags&MP_IMGFLAG_DIRECT)){ // do the postprocessing! (or copy if no DR) pp2_postprocess(mpi->planes ,mpi->stride, Modified: mplayerxp/postproc/vf_rectangle.c =================================================================== --- mplayerxp/postproc/vf_rectangle.c 2010-01-07 10:44:05 UTC (rev 85) +++ mplayerxp/postproc/vf_rectangle.c 2010-01-08 15:23:59 UTC (rev 86) @@ -70,7 +70,7 @@ mpi->w, mpi->h); memcpy_pic(dmpi->planes[0],mpi->planes[0],mpi->w*bpp, mpi->h, - dmpi->stride[0],mpi->stride[0]); + dmpi->stride[0],mpi->stride[0]); if(mpi->flags&MP_IMGFLAG_PLANAR && mpi->flags&MP_IMGFLAG_YUV){ memcpy_pic(dmpi->planes[1],mpi->planes[1], mpi->w>>mpi->chroma_x_shift, mpi->h>>mpi->chroma_y_shift, Modified: mplayerxp/postproc/vf_scale.c =================================================================== --- mplayerxp/postproc/vf_scale.c 2010-01-07 10:44:05 UTC (rev 85) +++ mplayerxp/postproc/vf_scale.c 2010-01-08 15:23:59 UTC (rev 86) @@ -103,7 +103,7 @@ ret= vf_next_query_format(vf, outfmt_list[i],w,h); vf->priv->query_format_cache[i]= ret+1; } - + MSG_DBG2("scale: query(%s) -> %d\n",vo_format_name(format),ret&3); if(ret&VFCAP_CSP_SUPPORTED_BY_HW){ best=format; // no conversion -> bingo! @@ -129,12 +129,12 @@ int vo_flags; int int_sws_flags=0; SwsFilter *srcFilter, *dstFilter; - + if(!best){ MSG_WARN("SwScale: no supported outfmt found :(\n"); return 0; } - + vo_flags=vf_next_query_format(vf,best,d_width,d_height); MSG_DBG2("vf_scale: %i=vf_next_query_format(%p,%X,%u,%u);\n" ,vo_flags,vf,best,d_width,d_height); @@ -193,14 +193,14 @@ if(vf->priv->h==-2) vf->priv->h=vf->priv->w*d_height/d_width; break; } - + if(vf->priv->h<0) vf->priv->h=height; else if(vf->priv->h==0) vf->priv->h=d_height; - + // free old ctx: if(vf->priv->ctx) sws_freeContext(vf->priv->ctx); if(vf->priv->ctx2)sws_freeContext(vf->priv->ctx2); - + // new swscaler: sws_getFlagsAndFilterFromCmdLine(&int_sws_flags, &srcFilter, &dstFilter); MSG_DBG2("vf_scale: sws_getFlagsAndFilterFromCmdLine(...);\n"); @@ -317,7 +317,7 @@ sws_scale_ordered(sws2, src2, src_stride2, y>>1, h>>1, dst2, dst_stride2); }else{ sws_scale_ordered(sws1, src, src_stride, y, h, dst, dst_stride); - } + } } static int __FASTCALL__ put_slice(struct vf_instance_s* vf, mp_image_t *mpi){ @@ -493,7 +493,7 @@ MSG_V("SwScale params: %d x %d (-1=no scaling)\n", vf->priv->w, vf->priv->h); - + return 1; } @@ -535,7 +535,7 @@ sws_lum_gblur, sws_chr_gblur, sws_lum_sharpen, sws_chr_sharpen, sws_chr_hshift, sws_chr_vshift, verbose>1); - + switch(sws_flags) { case 0: *flags|= SWS_FAST_BILINEAR; break; @@ -587,7 +587,7 @@ "scale", "A'rpi", "", - VF_FLAGS_THREADS, + VF_FLAGS_THREADS|VF_FLAGS_SLICES, vf_open }; @@ -597,7 +597,7 @@ "fmtcvt", "A'rpi", "", - VF_FLAGS_THREADS, + VF_FLAGS_THREADS|VF_FLAGS_SLICES, vf_open }; Modified: mplayerxp/postproc/vf_smartblur.c =================================================================== --- mplayerxp/postproc/vf_smartblur.c 2010-01-07 10:44:05 UTC (rev 85) +++ mplayerxp/postproc/vf_smartblur.c 2010-01-08 15:23:59 UTC (rev 86) @@ -191,7 +191,7 @@ dmpi->stride[1], dmpi->stride[1], vf->priv->chroma.radius, vf->priv->chroma.strength); vBlur(dmpi->planes[2], dmpi->planes[2], cw,ch, dmpi->stride[2], dmpi->stride[2], vf->priv->chroma.radius, vf->priv->chroma.strength); - + return vf_next_put_slice(vf,dmpi); } Modified: mplayerxp/postproc/vf_swapuv.c =================================================================== --- mplayerxp/postproc/vf_swapuv.c 2010-01-07 10:44:05 UTC (rev 85) +++ mplayerxp/postproc/vf_swapuv.c 2010-01-08 15:23:59 UTC (rev 86) @@ -56,7 +56,7 @@ static int __FASTCALL__ put_slice(struct vf_instance_s* vf, mp_image_t *mpi){ mp_image_t *dmpi; - + if(mpi->flags&MP_IMGFLAG_DIRECT){ dmpi=(mp_image_t*)mpi->priv; } else { @@ -70,7 +70,7 @@ dmpi->stride[2]=mpi->stride[1]; dmpi->width=mpi->width; } - + vf_clone_mpi_attributes(dmpi, mpi); return vf_next_put_slice(vf,dmpi); } @@ -104,7 +104,7 @@ "swapuv", "Michael Niedermayer", "", - VF_FLAGS_THREADS, + VF_FLAGS_THREADS|VF_FLAGS_SLICES, vf_open }; Modified: mplayerxp/postproc/vf_vo.c =================================================================== --- mplayerxp/postproc/vf_vo.c 2010-01-07 10:44:05 UTC (rev 85) +++ mplayerxp/postproc/vf_vo.c 2010-01-08 15:23:59 UTC (rev 86) @@ -159,7 +159,7 @@ "vo", "A'rpi", "for internal use", - VF_FLAGS_THREADS, + VF_FLAGS_THREADS|VF_FLAGS_SLICES, vf_open }; Modified: mplayerxp/postproc/vf_yuvcsp.c =================================================================== --- mplayerxp/postproc/vf_yuvcsp.c 2010-01-07 10:44:05 UTC (rev 85) +++ mplayerxp/postproc/vf_yuvcsp.c 2010-01-08 15:23:59 UTC (rev 86) @@ -38,7 +38,7 @@ vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, mpi->w, mpi->h); - + y_in = mpi->planes[0]; cb_in = mpi->planes[1]; cr_in = mpi->planes[2]; @@ -46,27 +46,18 @@ y_out = vf->dmpi->planes[0]; cb_out = vf->dmpi->planes[1]; cr_out = vf->dmpi->planes[2]; -#ifdef _OPENMP -#pragma omp parallel sections -{ -#pragma omp section -#endif - for (i = 0; i < mpi->height; i++) - for (j = 0; j < mpi->width; j++) + + for (i = mpi->y; i < mpi->height; i++) + for (j = mpi->x; j < mpi->width; j++) y_out[i*vf->dmpi->stride[0]+j] = clamp_y(y_in[i*mpi->stride[0]+j]); -#ifdef _OPENMP -#pragma omp section -#endif - for (i = 0; i < mpi->chroma_height; i++) - for (j = 0; j < mpi->chroma_width; j++) + for (i = (mpi->y)>>(mpi->chroma_y_shift); i < mpi->chroma_height; i++) + for (j = (mpi->x)>>(mpi->chroma_x_shift); j < mpi->chroma_width; j++) { cb_out[i*vf->dmpi->stride[1]+j] = clamp_c(cb_in[i*mpi->stride[1]+j]); cr_out[i*vf->dmpi->stride[2]+j] = clamp_c(cr_in[i*mpi->stride[2]+j]); } -#ifdef _OPENMP -} -#endif + return vf_next_put_slice(vf,vf->dmpi); } @@ -103,7 +94,7 @@ "yuvcsp", "Alex Beregszaszi", "", - VF_FLAGS_THREADS, + VF_FLAGS_THREADS|VF_FLAGS_SLICES, vf_open }; Modified: mplayerxp/postproc/vf_yuy2.c =================================================================== --- mplayerxp/postproc/vf_yuy2.c 2010-01-07 10:44:05 UTC (rev 85) +++ mplayerxp/postproc/vf_yuy2.c 2010-01-08 15:23:59 UTC (rev 86) @@ -21,12 +21,12 @@ unsigned int flags, unsigned int outfmt,void *tune){ sws_rgb2rgb_init(get_sws_cpuflags()); - + if(vf_next_query_format(vf,IMGFMT_YUY2,d_width,d_height)<=0){ MSG_ERR("yuy2 isn't supported by next filter/vo :(\n"); return 0; } - + return vf_next_config(vf,width,height,d_width,d_height,flags,IMGFMT_YUY2,tune); } @@ -44,9 +44,9 @@ else yv12toyuy2(mpi->planes[0],mpi->planes[1],mpi->planes[2], dmpi->planes[0], mpi->w,mpi->h, mpi->stride[0],mpi->stride[1],dmpi->stride[0]); - + vf_clone_mpi_attributes(dmpi, mpi); - + return vf_next_put_slice(vf,dmpi); } Modified: mplayerxp/postproc/vf_yvu9.c =================================================================== --- mplayerxp/postproc/vf_yvu9.c 2010-01-07 10:44:05 UTC (rev 85) +++ mplayerxp/postproc/vf_yvu9.c 2010-01-08 15:23:59 UTC (rev 86) @@ -18,12 +18,12 @@ static int __FASTCALL__ config(struct vf_instance_s* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt,void *tune){ - + if(vf_next_query_format(vf,IMGFMT_YV12,d_width,d_height)<=0){ MSG_ERR("yv12 isn't supported by next filter/vo :(\n"); return 0; } - + return vf_next_config(vf,width,height,d_width,d_height,flags,IMGFMT_YV12,tune); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |