Mercurial > mplayer.hg
annotate libmpcodecs/vf_vo.c @ 19017:330a11fcdab2
Fix = vs == typo
author | uau |
---|---|
date | Wed, 12 Jul 2006 10:37:11 +0000 |
parents | d9a75b26da6c |
children | ed2785b4dd48 |
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 |
17012 | 5 #include "config.h" |
6 #include "mp_msg.h" | |
5507
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 |
17012 | 11 #include "libvo/video_out.h" |
5507
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 |
18917
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
17906
diff
changeset
|
15 struct priv_t {double pts; vo_functions_t *vo;}; |
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
17906
diff
changeset
|
16 #define video_out (((struct priv_t *)(vf->priv))->vo) |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
17 |
7731 | 18 static int query_format(struct vf_instance_s* vf, unsigned int fmt); /* forward declaration */ |
19 | |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
20 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
|
21 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
|
22 unsigned int flags, unsigned int outfmt){ |
5559 | 23 |
6197 | 24 if ((width <= 0) || (height <= 0) || (d_width <= 0) || (d_height <= 0)) |
25 { | |
26 mp_msg(MSGT_CPLAYER, MSGL_ERR, "VO: invalid dimensions!\n"); | |
27 return 0; | |
28 } | |
29 | |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7731
diff
changeset
|
30 if(video_out->info) |
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7731
diff
changeset
|
31 { const vo_info_t *info = video_out->info; |
5559 | 32 mp_msg(MSGT_CPLAYER,MSGL_INFO,"VO: [%s] %dx%d => %dx%d %s %s%s%s%s\n",info->short_name, |
33 width, height, | |
34 d_width, d_height, | |
35 vo_format_name(outfmt), | |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
10052
diff
changeset
|
36 (flags&VOFLAG_FULLSCREEN)?" [fs]":"", |
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
10052
diff
changeset
|
37 (flags&VOFLAG_MODESWITCHING)?" [vm]":"", |
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
10052
diff
changeset
|
38 (flags&VOFLAG_SWSCALE)?" [zoom]":"", |
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
10052
diff
changeset
|
39 (flags&VOFLAG_FLIPPING)?" [flip]":""); |
5559 | 40 mp_msg(MSGT_CPLAYER,MSGL_V,"VO: Description: %s\n",info->name); |
41 mp_msg(MSGT_CPLAYER,MSGL_V,"VO: Author: %s\n", info->author); | |
42 if(info->comment && strlen(info->comment) > 0) | |
43 mp_msg(MSGT_CPLAYER,MSGL_V,"VO: Comment: %s\n", info->comment); | |
44 } | |
45 | |
7687 | 46 // save vo's stride capability for the wanted colorspace: |
47 vf->default_caps=query_format(vf,outfmt) & VFCAP_ACCEPT_STRIDE; | |
48 | |
7125 | 49 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
|
50 return 0; |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7731
diff
changeset
|
51 |
5511 | 52 ++vo_config_count; |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
53 return 1; |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
54 } |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
55 |
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
|
56 static int control(struct vf_instance_s* vf, int request, void* data) |
6780 | 57 { |
5643 | 58 switch(request){ |
6780 | 59 #ifdef USE_OSD |
5643 | 60 case VFCTRL_DRAW_OSD: |
6157 | 61 if(!vo_config_count) return CONTROL_FALSE; // vo not configured? |
5643 | 62 video_out->draw_osd(); |
63 return CONTROL_TRUE; | |
6780 | 64 #endif |
10052
b358b7509e1a
sort of a hack, but at least this lets the framerate-increasing
rfelker
parents:
9593
diff
changeset
|
65 case VFCTRL_FLIP_PAGE: |
b358b7509e1a
sort of a hack, but at least this lets the framerate-increasing
rfelker
parents:
9593
diff
changeset
|
66 { |
b358b7509e1a
sort of a hack, but at least this lets the framerate-increasing
rfelker
parents:
9593
diff
changeset
|
67 if(!vo_config_count) return CONTROL_FALSE; // vo not configured? |
b358b7509e1a
sort of a hack, but at least this lets the framerate-increasing
rfelker
parents:
9593
diff
changeset
|
68 video_out->flip_page(); |
b358b7509e1a
sort of a hack, but at least this lets the framerate-increasing
rfelker
parents:
9593
diff
changeset
|
69 return CONTROL_TRUE; |
b358b7509e1a
sort of a hack, but at least this lets the framerate-increasing
rfelker
parents:
9593
diff
changeset
|
70 } |
6780 | 71 case VFCTRL_SET_EQUALIZER: |
72 { | |
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
|
73 vf_equalizer_t *eq=data; |
6780 | 74 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
|
75 return((video_out->control(VOCTRL_SET_EQUALIZER, eq->item, eq->value) == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE); |
6780 | 76 } |
77 case VFCTRL_GET_EQUALIZER: | |
78 { | |
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
|
79 vf_equalizer_t *eq=data; |
6780 | 80 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
|
81 return((video_out->control(VOCTRL_GET_EQUALIZER, eq->item, &eq->value) == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE); |
6780 | 82 } |
5643 | 83 } |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
84 // return video_out->control(request,data); |
5519 | 85 return CONTROL_UNKNOWN; |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
86 } |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
87 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
88 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
|
89 int flags=video_out->control(VOCTRL_QUERY_FORMAT,&fmt); |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5559
diff
changeset
|
90 // draw_slice() accepts stride, draw_frame() doesn't: |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5559
diff
changeset
|
91 if(flags) |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5559
diff
changeset
|
92 if(fmt==IMGFMT_YV12 || fmt==IMGFMT_I420 || fmt==IMGFMT_IYUV) |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5559
diff
changeset
|
93 flags|=VFCAP_ACCEPT_STRIDE; |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5559
diff
changeset
|
94 return flags; |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
95 } |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
96 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
97 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
|
98 mp_image_t *mpi){ |
5511 | 99 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
|
100 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
|
101 } |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
102 |
7368 | 103 static int put_image(struct vf_instance_s* vf, |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
104 mp_image_t *mpi, double pts){ |
7368 | 105 if(!vo_config_count) return 0; // vo not configured? |
18917
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
17906
diff
changeset
|
106 // record pts (potentially modified by filters) for main loop |
d9a75b26da6c
Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents:
17906
diff
changeset
|
107 ((struct priv_t *)vf->priv)->pts = pts; |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
108 // first check, maybe the vo/vf plugin implements draw_image using mpi: |
7368 | 109 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
|
110 // 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
|
111 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
|
112 // blit frame: |
7687 | 113 // if(mpi->flags&MP_IMGFLAG_PLANAR) |
114 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
|
115 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
|
116 else |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
117 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
|
118 } |
7368 | 119 return 1; |
5507
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 |
9560
ae2ce6ebc1fa
Pass start slice to the vo it make dr + slice implemantation easier
albeu
parents:
8148
diff
changeset
|
122 static void start_slice(struct vf_instance_s* vf, |
ae2ce6ebc1fa
Pass start slice to the vo it make dr + slice implemantation easier
albeu
parents:
8148
diff
changeset
|
123 mp_image_t *mpi) { |
ae2ce6ebc1fa
Pass start slice to the vo it make dr + slice implemantation easier
albeu
parents:
8148
diff
changeset
|
124 if(!vo_config_count) return; // vo not configured? |
ae2ce6ebc1fa
Pass start slice to the vo it make dr + slice implemantation easier
albeu
parents:
8148
diff
changeset
|
125 video_out->control(VOCTRL_START_SLICE,mpi); |
ae2ce6ebc1fa
Pass start slice to the vo it make dr + slice implemantation easier
albeu
parents:
8148
diff
changeset
|
126 } |
ae2ce6ebc1fa
Pass start slice to the vo it make dr + slice implemantation easier
albeu
parents:
8148
diff
changeset
|
127 |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
128 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
|
129 unsigned char** src, int* stride, int w,int h, int x, int y){ |
5511 | 130 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
|
131 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
|
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 //===========================================================================// |
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 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
|
137 vf->config=config; |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
138 vf->control=control; |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
139 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
|
140 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
|
141 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
|
142 vf->draw_slice=draw_slice; |
9560
ae2ce6ebc1fa
Pass start slice to the vo it make dr + slice implemantation easier
albeu
parents:
8148
diff
changeset
|
143 vf->start_slice=start_slice; |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
144 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
|
145 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
|
146 // 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
|
147 return 1; |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
148 } |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
149 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
150 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
|
151 "libvo wrapper", |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
152 "vo", |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
153 "A'rpi", |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
154 "for internal use", |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9560
diff
changeset
|
155 open, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9560
diff
changeset
|
156 NULL |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
157 }; |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
158 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
159 //===========================================================================// |