annotate libmpcodecs/vf_vo.c @ 19576:3e7ce339d74b

Add EOSD support to vf_vo.
author eugeni
date Mon, 28 Aug 2006 19:10:11 +0000
parents ed2785b4dd48
children 52a319698894
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>
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
4
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15212
diff changeset
5 #include "config.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15212
diff changeset
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
1972c3475d93 mp_image.h and img_format.h moved to libmpcodecs
arpi
parents: 5565
diff changeset
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
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15212
diff changeset
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
19576
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
13 #ifdef USE_ASS
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
14 #include "libass/ass.h"
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
15 #include "libass/ass_mp.h"
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
16 extern ass_track_t* ass_track;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
17 #endif
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
18
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
19 //===========================================================================//
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
20
19576
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
21 extern int sub_visibility;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
22 extern double sub_delay;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
23
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
24 typedef struct vf_vo_data_s {
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
25 double pts;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
26 vo_functions_t *vo;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
27 } vf_vo_data_t;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
28
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
29 struct vf_priv_s {
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
30 vf_vo_data_t* vf_vo_data;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
31 #ifdef USE_ASS
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
32 ass_instance_t* ass_priv;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
33 ass_settings_t ass_settings;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
34 #endif
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
35 };
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
36 #define video_out (vf->priv->vf_vo_data->vo)
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
37
7731
1f8961f2b34c compiler warning fixes
arpi
parents: 7687
diff changeset
38 static int query_format(struct vf_instance_s* vf, unsigned int fmt); /* forward declaration */
1f8961f2b34c compiler warning fixes
arpi
parents: 7687
diff changeset
39
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
40 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
41 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
42 unsigned int flags, unsigned int outfmt){
5559
7a73663095fc print VO info
arpi
parents: 5519
diff changeset
43
6197
48d0e89e8b21 report error if bad dimensions requested (<=0)
alex
parents: 6157
diff changeset
44 if ((width <= 0) || (height <= 0) || (d_width <= 0) || (d_height <= 0))
48d0e89e8b21 report error if bad dimensions requested (<=0)
alex
parents: 6157
diff changeset
45 {
48d0e89e8b21 report error if bad dimensions requested (<=0)
alex
parents: 6157
diff changeset
46 mp_msg(MSGT_CPLAYER, MSGL_ERR, "VO: invalid dimensions!\n");
48d0e89e8b21 report error if bad dimensions requested (<=0)
alex
parents: 6157
diff changeset
47 return 0;
48d0e89e8b21 report error if bad dimensions requested (<=0)
alex
parents: 6157
diff changeset
48 }
48d0e89e8b21 report error if bad dimensions requested (<=0)
alex
parents: 6157
diff changeset
49
8148
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7731
diff changeset
50 if(video_out->info)
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7731
diff changeset
51 { const vo_info_t *info = video_out->info;
5559
7a73663095fc print VO info
arpi
parents: 5519
diff changeset
52 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
53 width, height,
7a73663095fc print VO info
arpi
parents: 5519
diff changeset
54 d_width, d_height,
7a73663095fc print VO info
arpi
parents: 5519
diff changeset
55 vo_format_name(outfmt),
15212
05aa13cdf92f replace VO and VF numeric flags with #defined identifiers
henry
parents: 10052
diff changeset
56 (flags&VOFLAG_FULLSCREEN)?" [fs]":"",
05aa13cdf92f replace VO and VF numeric flags with #defined identifiers
henry
parents: 10052
diff changeset
57 (flags&VOFLAG_MODESWITCHING)?" [vm]":"",
05aa13cdf92f replace VO and VF numeric flags with #defined identifiers
henry
parents: 10052
diff changeset
58 (flags&VOFLAG_SWSCALE)?" [zoom]":"",
05aa13cdf92f replace VO and VF numeric flags with #defined identifiers
henry
parents: 10052
diff changeset
59 (flags&VOFLAG_FLIPPING)?" [flip]":"");
5559
7a73663095fc print VO info
arpi
parents: 5519
diff changeset
60 mp_msg(MSGT_CPLAYER,MSGL_V,"VO: Description: %s\n",info->name);
7a73663095fc print VO info
arpi
parents: 5519
diff changeset
61 mp_msg(MSGT_CPLAYER,MSGL_V,"VO: Author: %s\n", info->author);
7a73663095fc print VO info
arpi
parents: 5519
diff changeset
62 if(info->comment && strlen(info->comment) > 0)
7a73663095fc print VO info
arpi
parents: 5519
diff changeset
63 mp_msg(MSGT_CPLAYER,MSGL_V,"VO: Comment: %s\n", info->comment);
7a73663095fc print VO info
arpi
parents: 5519
diff changeset
64 }
7a73663095fc print VO info
arpi
parents: 5519
diff changeset
65
7687
a9a19a991a70 support for VFCAP_ACCEPT_STRIDE in vo drivers
arpi
parents: 7368
diff changeset
66 // save vo's stride capability for the wanted colorspace:
a9a19a991a70 support for VFCAP_ACCEPT_STRIDE in vo drivers
arpi
parents: 7368
diff changeset
67 vf->default_caps=query_format(vf,outfmt) & VFCAP_ACCEPT_STRIDE;
a9a19a991a70 support for VFCAP_ACCEPT_STRIDE in vo drivers
arpi
parents: 7368
diff changeset
68
7125
3aeb57cc8ac6 10l fix
alex
parents: 6832
diff changeset
69 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
70 return 0;
8148
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7731
diff changeset
71
19576
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
72 #ifdef USE_ASS
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
73 if (vf->priv->ass_priv) {
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
74 vf->priv->ass_settings.font_size_coeff = ass_font_scale;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
75 vf->priv->ass_settings.line_spacing = ass_line_spacing;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
76 vf->priv->ass_settings.use_margins = ass_use_margins;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
77 }
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
78 #endif
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
79
5511
7a24a067f0af vo_config_count now counts calls to vo->config()
arpi
parents: 5508
diff changeset
80 ++vo_config_count;
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
81 return 1;
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
82 }
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
83
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
84 static int control(struct vf_instance_s* vf, int request, void* data)
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
85 {
5643
3d9de27d9bd0 OSD handled by vf control()
arpi
parents: 5607
diff changeset
86 switch(request){
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
87 #ifdef USE_OSD
5643
3d9de27d9bd0 OSD handled by vf control()
arpi
parents: 5607
diff changeset
88 case VFCTRL_DRAW_OSD:
6157
alex
parents: 6138
diff changeset
89 if(!vo_config_count) return CONTROL_FALSE; // vo not configured?
5643
3d9de27d9bd0 OSD handled by vf control()
arpi
parents: 5607
diff changeset
90 video_out->draw_osd();
3d9de27d9bd0 OSD handled by vf control()
arpi
parents: 5607
diff changeset
91 return CONTROL_TRUE;
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
92 #endif
10052
b358b7509e1a sort of a hack, but at least this lets the framerate-increasing
rfelker
parents: 9593
diff changeset
93 case VFCTRL_FLIP_PAGE:
b358b7509e1a sort of a hack, but at least this lets the framerate-increasing
rfelker
parents: 9593
diff changeset
94 {
b358b7509e1a sort of a hack, but at least this lets the framerate-increasing
rfelker
parents: 9593
diff changeset
95 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
96 video_out->flip_page();
b358b7509e1a sort of a hack, but at least this lets the framerate-increasing
rfelker
parents: 9593
diff changeset
97 return CONTROL_TRUE;
b358b7509e1a sort of a hack, but at least this lets the framerate-increasing
rfelker
parents: 9593
diff changeset
98 }
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
99 case VFCTRL_SET_EQUALIZER:
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
100 {
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
101 vf_equalizer_t *eq=data;
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
102 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
103 return((video_out->control(VOCTRL_SET_EQUALIZER, eq->item, eq->value) == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE);
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
104 }
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
105 case VFCTRL_GET_EQUALIZER:
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
106 {
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
107 vf_equalizer_t *eq=data;
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
108 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
109 return((video_out->control(VOCTRL_GET_EQUALIZER, eq->item, &eq->value) == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE);
6780
5bf3ed8a17c4 equalizer reworked
alex
parents: 6197
diff changeset
110 }
19576
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
111 #ifdef USE_ASS
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
112 case VFCTRL_INIT_EOSD:
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
113 {
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
114 vf->priv->ass_priv = ass_init();
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
115 return vf->priv->ass_priv ? CONTROL_TRUE : CONTROL_FALSE;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
116 }
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
117 case VFCTRL_DRAW_EOSD:
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
118 {
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
119 ass_image_t* images = 0;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
120 double pts = vf->priv->vf_vo_data->pts;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
121 if (!vo_config_count || !vf->priv->ass_priv) return CONTROL_FALSE;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
122 if (sub_visibility && vf->priv->ass_priv && ass_track && (pts != MP_NOPTS_VALUE)) {
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
123 mp_eosd_res_t res;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
124 ass_settings_t* const settings = &vf->priv->ass_settings;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
125 memset(&res, 0, sizeof(res));
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
126 if (video_out->control(VOCTRL_GET_EOSD_RES, &res) == VO_TRUE) {
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
127 settings->frame_width = res.w;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
128 settings->frame_height = res.h;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
129 settings->top_margin = res.mt;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
130 settings->bottom_margin = res.mb;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
131 settings->left_margin = res.ml;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
132 settings->right_margin = res.mr;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
133 settings->aspect = ((double)res.w) / res.h;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
134 }
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
135 ass_configure(vf->priv->ass_priv, settings);
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
136
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
137 images = ass_render_frame(vf->priv->ass_priv, ass_track, (pts+sub_delay) * 1000 + .5);
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
138 }
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
139 return (video_out->control(VOCTRL_DRAW_EOSD, images) == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
140 }
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
141 #endif
5643
3d9de27d9bd0 OSD handled by vf control()
arpi
parents: 5607
diff changeset
142 }
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
143 // return video_out->control(request,data);
5519
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5511
diff changeset
144 return CONTROL_UNKNOWN;
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
145 }
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
146
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
147 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
148 int flags=video_out->control(VOCTRL_QUERY_FORMAT,&fmt);
0b301fec999a capabilities support -> automatic insertion of scale, expand, pp
arpi
parents: 5559
diff changeset
149 // draw_slice() accepts stride, draw_frame() doesn't:
0b301fec999a capabilities support -> automatic insertion of scale, expand, pp
arpi
parents: 5559
diff changeset
150 if(flags)
0b301fec999a capabilities support -> automatic insertion of scale, expand, pp
arpi
parents: 5559
diff changeset
151 if(fmt==IMGFMT_YV12 || fmt==IMGFMT_I420 || fmt==IMGFMT_IYUV)
0b301fec999a capabilities support -> automatic insertion of scale, expand, pp
arpi
parents: 5559
diff changeset
152 flags|=VFCAP_ACCEPT_STRIDE;
0b301fec999a capabilities support -> automatic insertion of scale, expand, pp
arpi
parents: 5559
diff changeset
153 return flags;
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
154 }
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
155
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
156 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
157 mp_image_t *mpi){
5511
7a24a067f0af vo_config_count now counts calls to vo->config()
arpi
parents: 5508
diff changeset
158 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
159 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
160 }
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
161
7368
a894e99c1e51 changing return type of put_image void->int
arpi
parents: 7220
diff changeset
162 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
163 mp_image_t *mpi, double pts){
7368
a894e99c1e51 changing return type of put_image void->int
arpi
parents: 7220
diff changeset
164 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
165 // record pts (potentially modified by filters) for main loop
19576
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
166 vf->priv->vf_vo_data->pts = pts;
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
167 // first check, maybe the vo/vf plugin implements draw_image using mpi:
7368
a894e99c1e51 changing return type of put_image void->int
arpi
parents: 7220
diff changeset
168 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
169 // 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
170 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
171 // blit frame:
7687
a9a19a991a70 support for VFCAP_ACCEPT_STRIDE in vo drivers
arpi
parents: 7368
diff changeset
172 // if(mpi->flags&MP_IMGFLAG_PLANAR)
a9a19a991a70 support for VFCAP_ACCEPT_STRIDE in vo drivers
arpi
parents: 7368
diff changeset
173 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
174 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
175 else
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
176 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
177 }
7368
a894e99c1e51 changing return type of put_image void->int
arpi
parents: 7220
diff changeset
178 return 1;
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
179 }
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
180
9560
ae2ce6ebc1fa Pass start slice to the vo it make dr + slice implemantation easier
albeu
parents: 8148
diff changeset
181 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
182 mp_image_t *mpi) {
ae2ce6ebc1fa Pass start slice to the vo it make dr + slice implemantation easier
albeu
parents: 8148
diff changeset
183 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
184 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
185 }
ae2ce6ebc1fa Pass start slice to the vo it make dr + slice implemantation easier
albeu
parents: 8148
diff changeset
186
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
187 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
188 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
189 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
190 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
191 }
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
192
19576
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
193 static void uninit(struct vf_instance_s* vf)
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
194 {
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
195 if (vf->priv) {
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
196 if (vf->priv->ass_priv)
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
197 ass_done(vf->priv->ass_priv);
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
198 free(vf->priv);
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
199 }
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
200 }
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
201 //===========================================================================//
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
202
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
203 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
204 vf->config=config;
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
205 vf->control=control;
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
206 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
207 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
208 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
209 vf->draw_slice=draw_slice;
9560
ae2ce6ebc1fa Pass start slice to the vo it make dr + slice implemantation easier
albeu
parents: 8148
diff changeset
210 vf->start_slice=start_slice;
19576
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
211 vf->uninit=uninit;
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
212 vf->priv=calloc(1, sizeof(struct vf_priv_s));
3e7ce339d74b Add EOSD support to vf_vo.
eugeni
parents: 19463
diff changeset
213 vf->priv->vf_vo_data=(vf_vo_data_t*)args;
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
214 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
215 // 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
216 return 1;
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
217 }
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
218
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
219 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
220 "libvo wrapper",
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
221 "vo",
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
222 "A'rpi",
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
223 "for internal use",
9593
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 9560
diff changeset
224 open,
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 9560
diff changeset
225 NULL
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
226 };
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
227
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
228 //===========================================================================//