Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-gpu
Commits
048e2d91
Commit
048e2d91
authored
Jun 04, 2009
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert puzzle to "video filter2".
parent
1d2ada11
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
292 additions
and
358 deletions
+292
-358
modules/video_filter/puzzle.c
modules/video_filter/puzzle.c
+286
-356
modules/video_filter/wrapper.c
modules/video_filter/wrapper.c
+6
-2
No files found.
modules/video_filter/puzzle.c
View file @
048e2d91
/*****************************************************************************
/*****************************************************************************
* puzzle.c : Puzzle game
* puzzle.c : Puzzle game
*****************************************************************************
*****************************************************************************
* Copyright (C) 2005-200
6
the VideoLAN team
* Copyright (C) 2005-200
9
the VideoLAN team
* $Id$
* $Id$
*
*
* Authors: Antoine Cellerier <dionoea -at- videolan -dot- org>
* Authors: Antoine Cellerier <dionoea -at- videolan -dot- org>
...
@@ -28,38 +28,17 @@
...
@@ -28,38 +28,17 @@
#ifdef HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include "config.h"
# include "config.h"
#endif
#endif
#include <math.h>
#include <vlc_common.h>
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_plugin.h>
#include <vlc_vout.h>
#include <vlc_filter.h>
#include <math.h>
#include "filter_common.h"
#include "vlc_image.h"
#include "vlc_input.h"
#include "vlc_playlist.h"
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
);
static
void
Destroy
(
vlc_object_t
*
);
static
int
Init
(
vout_thread_t
*
);
static
void
End
(
vout_thread_t
*
);
static
void
Render
(
vout_thread_t
*
,
picture_t
*
);
static
int
MouseEvent
(
vlc_object_t
*
,
char
const
*
,
#include "filter_picture.h"
vlc_value_t
,
vlc_value_t
,
void
*
);
static
int
PuzzleCallback
(
vlc_object_t
*
,
char
const
*
,
vlc_value_t
,
vlc_value_t
,
void
*
);
/*****************************************************************************
/*****************************************************************************
* Module descriptor
* Module descriptor
*****************************************************************************/
*****************************************************************************/
#define ROWS_TEXT N_("Number of puzzle rows")
#define ROWS_TEXT N_("Number of puzzle rows")
#define ROWS_LONGTEXT N_("Number of puzzle rows")
#define ROWS_LONGTEXT N_("Number of puzzle rows")
#define COLS_TEXT N_("Number of puzzle columns")
#define COLS_TEXT N_("Number of puzzle columns")
...
@@ -69,10 +48,13 @@ static int PuzzleCallback( vlc_object_t *, char const *,
...
@@ -69,10 +48,13 @@ static int PuzzleCallback( vlc_object_t *, char const *,
#define CFG_PREFIX "puzzle-"
#define CFG_PREFIX "puzzle-"
vlc_module_begin
()
static
int
Open
(
vlc_object_t
*
);
static
void
Close
(
vlc_object_t
*
);
vlc_module_begin
()
set_description
(
N_
(
"Puzzle interactive game video filter"
)
)
set_description
(
N_
(
"Puzzle interactive game video filter"
)
)
set_shortname
(
N_
(
"Puzzle"
))
set_shortname
(
N_
(
"Puzzle"
))
set_capability
(
"video filter"
,
0
)
set_capability
(
"video filter
2
"
,
0
)
set_category
(
CAT_VIDEO
)
set_category
(
CAT_VIDEO
)
set_subcategory
(
SUBCAT_VIDEO_VFILTER
)
set_subcategory
(
SUBCAT_VIDEO_VFILTER
)
...
@@ -83,208 +65,45 @@ vlc_module_begin ()
...
@@ -83,208 +65,45 @@ vlc_module_begin ()
add_bool
(
CFG_PREFIX
"black-slot"
,
0
,
NULL
,
add_bool
(
CFG_PREFIX
"black-slot"
,
0
,
NULL
,
BLACKSLOT_TEXT
,
BLACKSLOT_LONGTEXT
,
false
)
BLACKSLOT_TEXT
,
BLACKSLOT_LONGTEXT
,
false
)
set_callbacks
(
Create
,
Destroy
)
set_callbacks
(
Open
,
Close
)
vlc_module_end
()
vlc_module_end
()
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
const
char
*
const
ppsz_filter_options
[]
=
{
static
const
char
*
const
ppsz_filter_options
[]
=
{
"rows"
,
"cols"
,
"black-slot"
,
NULL
"rows"
,
"cols"
,
"black-slot"
,
NULL
};
};
/*****************************************************************************
static
picture_t
*
Filter
(
filter_t
*
,
picture_t
*
);
* vout_sys_t: Magnify video output method descriptor
static
int
Mouse
(
filter_t
*
,
vlc_mouse_t
*
,
const
vlc_mouse_t
*
,
const
vlc_mouse_t
*
);
*****************************************************************************/
struct
vout_sys_t
{
vout_thread_t
*
p_vout
;
image_handler_t
*
p_image
;
static
bool
IsFinished
(
filter_sys_t
*
);
static
void
Shuffle
(
filter_sys_t
*
);
static
int
PuzzleCallback
(
vlc_object_t
*
,
char
const
*
,
vlc_value_t
,
vlc_value_t
,
void
*
);
struct
filter_sys_t
{
/* */
int
i_cols
;
int
i_cols
;
int
i_rows
;
int
i_rows
;
bool
b_blackslot
;
int
*
pi_order
;
int
*
pi_order
;
int
i_selected
;
int
i_selected
;
bool
b_finished
;
bool
b_finished
;
bool
b_blackslot
;
/* */
};
vlc_mutex_t
lock
;
bool
b_change
;
/*****************************************************************************
struct
* Control: control facility for the vout (forwards to child vout)
*****************************************************************************/
static
int
Control
(
vout_thread_t
*
p_vout
,
int
i_query
,
va_list
args
)
{
return
vout_vaControl
(
p_vout
->
p_sys
->
p_vout
,
i_query
,
args
);
}
/*****************************************************************************
* Misc stuff...
*****************************************************************************/
static
bool
finished
(
vout_sys_t
*
p_sys
)
{
int
i
;
for
(
i
=
0
;
i
<
p_sys
->
i_cols
*
p_sys
->
i_rows
;
i
++
)
{
if
(
i
!=
p_sys
->
pi_order
[
i
]
)
return
false
;
}
return
true
;
}
static
bool
is_valid
(
vout_sys_t
*
p_sys
)
{
int
i
,
j
,
d
=
0
;
if
(
p_sys
->
b_blackslot
==
false
)
return
true
;
for
(
i
=
0
;
i
<
p_sys
->
i_cols
*
p_sys
->
i_rows
;
i
++
)
{
if
(
p_sys
->
pi_order
[
i
]
==
p_sys
->
i_cols
*
p_sys
->
i_rows
-
1
)
{
d
+=
i
/
p_sys
->
i_cols
+
1
;
continue
;
}
for
(
j
=
i
+
1
;
j
<
p_sys
->
i_cols
*
p_sys
->
i_rows
;
j
++
)
{
if
(
p_sys
->
pi_order
[
j
]
==
p_sys
->
i_cols
*
p_sys
->
i_rows
-
1
)
continue
;
if
(
p_sys
->
pi_order
[
i
]
>
p_sys
->
pi_order
[
j
]
)
d
++
;
}
}
if
(
d
%
2
!=
0
)
return
false
;
else
return
true
;
}
static
void
shuffle
(
vout_sys_t
*
p_sys
)
{
int
i
,
c
;
free
(
p_sys
->
pi_order
);
p_sys
->
pi_order
=
malloc
(
p_sys
->
i_cols
*
p_sys
->
i_rows
*
sizeof
(
int
)
);
do
{
for
(
i
=
0
;
i
<
p_sys
->
i_cols
*
p_sys
->
i_rows
;
i
++
)
{
p_sys
->
pi_order
[
i
]
=
-
1
;
}
i
=
0
;
for
(
c
=
0
;
c
<
p_sys
->
i_cols
*
p_sys
->
i_rows
;
)
{
i
=
rand
()
%
(
p_sys
->
i_cols
*
p_sys
->
i_rows
);
if
(
p_sys
->
pi_order
[
i
]
==
-
1
)
{
p_sys
->
pi_order
[
i
]
=
c
;
c
++
;
}
}
p_sys
->
b_finished
=
finished
(
p_sys
);
}
while
(
p_sys
->
b_finished
==
true
||
is_valid
(
p_sys
)
==
false
);
if
(
p_sys
->
b_blackslot
==
true
)
{
for
(
i
=
0
;
i
<
p_sys
->
i_cols
*
p_sys
->
i_rows
;
i
++
)
{
if
(
p_sys
->
pi_order
[
i
]
==
p_sys
->
i_cols
*
p_sys
->
i_rows
-
1
)
{
p_sys
->
i_selected
=
i
;
break
;
}
}
}
else
{
{
p_sys
->
i_selected
=
-
1
;
int
i_cols
;
}
int
i_rows
;
}
bool
b_blackslot
;
}
change
;
/*****************************************************************************
};
* Create: allocates Magnify video thread output method
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
p_this
)
{
vout_thread_t
*
p_vout
=
(
vout_thread_t
*
)
p_this
;
/* Allocate structure */
p_vout
->
p_sys
=
malloc
(
sizeof
(
vout_sys_t
)
);
if
(
p_vout
->
p_sys
==
NULL
)
return
VLC_ENOMEM
;
p_vout
->
p_sys
->
p_image
=
image_HandlerCreate
(
p_vout
);
config_ChainParse
(
p_vout
,
CFG_PREFIX
,
ppsz_filter_options
,
p_vout
->
p_cfg
);
p_vout
->
p_sys
->
i_rows
=
var_CreateGetIntegerCommand
(
p_vout
,
CFG_PREFIX
"rows"
);
p_vout
->
p_sys
->
i_cols
=
var_CreateGetIntegerCommand
(
p_vout
,
CFG_PREFIX
"cols"
);
p_vout
->
p_sys
->
b_blackslot
=
var_CreateGetBoolCommand
(
p_vout
,
CFG_PREFIX
"black-slot"
);
var_AddCallback
(
p_vout
,
CFG_PREFIX
"rows"
,
PuzzleCallback
,
p_vout
->
p_sys
);
var_AddCallback
(
p_vout
,
CFG_PREFIX
"cols"
,
PuzzleCallback
,
p_vout
->
p_sys
);
var_AddCallback
(
p_vout
,
CFG_PREFIX
"black-slot"
,
PuzzleCallback
,
p_vout
->
p_sys
);
p_vout
->
p_sys
->
pi_order
=
NULL
;
shuffle
(
p_vout
->
p_sys
);
p_vout
->
pf_init
=
Init
;
p_vout
->
pf_end
=
End
;
p_vout
->
pf_manage
=
NULL
;
p_vout
->
pf_render
=
Render
;
p_vout
->
pf_display
=
NULL
;
p_vout
->
pf_control
=
Control
;
return
VLC_SUCCESS
;
}
/*****************************************************************************
* Init: initialize Magnify video thread output method
*****************************************************************************/
static
int
Init
(
vout_thread_t
*
p_vout
)
{
video_format_t
fmt
;
memset
(
&
fmt
,
0
,
sizeof
(
video_format_t
)
);
I_OUTPUTPICTURES
=
0
;
/* Initialize the output structure */
p_vout
->
output
.
i_chroma
=
p_vout
->
render
.
i_chroma
;
p_vout
->
output
.
i_width
=
p_vout
->
render
.
i_width
;
p_vout
->
output
.
i_height
=
p_vout
->
render
.
i_height
;
p_vout
->
output
.
i_aspect
=
p_vout
->
render
.
i_aspect
;
p_vout
->
fmt_out
=
p_vout
->
fmt_in
;
fmt
=
p_vout
->
fmt_out
;
/* Try to open the real video output */
msg_Dbg
(
p_vout
,
"spawning the real video output"
);
p_vout
->
p_sys
->
p_vout
=
vout_Create
(
p_vout
,
&
fmt
);
/* Everything failed */
if
(
p_vout
->
p_sys
->
p_vout
==
NULL
)
{
msg_Err
(
p_vout
,
"cannot open vout, aborting"
);
return
VLC_EGENERIC
;
}
vout_filter_AllocateDirectBuffers
(
p_vout
,
VOUT_MAX_PICTURES
);
vout_filter_AddChild
(
p_vout
,
p_vout
->
p_sys
->
p_vout
,
MouseEvent
);
return
VLC_SUCCESS
;
}
/*****************************************************************************
* End: terminate Magnify video thread output method
*****************************************************************************/
static
void
End
(
vout_thread_t
*
p_vout
)
{
vout_sys_t
*
p_sys
=
p_vout
->
p_sys
;
vout_filter_DelChild
(
p_vout
,
p_sys
->
p_vout
,
MouseEvent
);
vout_CloseAndRelease
(
p_sys
->
p_vout
);
vout_filter_ReleaseDirectBuffers
(
p_vout
);
}
#define SHUFFLE_WIDTH 81
#define SHUFFLE_WIDTH 81
#define SHUFFLE_HEIGHT 13
#define SHUFFLE_HEIGHT 13
...
@@ -302,109 +121,155 @@ static const char *shuffle_button[] =
...
@@ -302,109 +121,155 @@ static const char *shuffle_button[] =
"...... ...... .... ...... .... ....... ......... ........ ...... ......."
,
"...... ...... .... ...... .... ....... ......... ........ ...... ......."
,
". .... ...... .... ...... ... ....... ......... ........ ....... .... ."
,
". .... ...... .... ...... ... ....... ......... ........ ....... .... ."
,
".. ....... .... ....... . ....... ......... ........ ........ .."
,
".. ....... .... ....... . ....... ......... ........ ........ .."
,
"................................................................................."
};
"................................................................................."
};
/**
***************************************************************************
/**
*
Destroy: destroy Magnify video thread output method
*
Open the filter
*
****************************************************************************
/
*/
static
void
Destroy
(
vlc_object_t
*
p_this
)
static
int
Open
(
vlc_object_t
*
p_this
)
{
{
vout_thread_t
*
p_vout
=
(
vout_thread_t
*
)
p_this
;
filter_t
*
p_filter
=
(
filter_t
*
)
p_this
;
filter_sys_t
*
p_sys
;
/* */
if
(
memcmp
(
&
p_filter
->
fmt_in
,
&
p_filter
->
fmt_out
,
sizeof
(
p_filter
->
fmt_in
)
)
)
{
msg_Err
(
p_filter
,
"Input and output format does not match"
);
return
VLC_EGENERIC
;
}
/* Allocate structure */
p_filter
->
p_sys
=
p_sys
=
malloc
(
sizeof
(
*
p_sys
)
);
if
(
!
p_sys
)
return
VLC_ENOMEM
;
config_ChainParse
(
p_filter
,
CFG_PREFIX
,
ppsz_filter_options
,
p_filter
->
p_cfg
);
p_sys
->
pi_order
=
NULL
;
vlc_mutex_init
(
&
p_sys
->
lock
);
p_sys
->
change
.
i_rows
=
var_CreateGetIntegerCommand
(
p_filter
,
CFG_PREFIX
"rows"
);
p_sys
->
change
.
i_cols
=
var_CreateGetIntegerCommand
(
p_filter
,
CFG_PREFIX
"cols"
);
p_sys
->
change
.
b_blackslot
=
var_CreateGetBoolCommand
(
p_filter
,
CFG_PREFIX
"black-slot"
);
p_sys
->
b_change
=
true
;
image_HandlerDelete
(
p_vout
->
p_sys
->
p_image
);
var_AddCallback
(
p_filter
,
CFG_PREFIX
"rows"
,
PuzzleCallback
,
p_sys
);
free
(
p_vout
->
p_sys
->
pi_order
);
var_AddCallback
(
p_filter
,
CFG_PREFIX
"cols"
,
PuzzleCallback
,
p_sys
);
var_AddCallback
(
p_filter
,
CFG_PREFIX
"black-slot"
,
PuzzleCallback
,
p_sys
);
free
(
p_vout
->
p_sys
);
p_filter
->
pf_video_filter
=
Filter
;
p_filter
->
pf_mouse
=
Mouse
;
return
VLC_SUCCESS
;
}
}
/**
***************************************************************************
/**
*
Render: displays previously rendered output
*
Close the filter
*
****************************************************************************
/
*/
static
void
Render
(
vout_thread_t
*
p_vout
,
picture_t
*
p_pic
)
static
void
Close
(
vlc_object_t
*
p_this
)
{
{
picture_t
*
p_outpic
;
filter_t
*
p_filter
=
(
filter_t
*
)
p_this
;
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
//video_format_t fmt_out
;
var_DelCallback
(
p_filter
,
CFG_PREFIX
"rows"
,
PuzzleCallback
,
p_sys
)
;
// memset( &fmt_out, 0, sizeof(video_format_t)
);
var_DelCallback
(
p_filter
,
CFG_PREFIX
"cols"
,
PuzzleCallback
,
p_sys
);
//picture_t *p_converted
;
var_DelCallback
(
p_filter
,
CFG_PREFIX
"black-slot"
,
PuzzleCallback
,
p_sys
)
;
int
i_plane
;
vlc_mutex_destroy
(
&
p_sys
->
lock
);
free
(
p_sys
->
pi_order
);
int
i_rows
=
p_vout
->
p_sys
->
i_rows
;
free
(
p_sys
)
;
int
i_cols
=
p_vout
->
p_sys
->
i_cols
;
}
/* This is a new frame. Get a structure from the video_output. */
/**
while
(
(
p_outpic
=
vout_CreatePicture
(
p_vout
->
p_sys
->
p_vout
,
0
,
0
,
0
)
)
* Filter a picture
==
NULL
)
*/
static
picture_t
*
Filter
(
filter_t
*
p_filter
,
picture_t
*
p_pic
)
{
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
picture_t
*
p_outpic
=
filter_NewPicture
(
p_filter
);
if
(
!
p_outpic
)
{
{
if
(
!
vlc_object_alive
(
p_vout
)
||
p_vout
->
b_error
)
picture_Release
(
p_pic
);
{
return
NULL
;
return
;
}
msleep
(
VOUT_OUTMEM_SLEEP
);
}
}
p_outpic
->
date
=
p_pic
->
date
;
/* */
vlc_mutex_lock
(
&
p_sys
->
lock
);
if
(
p_sys
->
b_change
)
{
p_sys
->
i_rows
=
p_sys
->
change
.
i_rows
;
p_sys
->
i_cols
=
p_sys
->
change
.
i_cols
;
p_sys
->
b_blackslot
=
p_sys
->
change
.
b_blackslot
;
p_sys
->
b_change
=
false
;
Shuffle
(
p_sys
);
}
vlc_mutex_unlock
(
&
p_sys
->
lock
);
/* */
const
int
i_rows
=
p_sys
->
i_rows
;
const
int
i_cols
=
p_sys
->
i_cols
;
for
(
i_plane
=
0
;
i_plane
<
p_outpic
->
i_planes
;
i_plane
++
)
/* */
for
(
int
i_plane
=
0
;
i_plane
<
p_outpic
->
i_planes
;
i_plane
++
)
{
{
plane_t
*
p_in
=
p_pic
->
p
+
i_plane
;
const
plane_t
*
p_in
=
&
p_pic
->
p
[
i_plane
];
plane_t
*
p_out
=
p_outpic
->
p
+
i_plane
;
const
int
i_pitch
=
p_in
->
i_pitch
;
int
i_pitch
=
p_in
->
i_pitch
;
plane_t
*
p_out
=
&
p_outpic
->
p
[
i_plane
];
int
i
;
for
(
i
=
0
;
i
<
i_cols
*
i_rows
;
i
++
)
for
(
i
nt
i
=
0
;
i
<
i_cols
*
i_rows
;
i
++
)
{
{
int
i_col
=
i
%
i_cols
;
int
i_col
=
i
%
i_cols
;
int
i_row
=
i
/
i_cols
;
int
i_row
=
i
/
i_cols
;
int
i_ocol
=
p_
vout
->
p_
sys
->
pi_order
[
i
]
%
i_cols
;
int
i_ocol
=
p_sys
->
pi_order
[
i
]
%
i_cols
;
int
i_orow
=
p_
vout
->
p_
sys
->
pi_order
[
i
]
/
i_cols
;
int
i_orow
=
p_sys
->
pi_order
[
i
]
/
i_cols
;
int
i_last_row
=
i_row
+
1
;
int
i_last_row
=
i_row
+
1
;
i_orow
*=
p_in
->
i_lines
/
i_rows
;
i_orow
*=
p_in
->
i_lines
/
i_rows
;
i_row
*=
p_in
->
i_lines
/
i_rows
;
i_row
*=
p_in
->
i_lines
/
i_rows
;
i_last_row
*=
p_in
->
i_lines
/
i_rows
;
i_last_row
*=
p_in
->
i_lines
/
i_rows
;
if
(
p_vout
->
p_sys
->
b_blackslot
==
true
if
(
p_sys
->
b_blackslot
&&
p_sys
->
b_finished
&&
i
==
p_sys
->
i_selected
)
&&
p_vout
->
p_sys
->
b_finished
==
false
&&
i
==
p_vout
->
p_sys
->
i_selected
)
{
{
uint8_t
color
=
(
i_plane
==
Y_PLANE
?
0x0
:
0x80
);
uint8_t
color
=
(
i_plane
==
Y_PLANE
?
0x0
:
0x80
);
for
(
;
i_row
<
i_last_row
;
i_row
++
,
i_orow
++
)
for
(
;
i_row
<
i_last_row
;
i_row
++
,
i_orow
++
)
{
{
vlc_memset
(
p_out
->
p_pixels
+
i_row
*
i_pitch
memset
(
p_out
->
p_pixels
+
i_row
*
i_pitch
+
i_col
*
i_pitch
/
i_cols
,
+
i_col
*
i_pitch
/
i_cols
,
color
,
i_pitch
/
i_cols
);
color
,
i_pitch
/
i_cols
);
}
}
}
}
else
else
{
{
for
(
;
i_row
<
i_last_row
;
i_row
++
,
i_orow
++
)
for
(
;
i_row
<
i_last_row
;
i_row
++
,
i_orow
++
)
{
{
vlc_memcpy
(
p_out
->
p_pixels
+
i_row
*
i_pitch
memcpy
(
p_out
->
p_pixels
+
i_row
*
i_pitch
+
i_col
*
i_pitch
/
i_cols
,
+
i_col
*
i_pitch
/
i_cols
,
p_in
->
p_pixels
+
i_orow
*
i_pitch
+
i_ocol
*
i_pitch
/
i_cols
,
p_in
->
p_pixels
+
i_orow
*
i_pitch
i_pitch
/
i_cols
);
+
i_ocol
*
i_pitch
/
i_cols
,
i_pitch
/
i_cols
);
}
}
}
}
}
}
}
}
if
(
p_vout
->
p_sys
->
i_selected
!=
-
1
if
(
p_sys
->
i_selected
!=
-
1
&&
!
p_sys
->
b_blackslot
)
&&
p_vout
->
p_sys
->
b_blackslot
==
false
)
{
{
plane_t
*
p_in
=
p_pic
->
p
+
Y_PLANE
;
const
plane_t
*
p_in
=
&
p_pic
->
p
[
Y_PLANE
];
plane_t
*
p_out
=
p_outpic
->
p
+
Y_PLANE
;
const
int
i_pitch
=
p_in
->
i_pitch
;
int
i_pitch
=
p_in
->
i_pitch
;
plane_t
*
p_out
=
&
p_outpic
->
p
[
Y_PLANE
];
int
i_col
=
p_vout
->
p_sys
->
i_selected
%
i_cols
;
int
i_row
=
p_vout
->
p_sys
->
i_selected
/
i_cols
;
int
i_col
=
p_sys
->
i_selected
%
i_cols
;
int
i_row
=
p_sys
->
i_selected
/
i_cols
;
int
i_last_row
=
i_row
+
1
;
int
i_last_row
=
i_row
+
1
;
i_row
*=
p_in
->
i_lines
/
i_rows
;
i_row
*=
p_in
->
i_lines
/
i_rows
;
i_last_row
*=
p_in
->
i_lines
/
i_rows
;
i_last_row
*=
p_in
->
i_lines
/
i_rows
;
vlc_memset
(
p_out
->
p_pixels
+
i_row
*
i_pitch
memset
(
p_out
->
p_pixels
+
i_row
*
i_pitch
+
i_col
*
i_pitch
/
i_cols
,
+
i_col
*
i_pitch
/
i_cols
,
0xff
,
i_pitch
/
i_cols
);
0xff
,
i_pitch
/
i_cols
);
for
(
;
i_row
<
i_last_row
;
i_row
++
)
for
(
;
i_row
<
i_last_row
;
i_row
++
)
{
{
p_out
->
p_pixels
[
i_row
*
i_pitch
p_out
->
p_pixels
[
i_row
*
i_pitch
...
@@ -413,125 +278,190 @@ static void Render( vout_thread_t *p_vout, picture_t *p_pic )
...
@@ -413,125 +278,190 @@ static void Render( vout_thread_t *p_vout, picture_t *p_pic )
+
(
i_col
+
1
)
*
i_pitch
/
i_cols
-
1
]
=
0xff
;
+
(
i_col
+
1
)
*
i_pitch
/
i_cols
-
1
]
=
0xff
;
}
}
i_row
--
;
i_row
--
;
vlc_memset
(
p_out
->
p_pixels
+
i_row
*
i_pitch
memset
(
p_out
->
p_pixels
+
i_row
*
i_pitch
+
i_col
*
i_pitch
/
i_cols
,
+
i_col
*
i_pitch
/
i_cols
,
0xff
,
i_pitch
/
i_cols
);
0xff
,
i_pitch
/
i_cols
);
}
}
if
(
p_
vout
->
p_sys
->
b_finished
==
true
)
if
(
p_
sys
->
b_finished
)
{
{
int
i
,
j
;
plane_t
*
p_out
=
&
p_outpic
->
p
[
Y_PLANE
];
plane_t
*
p_out
=
p_outpic
->
p
+
Y_PLANE
;
for
(
int
i
=
0
;
i
<
SHUFFLE_HEIGHT
;
i
++
)
int
i_pitch
=
p_out
->
i_pitch
;
for
(
i
=
0
;
i
<
SHUFFLE_HEIGHT
;
i
++
)
{
{
for
(
j
=
0
;
j
<
SHUFFLE_WIDTH
;
j
++
)
for
(
int
j
=
0
;
j
<
SHUFFLE_WIDTH
;
j
++
)
{
{
if
(
shuffle_button
[
i
][
j
]
==
'.'
)
if
(
shuffle_button
[
i
][
j
]
==
'.'
)
p_out
->
p_pixels
[
i
*
i_pitch
+
j
]
=
0xff
;
p_out
->
p_pixels
[
i
*
p_out
->
i_pitch
+
j
]
=
0xff
;
}
}
}
}
}
}
vout_DisplayPicture
(
p_vout
->
p_sys
->
p_vout
,
p_out
pic
);
return
CopyInfoAndRelease
(
p_outpic
,
p_
pic
);
}
}
/*****************************************************************************
static
int
Mouse
(
filter_t
*
p_filter
,
vlc_mouse_t
*
p_mouse
,
* MouseEvent: callback for mouse events
const
vlc_mouse_t
*
p_old
,
const
vlc_mouse_t
*
p_new
)
*****************************************************************************/
static
int
MouseEvent
(
vlc_object_t
*
p_this
,
char
const
*
psz_var
,
vlc_value_t
oldval
,
vlc_value_t
newval
,
void
*
p_data
)
{
{
vout_thread_t
*
p_vout
=
p_data
;
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
VLC_UNUSED
(
p_this
);
VLC_UNUSED
(
oldval
);
const
video_format_t
*
p_fmt
=
&
p_filter
->
fmt_in
.
video
;
int
i_x
,
i_y
;
int
i_v
;
if
(
p_new
->
i_x
<
0
||
p_new
->
i_x
>=
(
int
)
p_fmt
->
i_width
||
p_new
->
i_y
<
0
||
p_new
->
i_y
>=
(
int
)
p_fmt
->
i_height
)
/* FIXME missing lock */
return
VLC_EGENERIC
;
#define MOUSE_DOWN 1
#define MOUSE_CLICKED 2
/* */
#define MOUSE_MOVE_X 4
const
bool
b_clicked
=
vlc_mouse_HasPressed
(
p_old
,
p_new
,
MOUSE_BUTTON_LEFT
);
#define MOUSE_MOVE_Y 8
#define MOUSE_MOVE 12
if
(
p_sys
->
b_finished
)
uint8_t
mouse
=
0
;
int
v_h
=
p_vout
->
output
.
i_height
;
int
v_w
=
p_vout
->
output
.
i_width
;
int
i_pos
;
if
(
psz_var
[
6
]
==
'x'
)
mouse
|=
MOUSE_MOVE_X
;
if
(
psz_var
[
6
]
==
'y'
)
mouse
|=
MOUSE_MOVE_Y
;
if
(
psz_var
[
6
]
==
'c'
)
mouse
|=
MOUSE_CLICKED
;
i_v
=
var_GetInteger
(
p_vout
->
p_sys
->
p_vout
,
"mouse-button-down"
);
if
(
i_v
&
0x1
)
mouse
|=
MOUSE_DOWN
;
i_y
=
var_GetInteger
(
p_vout
->
p_sys
->
p_vout
,
"mouse-y"
);
i_x
=
var_GetInteger
(
p_vout
->
p_sys
->
p_vout
,
"mouse-x"
);
if
(
i_y
<
0
||
i_x
<
0
||
i_y
>=
v_h
||
i_x
>=
v_w
)
return
VLC_SUCCESS
;
if
(
mouse
&
MOUSE_CLICKED
)
{
{
i_pos
=
p_vout
->
p_sys
->
i_cols
*
(
(
p_vout
->
p_sys
->
i_rows
*
i_y
)
/
v_h
)
+
(
p_vout
->
p_sys
->
i_cols
*
i_x
)
/
v_w
;
if
(
b_clicked
&&
if
(
p_vout
->
p_sys
->
b_finished
==
true
p_new
->
i_x
<
SHUFFLE_WIDTH
&&
p_new
->
i_y
<
SHUFFLE_HEIGHT
)
&&
i_x
<
SHUFFLE_WIDTH
&&
i_y
<
SHUFFLE_HEIGHT
)
{
shuffle
(
p_vout
->
p_sys
);
}
else
if
(
p_vout
->
p_sys
->
i_selected
==
-
1
)
{
{
p_vout
->
p_sys
->
i_selected
=
i_pos
;
p_sys
->
b_change
=
true
;
return
VLC_EGENERIC
;
}
}
else
if
(
p_vout
->
p_sys
->
i_selected
==
i_pos
else
&&
p_vout
->
p_sys
->
b_blackslot
==
false
)
{
{
p_vout
->
p_sys
->
i_selected
=
-
1
;
/* This is the only case where we can forward the mouse */
*
p_mouse
=
*
p_new
;
return
VLC_SUCCESS
;
}
}
else
if
(
(
p_vout
->
p_sys
->
i_selected
==
i_pos
+
1
}
&&
p_vout
->
p_sys
->
i_selected
%
p_vout
->
p_sys
->
i_cols
!=
0
)
if
(
!
b_clicked
)
||
(
p_vout
->
p_sys
->
i_selected
==
i_pos
-
1
return
VLC_EGENERIC
;
&&
i_pos
%
p_vout
->
p_sys
->
i_cols
!=
0
)
||
p_vout
->
p_sys
->
i_selected
==
i_pos
+
p_vout
->
p_sys
->
i_cols
||
p_vout
->
p_sys
->
i_selected
==
i_pos
-
p_vout
->
p_sys
->
i_cols
)
{
int
a
=
p_vout
->
p_sys
->
pi_order
[
p_vout
->
p_sys
->
i_selected
];
p_vout
->
p_sys
->
pi_order
[
p_vout
->
p_sys
->
i_selected
]
=
p_vout
->
p_sys
->
pi_order
[
i_pos
];
p_vout
->
p_sys
->
pi_order
[
i_pos
]
=
a
;
if
(
p_vout
->
p_sys
->
b_blackslot
==
true
)
p_vout
->
p_sys
->
i_selected
=
i_pos
;
else
p_vout
->
p_sys
->
i_selected
=
-
1
;
p_vout
->
p_sys
->
b_finished
=
finished
(
p_vout
->
p_sys
);
/* */
}
const
int
i_pos_x
=
p_new
->
i_x
*
p_sys
->
i_cols
/
p_fmt
->
i_width
;
const
int
i_pos_y
=
p_new
->
i_y
*
p_sys
->
i_rows
/
p_fmt
->
i_height
;
const
int
i_pos
=
i_pos_y
*
p_sys
->
i_cols
+
i_pos_x
;
if
(
p_sys
->
i_selected
==
-
1
)
{
p_sys
->
i_selected
=
i_pos
;
}
}
/* FIXME do we want to forward it or not ? */
else
if
(
p_sys
->
i_selected
==
i_pos
&&
!
p_sys
->
b_blackslot
)
var_Set
(
p_vout
,
psz_var
,
newval
);
{
return
VLC_SUCCESS
;
p_sys
->
i_selected
=
-
1
;
}
else
if
(
(
p_sys
->
i_selected
==
i_pos
+
1
&&
p_sys
->
i_selected
%
p_sys
->
i_cols
!=
0
)
||
(
p_sys
->
i_selected
==
i_pos
-
1
&&
i_pos
%
p_sys
->
i_cols
!=
0
)
||
p_sys
->
i_selected
==
i_pos
+
p_sys
->
i_cols
||
p_sys
->
i_selected
==
i_pos
-
p_sys
->
i_cols
)
{
int
a
=
p_sys
->
pi_order
[
p_sys
->
i_selected
];
p_sys
->
pi_order
[
p_sys
->
i_selected
]
=
p_sys
->
pi_order
[
i_pos
];
p_sys
->
pi_order
[
i_pos
]
=
a
;
if
(
p_sys
->
b_blackslot
)
p_sys
->
i_selected
=
i_pos
;
else
p_sys
->
i_selected
=
-
1
;
p_sys
->
b_finished
=
IsFinished
(
p_sys
);
}
return
VLC_EGENERIC
;
}
}
/*****************************************************************************
* Misc stuff...
*****************************************************************************/
static
int
PuzzleCallback
(
vlc_object_t
*
p_this
,
char
const
*
psz_var
,
static
int
PuzzleCallback
(
vlc_object_t
*
p_this
,
char
const
*
psz_var
,
vlc_value_t
oldval
,
vlc_value_t
newval
,
vlc_value_t
oldval
,
vlc_value_t
newval
,
void
*
p_data
)
void
*
p_data
)
{
{
VLC_UNUSED
(
p_this
);
VLC_UNUSED
(
oldval
);
VLC_UNUSED
(
p_this
);
VLC_UNUSED
(
oldval
);
vout_sys_t
*
p_sys
=
(
vout
_sys_t
*
)
p_data
;
filter_sys_t
*
p_sys
=
(
filter
_sys_t
*
)
p_data
;
/* FIXME: thread safety */
vlc_mutex_lock
(
&
p_sys
->
lock
);
if
(
!
strcmp
(
psz_var
,
CFG_PREFIX
"rows"
)
)
if
(
!
strcmp
(
psz_var
,
CFG_PREFIX
"rows"
)
)
{
{
p_sys
->
i_rows
=
__MAX
(
1
,
newval
.
i_int
);
p_sys
->
change
.
i_rows
=
__MAX
(
1
,
newval
.
i_int
);
}
}
else
if
(
!
strcmp
(
psz_var
,
CFG_PREFIX
"cols"
)
)
else
if
(
!
strcmp
(
psz_var
,
CFG_PREFIX
"cols"
)
)
{
{
p_sys
->
i_cols
=
__MAX
(
1
,
newval
.
i_int
);
p_sys
->
change
.
i_cols
=
__MAX
(
1
,
newval
.
i_int
);
}
}
else
if
(
!
strcmp
(
psz_var
,
CFG_PREFIX
"black-slot"
)
)
else
if
(
!
strcmp
(
psz_var
,
CFG_PREFIX
"black-slot"
)
)
{
{
p_sys
->
b_blackslot
=
newval
.
b_bool
;
p_sys
->
change
.
b_blackslot
=
newval
.
b_bool
;
}
}
shuffle
(
p_sys
);
p_sys
->
b_change
=
true
;
vlc_mutex_unlock
(
&
p_sys
->
lock
);
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
static
bool
IsFinished
(
filter_sys_t
*
p_sys
)
{
for
(
int
i
=
0
;
i
<
p_sys
->
i_cols
*
p_sys
->
i_rows
;
i
++
)
{
if
(
i
!=
p_sys
->
pi_order
[
i
]
)
return
false
;
}
return
true
;
}
static
bool
IsValid
(
filter_sys_t
*
p_sys
)
{
const
int
i_count
=
p_sys
->
i_cols
*
p_sys
->
i_rows
;
if
(
p_sys
->
b_blackslot
)
return
true
;
int
d
=
0
;
for
(
int
i
=
0
;
i
<
i_count
;
i
++
)
{
if
(
p_sys
->
pi_order
[
i
]
==
i_count
-
1
)
{
d
+=
i
/
p_sys
->
i_cols
+
1
;
continue
;
}
for
(
int
j
=
i
+
1
;
j
<
i_count
;
j
++
)
{
if
(
p_sys
->
pi_order
[
j
]
==
i_count
-
1
)
continue
;
if
(
p_sys
->
pi_order
[
i
]
>
p_sys
->
pi_order
[
j
]
)
d
++
;
}
}
return
(
d
%
2
)
==
0
;
}
static
void
Shuffle
(
filter_sys_t
*
p_sys
)
{
const
int
i_count
=
p_sys
->
i_cols
*
p_sys
->
i_rows
;
free
(
p_sys
->
pi_order
);
p_sys
->
pi_order
=
calloc
(
i_count
,
sizeof
(
*
p_sys
->
pi_order
)
);
do
{
for
(
int
i
=
0
;
i
<
i_count
;
i
++
)
p_sys
->
pi_order
[
i
]
=
-
1
;
for
(
int
c
=
0
;
c
<
i_count
;
)
{
int
i
=
rand
()
%
i_count
;
if
(
p_sys
->
pi_order
[
i
]
==
-
1
)
p_sys
->
pi_order
[
i
]
=
c
++
;
}
p_sys
->
b_finished
=
IsFinished
(
p_sys
);
}
while
(
p_sys
->
b_finished
||
IsValid
(
p_sys
)
);
if
(
p_sys
->
b_blackslot
)
{
for
(
int
i
=
0
;
i
<
i_count
;
i
++
)
{
if
(
p_sys
->
pi_order
[
i
]
==
i_count
-
1
)
{
p_sys
->
i_selected
=
i
;
break
;
}
}
}
else
{
p_sys
->
i_selected
=
-
1
;
}
}
modules/video_filter/wrapper.c
View file @
048e2d91
...
@@ -47,6 +47,7 @@ static void Close( vlc_object_t * );
...
@@ -47,6 +47,7 @@ static void Close( vlc_object_t * );
static int Open##name ( vlc_object_t *p_this ) { return Open( p_this, #name ); }
static int Open##name ( vlc_object_t *p_this ) { return Open( p_this, #name ); }
DECLARE_OPEN
(
magnify
)
DECLARE_OPEN
(
magnify
)
DECLARE_OPEN
(
puzzle
)
#undef DECLARE_OPEN
#undef DECLARE_OPEN
...
@@ -62,7 +63,10 @@ vlc_module_begin()
...
@@ -62,7 +63,10 @@ vlc_module_begin()
set_subcategory
(
SUBCAT_VIDEO_VFILTER
)
set_subcategory
(
SUBCAT_VIDEO_VFILTER
)
DECLARE_MODULE
(
magnify
)
DECLARE_MODULE
(
magnify
)
//add_submodule()
add_submodule
()
DECLARE_MODULE
(
puzzle
)
vlc_module_end
()
vlc_module_end
()
#undef DECLARE_MODULE
#undef DECLARE_MODULE
...
@@ -118,7 +122,7 @@ static int Open( vlc_object_t *p_this, const char *psz_name )
...
@@ -118,7 +122,7 @@ static int Open( vlc_object_t *p_this, const char *psz_name )
filter_chain_Reset
(
p_chain
,
&
fmt
,
&
fmt
);
filter_chain_Reset
(
p_chain
,
&
fmt
,
&
fmt
);
filter_t
*
p_filter
=
filter_t
*
p_filter
=
filter_chain_AppendFilter
(
p_chain
,
psz_name
,
NULL
,
&
fmt
,
&
fmt
);
filter_chain_AppendFilter
(
p_chain
,
psz_name
,
p_vout
->
p_cfg
,
&
fmt
,
&
fmt
);
if
(
!
p_filter
)
if
(
!
p_filter
)
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment