~ubuntu-dev/mplayer/ubuntu-feisty

« back to all changes in this revision

Viewing changes to libmpcodecs/vf_vo.c

  • Committer: William Grant
  • Date: 2007-02-03 03:16:07 UTC
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: william.grant@ubuntu.org.au-20070203031607-08gc2ompbz6spt9i
Update to 1.0rc1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 
11
11
#include "libvo/video_out.h"
12
12
 
 
13
#ifdef USE_ASS
 
14
#include "libass/ass.h"
 
15
#include "libass/ass_mp.h"
 
16
extern ass_track_t* ass_track;
 
17
#endif
 
18
 
13
19
//===========================================================================//
14
20
 
15
 
#define video_out ((vo_functions_t*)(vf->priv))
 
21
extern int sub_visibility;
 
22
extern float sub_delay;
 
23
 
 
24
typedef struct vf_vo_data_s {
 
25
    double pts;
 
26
    vo_functions_t *vo;
 
27
} vf_vo_data_t;
 
28
 
 
29
struct vf_priv_s {
 
30
    vf_vo_data_t* vf_vo_data;
 
31
#ifdef USE_ASS
 
32
    ass_instance_t* ass_priv;
 
33
    ass_settings_t ass_settings;
 
34
#endif
 
35
};
 
36
#define video_out (vf->priv->vf_vo_data->vo)
16
37
 
17
38
static int query_format(struct vf_instance_s* vf, unsigned int fmt); /* forward declaration */
18
39
 
48
69
    if(video_out->config(width,height,d_width,d_height,flags,"MPlayer",outfmt))
49
70
        return 0;
50
71
 
 
72
#ifdef USE_ASS
 
73
    if (vf->priv->ass_priv) {
 
74
        vf->priv->ass_settings.font_size_coeff = ass_font_scale;
 
75
        vf->priv->ass_settings.line_spacing = ass_line_spacing;
 
76
        vf->priv->ass_settings.use_margins = ass_use_margins;
 
77
    }
 
78
#endif
 
79
 
51
80
    ++vo_config_count;
52
81
    return 1;
53
82
}
79
108
        if(!vo_config_count) return CONTROL_FALSE; // vo not configured?
80
109
        return((video_out->control(VOCTRL_GET_EQUALIZER, eq->item, &eq->value) == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE);
81
110
    }
 
111
#ifdef USE_ASS
 
112
    case VFCTRL_INIT_EOSD:
 
113
    {
 
114
        vf->priv->ass_priv = ass_init();
 
115
        return vf->priv->ass_priv ? CONTROL_TRUE : CONTROL_FALSE;
 
116
    }
 
117
    case VFCTRL_DRAW_EOSD:
 
118
    {
 
119
        ass_image_t* images = 0;
 
120
        double pts = vf->priv->vf_vo_data->pts;
 
121
        if (!vo_config_count || !vf->priv->ass_priv) return CONTROL_FALSE;
 
122
        if (sub_visibility && vf->priv->ass_priv && ass_track && (pts != MP_NOPTS_VALUE)) {
 
123
            mp_eosd_res_t res;
 
124
            ass_settings_t* const settings = &vf->priv->ass_settings;
 
125
            memset(&res, 0, sizeof(res));
 
126
            if (video_out->control(VOCTRL_GET_EOSD_RES, &res) == VO_TRUE) {
 
127
                settings->frame_width = res.w;
 
128
                settings->frame_height = res.h;
 
129
                settings->top_margin = res.mt;
 
130
                settings->bottom_margin = res.mb;
 
131
                settings->left_margin = res.ml;
 
132
                settings->right_margin = res.mr;
 
133
                settings->aspect = ((double)res.w) / res.h;
 
134
            }
 
135
            ass_configure(vf->priv->ass_priv, settings);
 
136
 
 
137
            images = ass_render_frame(vf->priv->ass_priv, ass_track, (pts+sub_delay) * 1000 + .5);
 
138
        }
 
139
        return (video_out->control(VOCTRL_DRAW_EOSD, images) == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE;
 
140
    }
 
141
#endif
82
142
    }
83
143
    // return video_out->control(request,data);
84
144
    return CONTROL_UNKNOWN;
102
162
static int put_image(struct vf_instance_s* vf,
103
163
        mp_image_t *mpi, double pts){
104
164
  if(!vo_config_count) return 0; // vo not configured?
 
165
  // record pts (potentially modified by filters) for main loop
 
166
  vf->priv->vf_vo_data->pts = pts;
105
167
  // first check, maybe the vo/vf plugin implements draw_image using mpi:
106
168
  if(video_out->control(VOCTRL_DRAW_IMAGE,mpi)==VO_TRUE) return 1; // done.
107
169
  // nope, fallback to old draw_frame/draw_slice:
128
190
    video_out->draw_slice(src,stride,w,h,x,y);
129
191
}
130
192
 
 
193
static void uninit(struct vf_instance_s* vf)
 
194
{
 
195
    if (vf->priv) {
 
196
#ifdef USE_ASS
 
197
        if (vf->priv->ass_priv)
 
198
            ass_done(vf->priv->ass_priv);
 
199
#endif
 
200
        free(vf->priv);
 
201
    }
 
202
}
131
203
//===========================================================================//
132
204
 
133
205
static int open(vf_instance_t *vf, char* args){
138
210
    vf->put_image=put_image;
139
211
    vf->draw_slice=draw_slice;
140
212
    vf->start_slice=start_slice;
141
 
    vf->priv=(void*)args; // video_out
 
213
    vf->uninit=uninit;
 
214
    vf->priv=calloc(1, sizeof(struct vf_priv_s));
 
215
    vf->priv->vf_vo_data=(vf_vo_data_t*)args;
142
216
    if(!video_out) return 0; // no vo ?
143
217
//    if(video_out->preinit(args)) return 0; // preinit failed
144
218
    return 1;