~ubuntu-branches/ubuntu/maverick/vlc/maverick

« back to all changes in this revision

Viewing changes to modules/video_filter/magnify.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-09-17 21:56:14 UTC
  • mfrom: (1.1.17 upstream)
  • Revision ID: james.westby@ubuntu.com-20080917215614-tj0vx8xzd57e52t8
Tags: 0.9.2-1ubuntu1
* New Upstream Release, exception granted by
    - dktrkranz, norsetto, Hobbsee (via irc). LP: #270404

Changes done in ubuntu:

* add libxul-dev to build-depends
* make sure that vlc is build against libxul in configure. This doesn't
  change anything in the package, but makes it more robust if building
  in an 'unclean' chroot or when modifying the package.
* debian/control: make Vcs-* fields point to the motumedia branch
* add libx264-dev and libass-dev to build-depends
  LP: #210354, #199870
* actually enable libass support by passing --enable-libass to configure
* enable libdca: add libdca-dev to build depends and --enable-libdca
* install the x264 plugin.

Changes already in the pkg-multimedia branch in debian:

* don't install usr/share/vlc/mozilla in debian/mozilla-plugin-vlc.install  
* new upstream .desktop file now registers flash video mimetype LP: #261567
* add Xb-Npp-Applications to mozilla-plugin-vlc
* remove duplicate entries in debian/vlc-nox.install

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * magnify.c : Magnify/Zoom interactive effect
3
3
 *****************************************************************************
4
4
 * Copyright (C) 2005 the VideoLAN team
5
 
 * $Id: 63401230ab8e2838b9fbacd3819114e139371a1e $
 
5
 * $Id$
6
6
 *
7
7
 * Authors: Antoine Cellerier <dionoea -at- videolan -dot- org>
8
8
 *
24
24
/*****************************************************************************
25
25
 * Preamble
26
26
 *****************************************************************************/
27
 
#include <stdlib.h>                                      /* malloc(), free() */
28
 
#include <string.h>
29
 
 
30
 
#include <vlc/vlc.h>
31
 
#include <vlc/vout.h>
 
27
 
 
28
#ifdef HAVE_CONFIG_H
 
29
# include "config.h"
 
30
#endif
 
31
 
 
32
#include <vlc_common.h>
 
33
#include <vlc_plugin.h>
 
34
#include <vlc_vout.h>
32
35
 
33
36
#include <math.h>
34
37
 
35
38
#include "filter_common.h"
 
39
#include "filter_picture.h"
 
40
 
36
41
#include "vlc_image.h"
37
 
#include "vlc_input.h"
38
 
#include "vlc_playlist.h"
39
42
 
40
43
/*****************************************************************************
41
 
 * Local prototypes
 
44
 * Module descriptor
42
45
 *****************************************************************************/
43
46
static int  Create    ( vlc_object_t * );
44
47
static void Destroy   ( vlc_object_t * );
45
48
 
46
 
static int  Init      ( vout_thread_t * );
47
 
static void End       ( vout_thread_t * );
48
 
static void Render    ( vout_thread_t *, picture_t * );
49
 
 
50
 
static int  SendEvents   ( vlc_object_t *, char const *,
51
 
                           vlc_value_t, vlc_value_t, void * );
52
 
static int  MouseEvent   ( vlc_object_t *, char const *,
53
 
                           vlc_value_t, vlc_value_t, void * );
54
 
 
55
 
/*****************************************************************************
56
 
 * Module descriptor
57
 
 *****************************************************************************/
58
49
vlc_module_begin();
59
 
    set_description( _("Magnify/Zoom interactive video filter") );
60
 
    set_shortname( _( "Magnify" ));
 
50
    set_description( N_("Magnify/Zoom interactive video filter") );
 
51
    set_shortname( N_( "Magnify" ));
61
52
    set_capability( "video filter", 0 );
62
53
    set_category( CAT_VIDEO );
63
54
    set_subcategory( SUBCAT_VIDEO_VFILTER );
65
56
    set_callbacks( Create, Destroy );
66
57
vlc_module_end();
67
58
 
 
59
 
 
60
/*****************************************************************************
 
61
 * Local prototypes
 
62
 *****************************************************************************/
 
63
static int  Init      ( vout_thread_t * );
 
64
static void End       ( vout_thread_t * );
 
65
static void Render    ( vout_thread_t *, picture_t * );
 
66
 
 
67
static int  SendEvents   ( vlc_object_t *, char const *,
 
68
                           vlc_value_t, vlc_value_t, void * );
 
69
static int  MouseEvent   ( vlc_object_t *, char const *,
 
70
                           vlc_value_t, vlc_value_t, void * );
 
71
 
 
72
static void DrawZoomStatus( uint8_t *, int i_pitch, int i_width, int i_height,
 
73
                            int i_offset_x, int i_offset_y, bool b_visible );
 
74
static void DrawRectangle( uint8_t *, int i_pitch, int i_width, int i_height,
 
75
                           int x, int y, int i_w, int i_h );
 
76
 
68
77
/*****************************************************************************
69
78
 * vout_sys_t: Magnify video output method descriptor
70
79
 *****************************************************************************/
74
83
 
75
84
    image_handler_t *p_image;
76
85
 
 
86
    int64_t i_hide_timeout;
 
87
 
 
88
    vlc_mutex_t lock;
77
89
    int i_zoom; /* zoom level in percent */
78
90
    int i_x, i_y; /* top left corner coordinates in original image */
79
91
 
80
 
    vlc_bool_t b_visible; /* is "interface" visible ? */
 
92
    bool b_visible; /* is "interface" visible ? */
 
93
 
 
94
    int64_t i_last_activity;
81
95
};
82
96
 
 
97
#define VIS_ZOOM 4
 
98
#define ZOOM_FACTOR 8
 
99
 
83
100
/*****************************************************************************
84
101
 * Control: control facility for the vout (forwards to child vout)
85
102
 *****************************************************************************/
95
112
{
96
113
    vout_thread_t *p_vout = (vout_thread_t *)p_this;
97
114
 
 
115
    switch( p_vout->fmt_in.i_chroma )
 
116
    {
 
117
        CASE_PLANAR_YUV
 
118
        case VLC_FOURCC('G','R','E','Y'):
 
119
            break;
 
120
        default:
 
121
            msg_Err( p_vout, "Unsupported chroma" );
 
122
            return VLC_EGENERIC;
 
123
    }
 
124
 
98
125
    /* Allocate structure */
99
126
    p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
100
127
    if( p_vout->p_sys == NULL )
101
 
    {
102
 
        msg_Err( p_vout, "out of memory" );
103
128
        return VLC_ENOMEM;
104
 
    }
105
129
 
106
130
    p_vout->p_sys->p_image = image_HandlerCreate( p_vout );
107
131
 
122
146
{
123
147
    int i_index;
124
148
    picture_t *p_pic;
125
 
    video_format_t fmt = {0};
 
149
    video_format_t fmt;
126
150
 
 
151
    memset( &fmt, 0, sizeof(video_format_t) );
127
152
    I_OUTPUTPICTURES = 0;
128
153
 
129
154
    /* Initialize the output structure */
147
172
        return VLC_EGENERIC;
148
173
    }
149
174
 
150
 
#define VIS_ZOOM 4
 
175
    vlc_mutex_init( &p_vout->p_sys->lock );
151
176
    p_vout->p_sys->i_x = 0;
152
177
    p_vout->p_sys->i_y = 0;
153
 
#define ZOOM_FACTOR 100
154
 
    p_vout->p_sys->i_zoom = 200;
 
178
    p_vout->p_sys->i_zoom = 2*ZOOM_FACTOR;
 
179
    p_vout->p_sys->b_visible = true;
 
180
    p_vout->p_sys->i_last_activity = mdate();
 
181
    p_vout->p_sys->i_hide_timeout = 1000 * var_GetInteger( p_vout, "mouse-hide-timeout" );
155
182
 
156
183
    var_AddCallback( p_vout->p_sys->p_vout, "mouse-x", MouseEvent, p_vout );
157
184
    var_AddCallback( p_vout->p_sys->p_vout, "mouse-y", MouseEvent, p_vout );
172
199
{
173
200
    int i_index;
174
201
 
 
202
    DEL_PARENT_CALLBACKS( SendEventsToChild );
 
203
 
 
204
    DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
 
205
 
175
206
    /* Free the fake output buffers we allocated */
176
207
    for( i_index = I_OUTPUTPICTURES ; i_index ; )
177
208
    {
182
213
    var_DelCallback( p_vout->p_sys->p_vout, "mouse-x", MouseEvent, p_vout);
183
214
    var_DelCallback( p_vout->p_sys->p_vout, "mouse-y", MouseEvent, p_vout);
184
215
    var_DelCallback( p_vout->p_sys->p_vout, "mouse-clicked", MouseEvent, p_vout);
 
216
 
 
217
    vlc_mutex_destroy( &p_vout->p_sys->lock );
 
218
 
 
219
    vout_CloseAndRelease( p_vout->p_sys->p_vout );
185
220
}
186
221
 
187
222
/*****************************************************************************
191
226
{
192
227
    vout_thread_t *p_vout = (vout_thread_t *)p_this;
193
228
 
194
 
    if( p_vout->p_sys->p_vout )
195
 
    {
196
 
        DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
197
 
        vlc_object_detach( p_vout->p_sys->p_vout );
198
 
        vout_Destroy( p_vout->p_sys->p_vout );
199
 
    }
200
 
 
201
229
    image_HandlerDelete( p_vout->p_sys->p_image );
202
230
 
203
 
    DEL_PARENT_CALLBACKS( SendEventsToChild );
204
231
 
205
232
    free( p_vout->p_sys );
206
233
}
210
237
 *****************************************************************************/
211
238
static void Render( vout_thread_t *p_vout, picture_t *p_pic )
212
239
{
 
240
    vout_sys_t *p_sys = p_vout->p_sys;
213
241
    picture_t *p_outpic;
214
242
 
215
 
    int o_x = p_vout->p_sys->i_x;
216
 
    int o_y = p_vout->p_sys->i_y;
217
 
    int o_zoom = p_vout->p_sys->i_zoom;
218
 
    int x,y,o_yp,o_xp;
219
243
    int v_w, v_h;
220
 
    video_format_t fmt_out = {0};
221
244
    picture_t *p_converted;
222
 
    plane_t *p_oyp=NULL;
 
245
    plane_t *p_oyp;
 
246
    int i_plane;
223
247
 
224
248
    /* This is a new frame. Get a structure from the video_output. */
225
 
    while( ( p_outpic = vout_CreatePicture( p_vout->p_sys->p_vout, 0, 0, 0 ) )
 
249
    while( ( p_outpic = vout_CreatePicture( p_sys->p_vout, 0, 0, 0 ) )
226
250
              == NULL )
227
251
    {
228
 
        if( p_vout->b_die || p_vout->b_error )
 
252
        if( !vlc_object_alive (p_vout) || p_vout->b_error )
229
253
        {
230
254
            return;
231
255
        }
232
256
        msleep( VOUT_OUTMEM_SLEEP );
233
257
    }
234
258
 
235
 
    vout_DatePicture( p_vout->p_sys->p_vout, p_outpic, p_pic->date );
236
 
 
237
 
    p_oyp = &(p_outpic->p[Y_PLANE]);
 
259
    vout_DatePicture( p_sys->p_vout, p_outpic, p_pic->date );
 
260
 
 
261
 
 
262
    vlc_mutex_lock( &p_sys->lock );
 
263
    const bool b_visible = p_sys->b_visible;
 
264
    const int o_x = p_sys->i_x;
 
265
    const int o_y = p_sys->i_y;
 
266
    const int o_zoom = p_sys->i_zoom;
 
267
    const int64_t i_last_activity = p_sys->i_last_activity;
 
268
    vlc_mutex_unlock( &p_sys->lock );
238
269
 
239
270
    /* background magnified image */
240
271
    if( o_zoom != ZOOM_FACTOR )
241
272
    {
242
 
#define magnify( plane ) \
243
 
    o_yp = o_y*p_outpic->p[plane].i_lines/p_outpic->p[Y_PLANE].i_lines; \
244
 
    o_xp = o_x*p_outpic->p[plane].i_pitch/p_outpic->p[Y_PLANE].i_pitch; \
245
 
    for( y=0; y<p_outpic->p[plane].i_visible_lines; y++ ) \
246
 
    { \
247
 
        for( x=0; x<p_outpic->p[plane].i_visible_pitch; x++ ) \
248
 
        { \
249
 
            p_outpic->p[plane].p_pixels[y*p_outpic->p[plane].i_pitch+x] = \
250
 
                p_pic->p[plane].p_pixels[ \
251
 
                    ( o_yp + y*ZOOM_FACTOR/o_zoom )*p_outpic->p[plane].i_pitch \
252
 
                    + o_xp + x*ZOOM_FACTOR/o_zoom \
253
 
                ]; \
254
 
        } \
255
 
    }
256
 
    magnify( Y_PLANE );
257
 
    magnify( U_PLANE );
258
 
    magnify( V_PLANE );
259
 
#undef magnify
 
273
        video_format_t fmt_in;
 
274
        video_format_t fmt_out;
 
275
        picture_t crop;
 
276
 
 
277
        crop = *p_pic;
 
278
        for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )
 
279
        {
 
280
            const int o_yp = o_y * p_outpic->p[i_plane].i_lines / p_outpic->p[Y_PLANE].i_lines;
 
281
            const int o_xp = o_x * p_outpic->p[i_plane].i_pitch / p_outpic->p[Y_PLANE].i_pitch;
 
282
 
 
283
            crop.p[i_plane].p_pixels += o_yp * p_outpic->p[i_plane].i_pitch + o_xp;
 
284
        }
 
285
 
 
286
        /* */
 
287
        fmt_in = p_vout->fmt_out;
 
288
        fmt_in.i_width  = (fmt_in.i_width  * ZOOM_FACTOR / o_zoom) & ~1;
 
289
        fmt_in.i_height = (fmt_in.i_height * ZOOM_FACTOR / o_zoom) & ~1;
 
290
 
 
291
        /* */
 
292
        fmt_out = p_vout->fmt_out;
 
293
 
 
294
        p_converted = image_Convert( p_sys->p_image, &crop, &fmt_in, &fmt_out );
 
295
 
 
296
        picture_CopyPixels( p_outpic, p_converted );
 
297
 
 
298
        picture_Release( p_converted );
260
299
    }
261
300
    else
262
301
    {
263
 
#define copy( plane ) \
264
 
        memcpy( p_outpic->p[plane].p_pixels, p_pic->p[plane].p_pixels, \
265
 
            p_outpic->p[plane].i_lines * p_outpic->p[plane].i_pitch );
266
 
        copy( Y_PLANE );
267
 
        copy( U_PLANE );
268
 
        copy( V_PLANE );
269
 
#undef copy
 
302
        picture_CopyPixels( p_outpic, p_pic );
270
303
    }
271
304
 
272
 
    if( p_vout->p_sys->b_visible )
 
305
    /* */
 
306
    p_oyp = &p_outpic->p[Y_PLANE];
 
307
    if( b_visible )
273
308
    {
 
309
        video_format_t fmt_out;
 
310
 
274
311
        /* image visualization */
275
312
        fmt_out = p_vout->fmt_out;
276
 
        fmt_out.i_width = p_vout->render.i_width/VIS_ZOOM;
277
 
        fmt_out.i_height = p_vout->render.i_height/VIS_ZOOM;
278
 
        p_converted = image_Convert( p_vout->p_sys->p_image, p_pic,
279
 
                                     &(p_pic->format), &fmt_out );
280
 
    #define copyimage( plane ) \
281
 
        for( y=0; y<p_converted->p[plane].i_visible_lines; y++) \
282
 
        { \
283
 
            memcpy( p_outpic->p[plane].p_pixels+y*p_outpic->p[plane].i_pitch, \
284
 
            p_converted->p[plane].p_pixels+y*p_converted->p[plane].i_pitch, \
285
 
            p_converted->p[plane].i_visible_pitch ); \
 
313
        fmt_out.i_width  = (p_vout->render.i_width/VIS_ZOOM ) & ~1;
 
314
        fmt_out.i_height = (p_vout->render.i_height/VIS_ZOOM) & ~1;
 
315
        p_converted = image_Convert( p_sys->p_image, p_pic,
 
316
                                     &p_pic->format, &fmt_out );
 
317
        for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )
 
318
        {
 
319
            int y;
 
320
            for( y = 0; y < p_converted->p[i_plane].i_visible_lines; y++)
 
321
            {
 
322
                vlc_memcpy(
 
323
                    &p_outpic->p[i_plane].p_pixels[y*p_outpic->p[i_plane].i_pitch],
 
324
                    p_converted->p[i_plane].p_pixels+y*p_converted->p[i_plane].i_pitch,
 
325
                    p_converted->p[i_plane].i_visible_pitch );
 
326
            }
286
327
        }
287
 
        copyimage( Y_PLANE );
288
 
        copyimage( U_PLANE );
289
 
        copyimage( V_PLANE );
290
 
    #undef copyimage
291
 
        if( p_converted->pf_release )
292
 
            p_converted->pf_release( p_converted );
 
328
        picture_Release( p_converted );
293
329
 
294
330
        /* white rectangle on visualization */
295
 
        v_w = p_oyp->i_pitch*ZOOM_FACTOR/(VIS_ZOOM*o_zoom);
296
 
        v_h = (o_y+p_oyp->i_lines*ZOOM_FACTOR/o_zoom)/VIS_ZOOM;
297
 
        /* top line */
298
 
        memset( p_oyp->p_pixels
299
 
                + o_y/VIS_ZOOM*p_oyp->i_pitch
300
 
                + o_x/VIS_ZOOM, 0xff, v_w+1 );
 
331
        v_w = __MIN( fmt_out.i_width  * ZOOM_FACTOR / o_zoom, fmt_out.i_width - 1 );
 
332
        v_h = __MIN( fmt_out.i_height * ZOOM_FACTOR / o_zoom, fmt_out.i_height - 1 );
301
333
 
302
 
        for( y = o_y/VIS_ZOOM+1; y < v_h; y++ )
303
 
        {
304
 
            /* left line */
305
 
            p_oyp->p_pixels[
306
 
                y*p_oyp->i_pitch+o_x/VIS_ZOOM
307
 
            ] = 0xff;
308
 
            /* right line */
309
 
            p_oyp->p_pixels[
310
 
                y*p_oyp->i_pitch+o_x/VIS_ZOOM + v_w
311
 
            ] = 0xff;
312
 
        }
313
 
        /* bottom line */
314
 
        memset( p_oyp->p_pixels
315
 
                + v_h*p_oyp->i_pitch
316
 
                + o_x/VIS_ZOOM, 0xff, v_w+1 );
 
334
        DrawRectangle( p_oyp->p_pixels, p_oyp->i_pitch,
 
335
                       p_oyp->i_pitch, p_oyp->i_lines,
 
336
                       o_x/VIS_ZOOM, o_y/VIS_ZOOM,
 
337
                       v_w, v_h );
317
338
 
318
339
        /* */
319
 
        v_h = p_oyp->i_lines/VIS_ZOOM;
 
340
        v_h = fmt_out.i_height + 1;
320
341
    }
321
342
    else
322
343
    {
323
344
        v_h = 1;
324
345
    }
325
346
 
326
 
    /* print a small "VLC ZOOM" ... gruikkkkkkkkk */
327
 
#define DRAW(a) {int c,l=1;L a;}
328
 
#define L ;l++,c=1
329
 
#define X ;draw(l,c);c+=1
330
 
#define o +1
331
 
#define draw(y,x) p_oyp->p_pixels[(v_h+y)*p_oyp->i_pitch+x] = 0xff;
332
 
if( p_vout->p_sys->b_visible )
333
 
DRAW(
334
 
X o o o X o X o o o o o o X X X X o o o X X X X X o o X X X o o o X X X o o X X o X X o o o X o o o X o X X X X X o X X X X o o X X X X X L
335
 
X o o o X o X o o o o o X o o o o o o o o o o X o o X o o o X o X o o o X o X o X o X o o o X o o o X o o o X o o o X o o o X o X o o o o L
336
 
o X o X o o X o o o o o X o o o o o o o o o X o o o X o o o X o X o o o X o X o o o X o o o X X X X X o o o X o o o X o o o X o X X X X o L
337
 
o X o X o o X o o o o o X o o o o o o o o X o o o o X o o o X o X o o o X o X o o o X o o o X o o o X o o o X o o o X o o o X o X o o o o L
338
 
o o X o o o X X X X X o o X X X X o o o X X X X X o o X X X o o o X X X o o X o o o X o o o X o o o X o X X X X X o X X X X o o X X X X X L
339
 
)
340
 
else
341
 
DRAW(
342
 
X o o o X o X o o o o o o X X X X o o o X X X X X o o X X X o o o X X X o o X X o X X o o o o X X X X o X o o o X o o X X X o o X o o o X L
343
 
X o o o X o X o o o o o X o o o o o o o o o o X o o X o o o X o X o o o X o X o X o X o o o X o o o o o X o o o X o X o o o X o X o o o X L
344
 
o X o X o o X o o o o o X o o o o o o o o o X o o o X o o o X o X o o o X o X o o o X o o o o X X X o o X X X X X o X o o o X o X o X o X L
345
 
o X o X o o X o o o o o X o o o o o o o o X o o o o X o o o X o X o o o X o X o o o X o o o o o o o X o X o o o X o X o o o X o X o X o X L
346
 
o o X o o o X X X X X o o X X X X o o o X X X X X o o X X X o o o X X X o o X o o o X o o o X X X X o o X o o o X o o X X X o o o X o X o L
347
 
)
348
 
#undef DRAW
349
 
#undef L
350
 
#undef X
351
 
#undef O
352
 
#undef draw
 
347
    /* print a small "VLC ZOOM" */
 
348
    if( b_visible || i_last_activity + p_sys->i_hide_timeout > mdate() )
 
349
        DrawZoomStatus( p_oyp->p_pixels, p_oyp->i_pitch, p_oyp->i_pitch, p_oyp->i_lines,
 
350
                        1, v_h, b_visible );
353
351
 
354
 
    if( p_vout->p_sys->b_visible )
 
352
    if( b_visible )
355
353
    {
 
354
        int y;
 
355
 
356
356
        /* zoom gauge */
357
 
        memset( p_oyp->p_pixels
358
 
                    + (v_h+9)*p_oyp->i_pitch,
359
 
                    0xff, 41 );
 
357
        vlc_memset( p_oyp->p_pixels + (v_h+9)*p_oyp->i_pitch, 0xff, 41 );
360
358
        for( y = v_h + 10; y < v_h + 90; y++ )
361
359
        {
362
360
            int width = v_h + 90 - y;
363
361
            width = (width*width)/160;
364
 
            if( (80 - y + v_h)*10 < o_zoom )
 
362
            if( (80 - y + v_h)*ZOOM_FACTOR/10 < o_zoom )
365
363
            {
366
 
                memset( p_oyp->p_pixels
367
 
                    + y*p_oyp->i_pitch,
368
 
                    0xff, width );
 
364
                vlc_memset( p_oyp->p_pixels + y*p_oyp->i_pitch, 0xff, width );
369
365
            }
370
366
            else
371
367
            {
375
371
        }
376
372
    }
377
373
 
378
 
    vout_DisplayPicture( p_vout->p_sys->p_vout, p_outpic );
 
374
    vout_DisplayPicture( p_sys->p_vout, p_outpic );
 
375
}
 
376
 
 
377
static void DrawZoomStatus( uint8_t *pb_dst, int i_pitch, int i_width, int i_height,
 
378
                            int i_offset_x, int i_offset_y, bool b_visible )
 
379
{
 
380
    static const char *p_hide =
 
381
        "X   X X      XXXX   XXXXX  XXX   XXX  XX XX   X   X XXXXX XXXX  XXXXXL"
 
382
        "X   X X     X          X  X   X X   X X X X   X   X   X   X   X X    L"
 
383
        " X X  X     X         X   X   X X   X X   X   XXXXX   X   X   X XXXX L"
 
384
        " X X  X     X        X    X   X X   X X   X   X   X   X   X   X X    L"
 
385
        "  X   XXXXX  XXXX   XXXXX  XXX   XXX  X   X   X   X XXXXX XXXX  XXXXXL";
 
386
    static const char *p_show = 
 
387
        "X   X X      XXXX   XXXXX  XXX   XXX  XX XX    XXXX X   X  XXX  X   XL"
 
388
        "X   X X     X          X  X   X X   X X X X   X     X   X X   X X   XL"
 
389
        " X X  X     X         X   X   X X   X X   X    XXX  XXXXX X   X X X XL"
 
390
        " X X  X     X        X    X   X X   X X   X       X X   X X   X X X XL"
 
391
        "  X   XXXXX  XXXX   XXXXX  XXX   XXX  X   X   XXXX  X   X  XXX   X X L";
 
392
    const char *p_draw = b_visible ? p_hide : p_show;
 
393
    int i, y, x;
 
394
 
 
395
    for( i = 0, x = i_offset_x, y = i_offset_y; p_draw[i] != '\0'; i++ )
 
396
    {
 
397
        if( p_draw[i] == 'X' )
 
398
        {
 
399
            if( x < i_width && y < i_height )
 
400
                pb_dst[y*i_pitch + x] = 0xff;
 
401
            x++;
 
402
        }
 
403
        else if( p_draw[i] == ' ' )
 
404
        {
 
405
            x++;
 
406
        }
 
407
        else if( p_draw[i] == 'L' )
 
408
        {
 
409
            x = i_offset_x;
 
410
            y++;
 
411
        }
 
412
    }
 
413
}
 
414
static void DrawRectangle( uint8_t *pb_dst, int i_pitch, int i_width, int i_height,
 
415
                           int x, int y, int i_w, int i_h )
 
416
{
 
417
    int dy;
 
418
 
 
419
    if( x + i_w > i_width || y + i_h > i_height )
 
420
        return;
 
421
 
 
422
    /* top line */
 
423
    vlc_memset( &pb_dst[y * i_pitch + x], 0xff, i_w );
 
424
 
 
425
    /* left and right */
 
426
    for( dy = 1; dy < i_h-1; dy++ )
 
427
    {
 
428
        pb_dst[(y+dy) * i_pitch + x +     0] = 0xff;
 
429
        pb_dst[(y+dy) * i_pitch + x + i_w-1] = 0xff;
 
430
    }
 
431
 
 
432
    /* bottom line */
 
433
    vlc_memset( &pb_dst[(y+i_h-1) * i_pitch + x], 0xff, i_w );
379
434
}
380
435
 
381
436
/*****************************************************************************
384
439
static int SendEvents( vlc_object_t *p_this, char const *psz_var,
385
440
                       vlc_value_t oldval, vlc_value_t newval, void *p_data )
386
441
{
 
442
    VLC_UNUSED(p_this); VLC_UNUSED(oldval);
387
443
    var_Set( (vlc_object_t *)p_data, psz_var, newval );
388
444
 
389
445
    return VLC_SUCCESS;
395
451
static int SendEventsToChild( vlc_object_t *p_this, char const *psz_var,
396
452
                       vlc_value_t oldval, vlc_value_t newval, void *p_data )
397
453
{
 
454
    VLC_UNUSED(p_data); VLC_UNUSED(oldval);
398
455
    vout_thread_t *p_vout = (vout_thread_t *)p_this;
399
456
    var_Set( p_vout->p_sys->p_vout, psz_var, newval );
400
457
    return VLC_SUCCESS;
409
466
    vout_thread_t *p_vout = (vout_thread_t*)p_data;
410
467
    vlc_value_t vald,valx,valy;
411
468
 
 
469
    VLC_UNUSED(p_this);
 
470
 
412
471
#define MOUSE_DOWN    1
413
472
#define MOUSE_CLICKED 2
414
473
#define MOUSE_MOVE_X  4
416
475
#define MOUSE_MOVE    12
417
476
    uint8_t mouse= 0;
418
477
 
419
 
    int v_h = p_vout->output.i_height*ZOOM_FACTOR/p_vout->p_sys->i_zoom;
420
 
    int v_w = p_vout->output.i_width*ZOOM_FACTOR/p_vout->p_sys->i_zoom;
421
 
 
422
478
    if( psz_var[6] == 'x' ) mouse |= MOUSE_MOVE_X;
423
479
    if( psz_var[6] == 'y' ) mouse |= MOUSE_MOVE_Y;
424
480
    if( psz_var[6] == 'c' ) mouse |= MOUSE_CLICKED;
428
484
    var_Get( p_vout->p_sys->p_vout, "mouse-y", &valy );
429
485
    var_Get( p_vout->p_sys->p_vout, "mouse-x", &valx );
430
486
 
 
487
    vlc_mutex_lock( &p_vout->p_sys->lock );
 
488
 
 
489
    const int v_h = p_vout->output.i_height*ZOOM_FACTOR/p_vout->p_sys->i_zoom;
 
490
    const int v_w = p_vout->output.i_width*ZOOM_FACTOR/p_vout->p_sys->i_zoom;
 
491
 
431
492
    if( ( mouse&MOUSE_MOVE && mouse&MOUSE_DOWN)
432
493
        || mouse&MOUSE_CLICKED )
433
494
    {
451
512
                && mouse&MOUSE_CLICKED )
452
513
            {
453
514
            /* mouse is over the "VLC ZOOM HIDE" text */
454
 
                p_vout->p_sys->b_visible = VLC_FALSE;
 
515
                p_vout->p_sys->b_visible = false;
455
516
            }
456
517
            else if(    (int)p_vout->output.i_height/VIS_ZOOM + 9 <= valy.i_int
457
518
                     && valy.i_int <= (int)p_vout->output.i_height/VIS_ZOOM + 90
482
543
                && valy.i_int <= 10 && mouse&MOUSE_CLICKED )
483
544
            {
484
545
            /* mouse is over the "VLC ZOOM SHOW" text */
485
 
                p_vout->p_sys->b_visible = VLC_TRUE;
 
546
                p_vout->p_sys->b_visible = true;
486
547
            }
487
548
            else if( mouse&MOUSE_MOVE_X && !(mouse&MOUSE_CLICKED) )
488
549
            {
504
565
         __MAX( 0, __MIN( p_vout->p_sys->i_y, (int)p_vout->output.i_height
505
566
        - (int)p_vout->output.i_height*ZOOM_FACTOR/p_vout->p_sys->i_zoom - 1 ));
506
567
 
 
568
    p_vout->p_sys->i_last_activity = mdate();
 
569
    vlc_mutex_unlock( &p_vout->p_sys->lock );
507
570
 
508
571
    return VLC_SUCCESS;
509
572
}