small compilation fix
[mplayer/glamo.git] / libmpcodecs / vf_vo.c
blob476de8af92b10b4a6423b3639d55c655996fdf8a
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
5 #include "../config.h"
6 #include "../mp_msg.h"
8 #include "mp_image.h"
9 #include "vf.h"
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");
26 return 0;
29 if(video_out->info)
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,
32 width, height,
33 d_width, d_height,
34 vo_format_name(outfmt),
35 (flags&1)?" [fs]":"",
36 (flags&2)?" [vm]":"",
37 (flags&4)?" [zoom]":"",
38 (flags&8)?" [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))
49 return 0;
51 ++vo_config_count;
52 return 1;
55 static int control(struct vf_instance_s* vf, int request, void* data)
57 switch(request){
58 #ifdef USE_OSD
59 case VFCTRL_DRAW_OSD:
60 if(!vo_config_count) return CONTROL_FALSE; // vo not configured?
61 video_out->draw_osd();
62 return CONTROL_TRUE;
63 #endif
64 case VFCTRL_FLIP_PAGE:
66 if(!vo_config_count) return CONTROL_FALSE; // vo not configured?
67 video_out->flip_page();
68 return CONTROL_TRUE;
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:
90 if(flags)
91 if(fmt==IMGFMT_YV12 || fmt==IMGFMT_I420 || fmt==IMGFMT_IYUV)
92 flags|=VFCAP_ACCEPT_STRIDE;
93 return flags;
96 static void get_image(struct vf_instance_s* vf,
97 mp_image_t *mpi){
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){
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))){
109 // blit frame:
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);
113 else
114 video_out->draw_frame(mpi->planes);
116 return 1;
119 static void start_slice(struct vf_instance_s* vf,
120 mp_image_t *mpi) {
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){
134 vf->config=config;
135 vf->control=control;
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
144 return 1;
147 vf_info_t vf_info_vo = {
148 "libvo wrapper",
149 "vo",
150 "A'rpi",
151 "for internal use",
152 open,
153 NULL
156 //===========================================================================//