[MPlayer-dev-eng] [PATCH] avoid useless full xvmc reinit with -fixed-vo if possible
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Wed Feb 14 15:25:05 CET 2007
Hello,
if the source format remains unchanged there is no need to reinit the
hardware, buffers etc. which with xvmc in addition causes several blue
frames.
I added a voflag to indicate this condition because I think other vos
can make use of it as well.
Unfortunately config() can not be completely skipped because the
geometry stuff is config() - which btw. I'd like to change as there is a
massive code duplication with nearly every vo using the same code.
Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libmpcodecs/vf_vo.c
===================================================================
--- libmpcodecs/vf_vo.c (revision 22215)
+++ libmpcodecs/vf_vo.c (working copy)
@@ -62,6 +62,9 @@
// save vo's stride capability for the wanted colorspace:
vf->default_caps=query_format(vf,outfmt) & VFCAP_ACCEPT_STRIDE;
+ if (vo_config_count && width == vo_config_width &&
+ height == vo_config_height && outfmt == vo_config_outfmt)
+ flags |= VOFLAG_SAME_INPUT;
if(video_out->config(width,height,d_width,d_height,flags,"MPlayer",outfmt))
return 0;
@@ -71,6 +74,8 @@
#endif
++vo_config_count;
+ vo_config_width = width; vo_config_height = height;
+ vo_config_outfmt = outfmt;
return 1;
}
Index: libvo/video_out.c
===================================================================
--- libvo/video_out.c (revision 22215)
+++ libvo/video_out.c (working copy)
@@ -29,6 +29,8 @@
int vo_screenheight=0;
int vo_config_count=0;
+int vo_config_width, vo_config_height;
+unsigned int vo_config_outfmt;
// requested resolution/bpp: (-x -y -bpp options)
int vo_dx=0;
Index: libvo/video_out.h
===================================================================
--- libvo/video_out.h (revision 22215)
+++ libvo/video_out.h (working copy)
@@ -93,6 +93,7 @@
#define VOFLAG_MODESWITCHING 0x02
#define VOFLAG_SWSCALE 0x04
#define VOFLAG_FLIPPING 0x08
+#define VOFLAG_SAME_INPUT 0x10
#define VOFLAG_XOVERLAY_SUB_VO 0x10000
typedef struct vo_info_s
@@ -187,6 +188,8 @@
extern int vo_flags;
extern int vo_config_count;
+extern int vo_config_width, vo_config_height;
+extern unsigned int vo_config_outfmt;
extern int xinerama_screen;
extern int xinerama_x;
Index: mencoder.c
===================================================================
--- mencoder.c (revision 22215)
+++ mencoder.c (working copy)
@@ -91,6 +91,8 @@
int vo_doublebuffering=0;
int vo_directrendering=0;
int vo_config_count=0;
+int vo_config_width, vo_config_height;
+unsigned int vo_config_outfmt;
int forced_subs_only=0;
//--------------------------
Index: libvo/vo_xvmc.c
===================================================================
--- libvo/vo_xvmc.c (revision 22215)
+++ libvo/vo_xvmc.c (working copy)
@@ -417,35 +417,10 @@
return 0;
}
-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){
+static int init_xvmc(int width, int height, unsigned format) {
int i,mode_id,rez;
int numblocks,blocks_per_macroblock;//bpmb we have 6,8,12
-//from vo_xv
-char *hello = (title == NULL) ? "XvMC render" : title;
-XSizeHints hint;
-XVisualInfo vinfo;
-XGCValues xgcv;
-XSetWindowAttributes xswa;
-XWindowAttributes attribs;
-unsigned long xswamask;
-int depth;
-#ifdef HAVE_XF86VM
-int vm=0;
-unsigned int modeline_width, modeline_height;
-static uint32_t vm_width;
-static uint32_t vm_height;
-#endif
-//end of vo_xv
-
- if( !IMGFMT_IS_XVMC(format) )
- {
- assert(0);//should never happen, abort on debug or
- return 1;//return error on relese
- }
-
// Find free port that supports MC, by querying adaptors
if( xv_port != 0 || number_of_surfaces != 0 ){
xvmc_free();
@@ -597,7 +572,38 @@
}
vo_xv_enable_vsync();//it won't break anything
+ return 0;
+}
+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){
+//from vo_xv
+char *hello = (title == NULL) ? "XvMC render" : title;
+XSizeHints hint;
+XVisualInfo vinfo;
+XGCValues xgcv;
+XSetWindowAttributes xswa;
+XWindowAttributes attribs;
+unsigned long xswamask;
+int depth;
+#ifdef HAVE_XF86VM
+int vm=0;
+unsigned int modeline_width, modeline_height;
+static uint32_t vm_width;
+static uint32_t vm_height;
+#endif
+//end of vo_xv
+
+ if( !IMGFMT_IS_XVMC(format) )
+ {
+ assert(0);//should never happen, abort on debug or
+ return 1;//return error on relese
+ }
+
+ if (!(flags & VOFLAG_SAME_INPUT))
+ if (init_xvmc(width, height, format) < 0) return -1;
+
//taken from vo_xv
panscan_init();
More information about the MPlayer-dev-eng
mailing list