11 #include "libvo/video_out.h"
13 //===========================================================================//
15 #define video_out ((vo_functions_t*)(vf->priv))
17 static int query_format(struct vf_instance_s
* vf
, unsigned int fmt
); /* forward declaration */
19 static int config(struct vf_instance_s
* vf
,
20 int width
, int height
, int d_width
, int d_height
,
21 unsigned int flags
, unsigned int outfmt
){
23 if ((width
<= 0) || (height
<= 0) || (d_width
<= 0) || (d_height
<= 0))
25 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, "VO: invalid dimensions!\n");
30 { const vo_info_t
*info
= video_out
->info
;
31 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,"VO: [%s] %dx%d => %dx%d %s %s%s%s%s\n",info
->short_name
,
34 vo_format_name(outfmt
),
35 (flags
&VOFLAG_FULLSCREEN
)?" [fs]":"",
36 (flags
&VOFLAG_MODESWITCHING
)?" [vm]":"",
37 (flags
&VOFLAG_SWSCALE
)?" [zoom]":"",
38 (flags
&VOFLAG_FLIPPING
)?" [flip]":"");
39 mp_msg(MSGT_CPLAYER
,MSGL_V
,"VO: Description: %s\n",info
->name
);
40 mp_msg(MSGT_CPLAYER
,MSGL_V
,"VO: Author: %s\n", info
->author
);
41 if(info
->comment
&& strlen(info
->comment
) > 0)
42 mp_msg(MSGT_CPLAYER
,MSGL_V
,"VO: Comment: %s\n", info
->comment
);
45 // save vo's stride capability for the wanted colorspace:
46 vf
->default_caps
=query_format(vf
,outfmt
) & VFCAP_ACCEPT_STRIDE
;
48 if(video_out
->config(width
,height
,d_width
,d_height
,flags
,"MPlayer",outfmt
))
55 static int control(struct vf_instance_s
* vf
, int request
, void* data
)
60 if(!vo_config_count
) return CONTROL_FALSE
; // vo not configured?
61 video_out
->draw_osd();
64 case VFCTRL_FLIP_PAGE
:
66 if(!vo_config_count
) return CONTROL_FALSE
; // vo not configured?
67 video_out
->flip_page();
70 case VFCTRL_SET_EQUALIZER
:
72 vf_equalizer_t
*eq
=data
;
73 if(!vo_config_count
) return CONTROL_FALSE
; // vo not configured?
74 return((video_out
->control(VOCTRL_SET_EQUALIZER
, eq
->item
, eq
->value
) == VO_TRUE
) ? CONTROL_TRUE
: CONTROL_FALSE
);
76 case VFCTRL_GET_EQUALIZER
:
78 vf_equalizer_t
*eq
=data
;
79 if(!vo_config_count
) return CONTROL_FALSE
; // vo not configured?
80 return((video_out
->control(VOCTRL_GET_EQUALIZER
, eq
->item
, &eq
->value
) == VO_TRUE
) ? CONTROL_TRUE
: CONTROL_FALSE
);
83 // return video_out->control(request,data);
84 return CONTROL_UNKNOWN
;
87 static int query_format(struct vf_instance_s
* vf
, unsigned int fmt
){
88 int flags
=video_out
->control(VOCTRL_QUERY_FORMAT
,&fmt
);
89 // draw_slice() accepts stride, draw_frame() doesn't:
91 if(fmt
==IMGFMT_YV12
|| fmt
==IMGFMT_I420
|| fmt
==IMGFMT_IYUV
)
92 flags
|=VFCAP_ACCEPT_STRIDE
;
96 static void get_image(struct vf_instance_s
* vf
,
98 if(vo_directrendering
&& vo_config_count
)
99 video_out
->control(VOCTRL_GET_IMAGE
,mpi
);
102 static int put_image(struct vf_instance_s
* vf
,
103 mp_image_t
*mpi
, double pts
){
104 if(!vo_config_count
) return 0; // vo not configured?
105 // first check, maybe the vo/vf plugin implements draw_image using mpi:
106 if(video_out
->control(VOCTRL_DRAW_IMAGE
,mpi
)==VO_TRUE
) return 1; // done.
107 // nope, fallback to old draw_frame/draw_slice:
108 if(!(mpi
->flags
&(MP_IMGFLAG_DIRECT
|MP_IMGFLAG_DRAW_CALLBACK
))){
110 // if(mpi->flags&MP_IMGFLAG_PLANAR)
111 if(vf
->default_caps
&VFCAP_ACCEPT_STRIDE
)
112 video_out
->draw_slice(mpi
->planes
,mpi
->stride
,mpi
->w
,mpi
->h
,mpi
->x
,mpi
->y
);
114 video_out
->draw_frame(mpi
->planes
);
119 static void start_slice(struct vf_instance_s
* vf
,
121 if(!vo_config_count
) return; // vo not configured?
122 video_out
->control(VOCTRL_START_SLICE
,mpi
);
125 static void draw_slice(struct vf_instance_s
* vf
,
126 unsigned char** src
, int* stride
, int w
,int h
, int x
, int y
){
127 if(!vo_config_count
) return; // vo not configured?
128 video_out
->draw_slice(src
,stride
,w
,h
,x
,y
);
131 //===========================================================================//
133 static int open(vf_instance_t
*vf
, char* args
){
136 vf
->query_format
=query_format
;
137 vf
->get_image
=get_image
;
138 vf
->put_image
=put_image
;
139 vf
->draw_slice
=draw_slice
;
140 vf
->start_slice
=start_slice
;
141 vf
->priv
=(void*)args
; // video_out
142 if(!video_out
) return 0; // no vo ?
143 // if(video_out->preinit(args)) return 0; // preinit failed
147 vf_info_t vf_info_vo
= {
156 //===========================================================================//