annotate libmpcodecs/vf_vo.c @ 6817:3e62e9cd1816

removed query_vaa
author alex
date Fri, 26 Jul 2002 12:42:43 +0000
parents b16cb6cbff5a
children 54578e5a8050
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
1 #include <stdio.h>
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
2 #include <stdlib.h>
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
3 #include <string.h>
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
4 #include <stdarg.h>
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
5
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
6 #include "../config.h"
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
7 #include "../mp_msg.h"
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
8
5607
1972c3475d93 mp_image.h and img_format.h moved to libmpcodecs
arpi
parents: 5565
diff changeset
9 #include "mp_image.h"
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
10 #include "vf.h"
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
11
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
12 #include "../libvo/video_out.h"
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
13
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
14 //===========================================================================//
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
15
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
16 #define video_out ((vo_functions_t*)(vf->priv))
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
17
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
18 static int config(struct vf_instance_s* vf,
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
19 int width, int height, int d_width, int d_height,
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
20 unsigned int flags, unsigned int outfmt){
5559
7a73663095fc print VO info
arpi
parents: 5519
diff changeset
21
6197
48d0e89e8b21 report error if bad dimensions requested (<=0)
alex
parents: 6157
diff changeset
22 if ((width <= 0) || (height <= 0) || (d_width <= 0) || (d_height <= 0))
48d0e89e8b21 report error if bad dimensions requested (<=0)
alex
parents: 6157
diff changeset
23 {
48d0e89e8b21 report error if bad dimensions requested (<=0)
alex
parents: 6157
diff changeset
24 mp_msg(MSGT_CPLAYER, MSGL_ERR, "VO: invalid dimensions!\n");
48d0e89e8b21 report error if bad dimensions requested (<=0)
alex
parents: 6157
diff changeset
25 return 0;
48d0e89e8b21 report error if bad dimensions requested (<=0)
alex
parents: 6157
diff changeset
26 }
48d0e89e8b21 report error if bad dimensions requested (<=0)
alex
parents: 6157
diff changeset
27
5559
7a73663095fc print VO info
arpi
parents: 5519
diff changeset
28 if(video_out->get_info)
7a73663095fc print VO info
arpi
parents: 5519
diff changeset
29 { const vo_info_t *info = video_out->get_info();
7a73663095fc print VO info
arpi
parents: 5519
diff changeset
30 mp_msg(MSGT_CPLAYER,MSGL_INFO,"VO: [%s] %dx%d => %dx%d %s %s%s%s%s\n",info->short_name,
7a73663095fc print VO info
arpi
parents: 5519
diff changeset
31 width, height,
7a73663095fc print VO info
arpi
parents: 5519
diff changeset
32 d_width, d_height,
7a73663095fc print VO info
arpi
parents: 5519
diff changeset
33 vo_format_name(outfmt),
6138
523014df7d32 big cosmetics patch, cleanup of messages printed by mplayer and libs.
arpi
parents: 5853
diff changeset
34 (flags&1)?" [fs]":"",
523014df7d32 big cosmetics patch, cleanup of messages printed by mplayer and libs.
arpi
parents: 5853
diff changeset
35 (flags&2)?" [vm]":"",
523014df7d32 big cosmetics patch, cleanup of messages printed by mplayer and libs.
arpi
parents: 5853
diff changeset
36 (flags&4)?" [zoom]":"",
523014df7d32 big cosmetics patch, cleanup of messages printed by mplayer and libs.
arpi
parents: 5853
diff changeset
37 (flags&8)?" [flip]":"");
5559
7a73663095fc print VO info
arpi
parents: 5519
diff changeset
38 mp_msg(MSGT_CPLAYER,MSGL_V,"VO: Description: %s\n",info->name);
7a73663095fc print VO info
arpi
parents: 5519
diff changeset
39 mp_msg(MSGT_CPLAYER,MSGL_V,"VO: Author: %s\n", info->author);
7a73663095fc print VO info
arpi
parents: 5519
diff changeset
40 if(info->comment && strlen(info->comment) > 0)
7a73663095fc print VO info
arpi
parents: 5519
diff changeset
41 mp_msg(MSGT_CPLAYER,MSGL_V,"VO: Comment: %s\n", info->comment);
7a73663095fc print VO info
arpi
parents: 5519
diff changeset
42 }
7a73663095fc print VO info
arpi
parents: 5519
diff changeset
43
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
44 if(video_out->config(width,height,d_width,d_height,flags,"MPlayer",outfmt,NULL))
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
45 return 0;
5511
7a24a067f0af vo_config_count now counts calls to vo->config()
arpi
parents: 5508
diff changeset
46 ++vo_config_count;
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
47 return 1;
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
48 }
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
49
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
50 static int control(struct vf_instance_s* vf, int request, void* data, ...)
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
51 {
5643
3d9de27d9bd0 OSD handled by vf control()
arpi
parents: 5607
diff changeset
52 switch(request){
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
53 #ifdef USE_OSD
5643
3d9de27d9bd0 OSD handled by vf control()
arpi
parents: 5607
diff changeset
54 case VFCTRL_DRAW_OSD:
6157
alex
parents: 6138
diff changeset
55 if(!vo_config_count) return CONTROL_FALSE; // vo not configured?
5643
3d9de27d9bd0 OSD handled by vf control()
arpi
parents: 5607
diff changeset
56 video_out->draw_osd();
3d9de27d9bd0 OSD handled by vf control()
arpi
parents: 5607
diff changeset
57 return CONTROL_TRUE;
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
58 #endif
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
59 case VFCTRL_SET_EQUALIZER:
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
60 {
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
61 va_list ap;
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
62 int value;
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
63
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
64 if(!vo_config_count) return CONTROL_FALSE; // vo not configured?
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
65 va_start(ap, data);
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
66 value = va_arg(ap, int);
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
67 va_end(ap);
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
68 return((video_out->control(VOCTRL_SET_EQUALIZER, data, (int *)value) == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE);
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
69 }
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
70 case VFCTRL_GET_EQUALIZER:
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
71 {
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
72 va_list ap;
6786
b16cb6cbff5a eq reworked
alex
parents: 6780
diff changeset
73 int *value;
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
74
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
75 if(!vo_config_count) return CONTROL_FALSE; // vo not configured?
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
76 va_start(ap, data);
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
77 value = va_arg(ap, int);
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
78 va_end(ap);
6786
b16cb6cbff5a eq reworked
alex
parents: 6780
diff changeset
79 return((video_out->control(VOCTRL_GET_EQUALIZER, data, value) == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE);
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
80 }
5643
3d9de27d9bd0 OSD handled by vf control()
arpi
parents: 5607
diff changeset
81 }
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
82 // return video_out->control(request,data);
5519
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5511
diff changeset
83 return CONTROL_UNKNOWN;
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
84 }
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
85
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
86 static int query_format(struct vf_instance_s* vf, unsigned int fmt){
5565
0b301fec999a capabilities support -> automatic insertion of scale, expand, pp
arpi
parents: 5559
diff changeset
87 int flags=video_out->control(VOCTRL_QUERY_FORMAT,&fmt);
0b301fec999a capabilities support -> automatic insertion of scale, expand, pp
arpi
parents: 5559
diff changeset
88 // draw_slice() accepts stride, draw_frame() doesn't:
0b301fec999a capabilities support -> automatic insertion of scale, expand, pp
arpi
parents: 5559
diff changeset
89 if(flags)
0b301fec999a capabilities support -> automatic insertion of scale, expand, pp
arpi
parents: 5559
diff changeset
90 if(fmt==IMGFMT_YV12 || fmt==IMGFMT_I420 || fmt==IMGFMT_IYUV)
0b301fec999a capabilities support -> automatic insertion of scale, expand, pp
arpi
parents: 5559
diff changeset
91 flags|=VFCAP_ACCEPT_STRIDE;
0b301fec999a capabilities support -> automatic insertion of scale, expand, pp
arpi
parents: 5559
diff changeset
92 return flags;
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
93 }
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
94
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
95 static void get_image(struct vf_instance_s* vf,
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
96 mp_image_t *mpi){
5511
7a24a067f0af vo_config_count now counts calls to vo->config()
arpi
parents: 5508
diff changeset
97 if(vo_directrendering && vo_config_count)
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
98 video_out->control(VOCTRL_GET_IMAGE,mpi);
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
99 }
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
100
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
101 static void put_image(struct vf_instance_s* vf,
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
102 mp_image_t *mpi){
5511
7a24a067f0af vo_config_count now counts calls to vo->config()
arpi
parents: 5508
diff changeset
103 if(!vo_config_count) return; // vo not configured?
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
104 // first check, maybe the vo/vf plugin implements draw_image using mpi:
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
105 if(video_out->control(VOCTRL_DRAW_IMAGE,mpi)==VO_TRUE) return; // done.
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
106 // nope, fallback to old draw_frame/draw_slice:
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
107 if(!(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK))){
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
108 // blit frame:
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
109 if(mpi->flags&MP_IMGFLAG_PLANAR)
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
110 video_out->draw_slice(mpi->planes,mpi->stride,mpi->w,mpi->h,mpi->x,mpi->y);
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
111 else
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
112 video_out->draw_frame(mpi->planes);
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
113 }
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
114 }
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
115
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
116 static void draw_slice(struct vf_instance_s* vf,
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
117 unsigned char* src, int* stride, int w,int h, int x, int y){
5511
7a24a067f0af vo_config_count now counts calls to vo->config()
arpi
parents: 5508
diff changeset
118 if(!vo_config_count) return; // vo not configured?
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
119 video_out->draw_slice(src,stride,w,h,x,y);
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
120 }
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
121
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
122 //===========================================================================//
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
123
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
124 static int open(vf_instance_t *vf, char* args){
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
125 vf->config=config;
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
126 vf->control=control;
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
127 vf->query_format=query_format;
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
128 vf->get_image=get_image;
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
129 vf->put_image=put_image;
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
130 vf->draw_slice=draw_slice;
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
131 vf->priv=(void*)args; // video_out
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
132 if(!video_out) return 0; // no vo ?
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
133 // if(video_out->preinit(args)) return 0; // preinit failed
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
134 return 1;
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
135 }
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
136
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
137 vf_info_t vf_info_vo = {
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
138 "libvo wrapper",
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
139 "vo",
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
140 "A'rpi",
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
141 "for internal use",
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
142 open
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
143 };
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
144
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
145 //===========================================================================//