Mercurial > mplayer.hg
annotate libmpcodecs/vf_vo.c @ 9335:de287fe94511
lang & country codes from ISO & utf8 requirement (ideas from Tobias Diedrich <td at sim dot uni-hannover dot de>
btw, sorry that i didn mention the names of the ppl from whom all the past ideas came from ...
author | michael |
---|---|
date | Sat, 08 Feb 2003 09:07:13 +0000 |
parents | 5b39e79af5fe |
children | ae2ce6ebc1fa |
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> |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
4 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
5 #include "../config.h" |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
6 #include "../mp_msg.h" |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
7 |
5607 | 8 #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
|
9 #include "vf.h" |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
10 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
11 #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
|
12 |
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 #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
|
16 |
7731 | 17 static int query_format(struct vf_instance_s* vf, unsigned int fmt); /* forward declaration */ |
18 | |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
19 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
|
20 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
|
21 unsigned int flags, unsigned int outfmt){ |
5559 | 22 |
6197 | 23 if ((width <= 0) || (height <= 0) || (d_width <= 0) || (d_height <= 0)) |
24 { | |
25 mp_msg(MSGT_CPLAYER, MSGL_ERR, "VO: invalid dimensions!\n"); | |
26 return 0; | |
27 } | |
28 | |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7731
diff
changeset
|
29 if(video_out->info) |
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7731
diff
changeset
|
30 { const vo_info_t *info = video_out->info; |
5559 | 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), | |
6138
523014df7d32
big cosmetics patch, cleanup of messages printed by mplayer and libs.
arpi
parents:
5853
diff
changeset
|
35 (flags&1)?" [fs]":"", |
523014df7d32
big cosmetics patch, cleanup of messages printed by mplayer and libs.
arpi
parents:
5853
diff
changeset
|
36 (flags&2)?" [vm]":"", |
523014df7d32
big cosmetics patch, cleanup of messages printed by mplayer and libs.
arpi
parents:
5853
diff
changeset
|
37 (flags&4)?" [zoom]":"", |
523014df7d32
big cosmetics patch, cleanup of messages printed by mplayer and libs.
arpi
parents:
5853
diff
changeset
|
38 (flags&8)?" [flip]":""); |
5559 | 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); | |
43 } | |
44 | |
7687 | 45 // save vo's stride capability for the wanted colorspace: |
46 vf->default_caps=query_format(vf,outfmt) & VFCAP_ACCEPT_STRIDE; | |
47 | |
7125 | 48 if(video_out->config(width,height,d_width,d_height,flags,"MPlayer",outfmt)) |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
49 return 0; |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7731
diff
changeset
|
50 |
5511 | 51 ++vo_config_count; |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
52 return 1; |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
53 } |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
54 |
6832
54578e5a8050
... removed from vf's control(), sing struct for equalizer. based on patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
arpi
parents:
6786
diff
changeset
|
55 static int control(struct vf_instance_s* vf, int request, void* data) |
6780 | 56 { |
5643 | 57 switch(request){ |
6780 | 58 #ifdef USE_OSD |
5643 | 59 case VFCTRL_DRAW_OSD: |
6157 | 60 if(!vo_config_count) return CONTROL_FALSE; // vo not configured? |
5643 | 61 video_out->draw_osd(); |
62 return CONTROL_TRUE; | |
6780 | 63 #endif |
64 case VFCTRL_SET_EQUALIZER: | |
65 { | |
6832
54578e5a8050
... removed from vf's control(), sing struct for equalizer. based on patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
arpi
parents:
6786
diff
changeset
|
66 vf_equalizer_t *eq=data; |
6780 | 67 if(!vo_config_count) return CONTROL_FALSE; // vo not configured? |
6832
54578e5a8050
... removed from vf's control(), sing struct for equalizer. based on patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
arpi
parents:
6786
diff
changeset
|
68 return((video_out->control(VOCTRL_SET_EQUALIZER, eq->item, eq->value) == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE); |
6780 | 69 } |
70 case VFCTRL_GET_EQUALIZER: | |
71 { | |
6832
54578e5a8050
... removed from vf's control(), sing struct for equalizer. based on patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
arpi
parents:
6786
diff
changeset
|
72 vf_equalizer_t *eq=data; |
6780 | 73 if(!vo_config_count) return CONTROL_FALSE; // vo not configured? |
6832
54578e5a8050
... removed from vf's control(), sing struct for equalizer. based on patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
arpi
parents:
6786
diff
changeset
|
74 return((video_out->control(VOCTRL_GET_EQUALIZER, eq->item, &eq->value) == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE); |
6780 | 75 } |
5643 | 76 } |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
77 // return video_out->control(request,data); |
5519 | 78 return CONTROL_UNKNOWN; |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
79 } |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
80 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
81 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
|
82 int flags=video_out->control(VOCTRL_QUERY_FORMAT,&fmt); |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5559
diff
changeset
|
83 // draw_slice() accepts stride, draw_frame() doesn't: |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5559
diff
changeset
|
84 if(flags) |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5559
diff
changeset
|
85 if(fmt==IMGFMT_YV12 || fmt==IMGFMT_I420 || fmt==IMGFMT_IYUV) |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5559
diff
changeset
|
86 flags|=VFCAP_ACCEPT_STRIDE; |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5559
diff
changeset
|
87 return flags; |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
88 } |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
89 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
90 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
|
91 mp_image_t *mpi){ |
5511 | 92 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
|
93 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
|
94 } |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
95 |
7368 | 96 static int put_image(struct vf_instance_s* vf, |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
97 mp_image_t *mpi){ |
7368 | 98 if(!vo_config_count) return 0; // vo not configured? |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
99 // first check, maybe the vo/vf plugin implements draw_image using mpi: |
7368 | 100 if(video_out->control(VOCTRL_DRAW_IMAGE,mpi)==VO_TRUE) return 1; // done. |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
101 // 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
|
102 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
|
103 // blit frame: |
7687 | 104 // if(mpi->flags&MP_IMGFLAG_PLANAR) |
105 if(vf->default_caps&VFCAP_ACCEPT_STRIDE) | |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
106 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
|
107 else |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
108 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
|
109 } |
7368 | 110 return 1; |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
111 } |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
112 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
113 static void draw_slice(struct vf_instance_s* vf, |
7220
e3ecccc7e505
warning fixes by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents:
7125
diff
changeset
|
114 unsigned char** src, int* stride, int w,int h, int x, int y){ |
5511 | 115 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
|
116 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
|
117 } |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
118 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
119 //===========================================================================// |
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 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
|
122 vf->config=config; |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
123 vf->control=control; |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
124 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
|
125 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
|
126 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
|
127 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
|
128 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
|
129 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
|
130 // 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
|
131 return 1; |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
132 } |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
133 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
134 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
|
135 "libvo wrapper", |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
136 "vo", |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
137 "A'rpi", |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
138 "for internal use", |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
139 open |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
140 }; |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
141 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
142 //===========================================================================// |