Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
11704ece
Commit
11704ece
authored
Nov 09, 2004
by
Gildas Bazin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* modules/video_filter/logo.c: whole bunch of fixes.
parent
ed673a8c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
82 deletions
+62
-82
modules/video_filter/logo.c
modules/video_filter/logo.c
+62
-82
No files found.
modules/video_filter/logo.c
View file @
11704ece
...
@@ -55,9 +55,8 @@ static int Control ( vout_thread_t *, int, va_list );
...
@@ -55,9 +55,8 @@ static int Control ( vout_thread_t *, int, va_list );
static
int
CreateFilter
(
vlc_object_t
*
);
static
int
CreateFilter
(
vlc_object_t
*
);
static
void
DestroyFilter
(
vlc_object_t
*
);
static
void
DestroyFilter
(
vlc_object_t
*
);
static
int
LogoCallback
(
vlc_object_t
*
p_this
,
char
const
*
psz_var
,
static
int
LogoCallback
(
vlc_object_t
*
,
char
const
*
,
vlc_value_t
oldval
,
vlc_value_t
newval
,
vlc_value_t
,
vlc_value_t
,
void
*
);
void
*
p_data
);
/*****************************************************************************
/*****************************************************************************
* Module descriptor
* Module descriptor
...
@@ -107,14 +106,14 @@ vlc_module_end();
...
@@ -107,14 +106,14 @@ vlc_module_end();
/*****************************************************************************
/*****************************************************************************
* LoadPNG: loads the PNG logo into memory
* LoadPNG: loads the PNG logo into memory
*****************************************************************************/
*****************************************************************************/
static
picture_t
*
LoadPNG
(
vlc_object_t
*
p_this
,
char
*
psz_filename
,
int
i_trans
)
static
picture_t
*
LoadPNG
(
vlc_object_t
*
p_this
,
char
*
psz_filename
,
int
i_trans
)
{
{
picture_t
*
p_pic
;
picture_t
*
p_pic
;
FILE
*
file
;
FILE
*
file
;
int
i
,
j
;
int
i
,
j
;
vlc_bool_t
b_alpha
=
VLC_TRUE
;
vlc_bool_t
b_alpha
=
VLC_TRUE
;
png_uint_32
i_width
,
i_height
;
png_uint_32
i_width
,
i_height
;
int
i_color_type
,
i_interlace_type
,
i_compression_type
,
i_filter_type
;
int
i_color_type
,
i_interlace_type
,
i_compression_type
,
i_filter_type
;
int
i_bit_depth
;
int
i_bit_depth
;
...
@@ -538,13 +537,13 @@ struct filter_sys_t
...
@@ -538,13 +537,13 @@ struct filter_sys_t
char
*
psz_filename
;
char
*
psz_filename
;
int
i_trans
;
int
i_trans
;
time_t
last_time
;
vlc_bool_t
b_absolute
;
vlc_bool_t
b_absolute
;
mtime_t
i_last_date
;
mtime_t
i_last_date
;
/* On the fly control variable: */
/* On the fly control variable */
vlc_bool_t
b_need_update
;
vlc_bool_t
b_need_update
;
vlc_bool_t
b_new
PNG
;
vlc_bool_t
b_new
_png
;
};
};
static
subpicture_t
*
Filter
(
filter_t
*
,
mtime_t
);
static
subpicture_t
*
Filter
(
filter_t
*
,
mtime_t
);
...
@@ -565,10 +564,12 @@ static int CreateFilter( vlc_object_t *p_this )
...
@@ -565,10 +564,12 @@ static int CreateFilter( vlc_object_t *p_this )
msg_Err
(
p_filter
,
"out of memory"
);
msg_Err
(
p_filter
,
"out of memory"
);
return
VLC_ENOMEM
;
return
VLC_ENOMEM
;
}
}
/* Hook used for callback variables */
/* Hook used for callback variables */
p_input
=
vlc_object_find
(
p_this
,
VLC_OBJECT_INPUT
,
FIND_
ANYWHERE
);
p_input
=
vlc_object_find
(
p_this
,
VLC_OBJECT_INPUT
,
FIND_
PARENT
);
if
(
!
p_input
)
if
(
!
p_input
)
{
{
free
(
p_sys
);
return
VLC_ENOOBJ
;
return
VLC_ENOOBJ
;
}
}
...
@@ -576,6 +577,8 @@ static int CreateFilter( vlc_object_t *p_this )
...
@@ -576,6 +577,8 @@ static int CreateFilter( vlc_object_t *p_this )
if
(
!
p_sys
->
psz_filename
||
!*
p_sys
->
psz_filename
)
if
(
!
p_sys
->
psz_filename
||
!*
p_sys
->
psz_filename
)
{
{
msg_Err
(
p_this
,
"logo file not specified"
);
msg_Err
(
p_this
,
"logo file not specified"
);
vlc_object_release
(
p_input
);
free
(
p_sys
);
return
0
;
return
0
;
}
}
...
@@ -585,8 +588,6 @@ static int CreateFilter( vlc_object_t *p_this )
...
@@ -585,8 +588,6 @@ static int CreateFilter( vlc_object_t *p_this )
p_sys
->
i_trans
=
var_CreateGetInteger
(
p_input
,
"logo-transparency"
);
p_sys
->
i_trans
=
var_CreateGetInteger
(
p_input
,
"logo-transparency"
);
p_sys
->
i_trans
=
__MAX
(
__MIN
(
p_sys
->
i_trans
,
255
),
0
);
p_sys
->
i_trans
=
__MAX
(
__MIN
(
p_sys
->
i_trans
,
255
),
0
);
p_sys
->
p_pic
=
LoadPNG
(
p_this
,
p_sys
->
psz_filename
,
p_sys
->
i_trans
);
var_AddCallback
(
p_input
,
"logo-file"
,
LogoCallback
,
p_sys
);
var_AddCallback
(
p_input
,
"logo-file"
,
LogoCallback
,
p_sys
);
var_AddCallback
(
p_input
,
"logo-x"
,
LogoCallback
,
p_sys
);
var_AddCallback
(
p_input
,
"logo-x"
,
LogoCallback
,
p_sys
);
var_AddCallback
(
p_input
,
"logo-y"
,
LogoCallback
,
p_sys
);
var_AddCallback
(
p_input
,
"logo-y"
,
LogoCallback
,
p_sys
);
...
@@ -608,14 +609,13 @@ static int CreateFilter( vlc_object_t *p_this )
...
@@ -608,14 +609,13 @@ static int CreateFilter( vlc_object_t *p_this )
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
p_sys
->
i_width
=
p_sys
->
p_pic
->
p
[
Y_PLANE
].
i_visible_pitch
;
p_sys
->
i_height
=
p_sys
->
p_pic
->
p
[
Y_PLANE
].
i_visible_lines
;
p_sys
->
i_last_date
=
0
;
/* Misc init */
/* Misc init */
p_filter
->
pf_sub_filter
=
Filter
;
p_filter
->
pf_sub_filter
=
Filter
;
p_sys
->
i_width
=
p_sys
->
p_pic
->
p
[
Y_PLANE
].
i_visible_pitch
;
p_sys
->
i_height
=
p_sys
->
p_pic
->
p
[
Y_PLANE
].
i_visible_lines
;
p_sys
->
b_need_update
=
VLC_TRUE
;
p_sys
->
b_need_update
=
VLC_TRUE
;
p_sys
->
last_time
=
((
time_t
)
-
1
);
p_sys
->
b_new_png
=
VLC_FALSE
;
p_sys
->
i_last_date
=
0
;
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
...
@@ -636,79 +636,67 @@ static void DestroyFilter( vlc_object_t *p_this )
...
@@ -636,79 +636,67 @@ static void DestroyFilter( vlc_object_t *p_this )
free
(
p_sys
);
free
(
p_sys
);
/* Delete the logo variables from INPUT */
/* Delete the logo variables from INPUT */
p_input
=
vlc_object_find
(
p_this
,
VLC_OBJECT_INPUT
,
FIND_ANYWHERE
);
p_input
=
vlc_object_find
(
p_this
,
VLC_OBJECT_INPUT
,
FIND_PARENT
);
if
(
!
p_input
)
if
(
!
p_input
)
return
;
{
return
;
}
var_Destroy
(
p_input
,
"logo-file"
);
var_Destroy
(
p_input
,
"logo-file"
);
var_Destroy
(
p_input
,
"logo-x"
);
var_Destroy
(
p_input
,
"logo-x"
);
var_Destroy
(
p_input
,
"logo-y"
);
var_Destroy
(
p_input
,
"logo-y"
);
var_Destroy
(
p_input
,
"logo-position"
);
var_Destroy
(
p_input
,
"logo-position"
);
var_Destroy
(
p_input
,
"logo-transparency"
);
var_Destroy
(
p_input
,
"logo-transparency"
);
vlc_object_release
(
p_input
);
vlc_object_release
(
p_input
);
}
}
/****************************************************************************
/****************************************************************************
*
* Filter: the whole thing
* Filter: the whole thing
****************************************************************************
****************************************************************************
*
* This function outputs subpictures at regular time intervals.
* This function outputs subpictures at regular time intervals.
****************************************************************************/
****************************************************************************
*
/
static
subpicture_t
*
Filter
(
filter_t
*
p_filter
,
mtime_t
date
)
static
subpicture_t
*
Filter
(
filter_t
*
p_filter
,
mtime_t
date
)
{
{
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
subpicture_t
*
p_spu
;
subpicture_t
*
p_spu
;
subpicture_region_t
*
p_region
;
subpicture_region_t
*
p_region
;
video_format_t
fmt
;
video_format_t
fmt
;
filter_sys_t
*
p_dummy
;
time_t
t
;
FILE
*
file
;
if
(
p_sys
->
last_time
==
time
(
NULL
)
)
if
(
!
p_sys
->
b_need_update
&&
p_sys
->
i_last_date
+
5000000
>
date
)
return
0
;
{
return
NULL
;
}
if
(
p_sys
->
b_need_update
==
VLC_FALSE
)
{
return
NULL
;
}
if
(
p_sys
->
b_newPNG
==
VLC_TRUE
)
if
(
p_sys
->
b_new_png
)
{
/* Trap invalid filenames, else get new graphic, swap for old */
if
(
!
(
file
=
fopen
(
p_sys
->
psz_filename
,
"rb"
))
)
{
msg_Err
(
p_filter
,
"logo file (%s) not found"
,
p_sys
->
psz_filename
);
p_sys
->
b_newPNG
=
VLC_FALSE
;
}
else
{
{
fclose
(
file
);
if
(
p_sys
->
p_pic
&&
p_sys
->
p_pic
->
p_data_orig
)
p_dummy
=
malloc
(
sizeof
(
filter_sys_t
)
);
free
(
p_sys
->
p_pic
->
p_data_orig
);
p_dummy
->
p_pic
=
malloc
(
sizeof
(
picture_t
)
);
if
(
p_sys
->
p_pic
)
free
(
p_sys
->
p_pic
);
p_dummy
->
p_pic
=
LoadPNG
(
p_filter
,
p_sys
->
psz_filename
,
p_sys
->
i_trans
);
if
(
!
p_sys
->
p_pic
)
p_sys
->
p_pic
=
LoadPNG
(
VLC_OBJECT
(
p_filter
),
p_sys
->
psz_filename
,
p_sys
->
i_trans
);
if
(
p_sys
->
p_pic
)
{
{
p_dummy
->
p_pic
=
p_sys
->
p_pic
;
}
/* if( p_sys->p_pic ) free( p_sys->p_pic ); */
p_sys
->
p_pic
=
p_dummy
->
p_pic
;
free
(
p_dummy
->
p_pic
);
free
(
p_dummy
);
p_sys
->
i_width
=
p_sys
->
p_pic
->
p
[
Y_PLANE
].
i_visible_pitch
;
p_sys
->
i_width
=
p_sys
->
p_pic
->
p
[
Y_PLANE
].
i_visible_pitch
;
p_sys
->
i_height
=
p_sys
->
p_pic
->
p
[
Y_PLANE
].
i_visible_lines
;
p_sys
->
i_height
=
p_sys
->
p_pic
->
p
[
Y_PLANE
].
i_visible_lines
;
p_sys
->
i_last_date
=
0
;
p_sys
->
b_newPNG
=
VLC_FALSE
;
}
}
p_sys
->
b_new_png
=
VLC_FALSE
;
}
}
p_sys
->
b_need_update
=
VLC_FALSE
;
/* Allocate the subpicture internal data. */
/* Allocate the subpicture internal data. */
p_spu
=
p_filter
->
pf_sub_buffer_new
(
p_filter
);
p_spu
=
p_filter
->
pf_sub_buffer_new
(
p_filter
);
if
(
!
p_spu
)
return
NULL
;
if
(
!
p_spu
)
return
NULL
;
p_spu
->
b_absolute
=
p_sys
->
b_absolute
;
p_spu
->
i_start
=
p_sys
->
i_last_date
=
date
;
p_spu
->
i_stop
=
0
;
p_spu
->
b_ephemer
=
VLC_TRUE
;
p_sys
->
b_need_update
=
VLC_FALSE
;
if
(
!
p_sys
->
p_pic
||
!
p_sys
->
i_trans
)
{
/* Send an empty subpicture to clear the display */
return
p_spu
;
}
/* Create new SPU region */
/* Create new SPU region */
memset
(
&
fmt
,
0
,
sizeof
(
video_format_t
)
);
memset
(
&
fmt
,
0
,
sizeof
(
video_format_t
)
);
fmt
.
i_chroma
=
VLC_FOURCC
(
'Y'
,
'U'
,
'V'
,
'A'
);
fmt
.
i_chroma
=
VLC_FOURCC
(
'Y'
,
'U'
,
'V'
,
'A'
);
...
@@ -725,38 +713,30 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
...
@@ -725,38 +713,30 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
return
NULL
;
return
NULL
;
}
}
t
=
p_sys
->
last_time
=
time
(
NULL
);
vout_CopyPicture
(
p_filter
,
&
p_region
->
picture
,
p_sys
->
p_pic
);
vout_CopyPicture
(
p_filter
,
&
p_region
->
picture
,
p_sys
->
p_pic
);
p_region
->
i_x
=
0
;
p_region
->
i_x
=
0
;
p_region
->
i_y
=
0
;
p_region
->
i_y
=
0
;
p_spu
->
i_x
=
p_sys
->
posx
;
p_spu
->
i_x
=
p_sys
->
posx
;
p_spu
->
i_y
=
p_sys
->
posy
;
p_spu
->
i_y
=
p_sys
->
posy
;
p_spu
->
i_flags
=
p_sys
->
pos
;
p_spu
->
i_flags
=
p_sys
->
pos
;
p_spu
->
b_absolute
=
p_sys
->
b_absolute
;
p_spu
->
p_region
=
p_region
;
p_spu
->
p_region
=
p_region
;
p_spu
->
i_start
=
p_sys
->
i_last_date
=
date
;
p_spu
->
i_stop
=
0
;
p_spu
->
b_ephemer
=
VLC_TRUE
;
p_sys
->
b_need_update
=
VLC_FALSE
;
return
p_spu
;
return
p_spu
;
}
}
/**********************************************************************
/*****************************************************************************
* Callback to update params on the fly
* Callback to update params on the fly
**********************************************************************/
**********************************************************************
*******
/
static
int
LogoCallback
(
vlc_object_t
*
p_this
,
char
const
*
psz_var
,
static
int
LogoCallback
(
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
)
{
{
filter_sys_t
*
p_sys
=
(
filter_sys_t
*
)
p_data
;
filter_sys_t
*
p_sys
=
(
filter_sys_t
*
)
p_data
;
if
(
!
strncmp
(
psz_var
,
"logo-file"
,
6
)
)
if
(
!
strncmp
(
psz_var
,
"logo-file"
,
6
)
)
{
{
if
(
p_sys
->
psz_filename
)
free
(
p_sys
->
psz_filename
);
if
(
p_sys
->
psz_filename
)
free
(
p_sys
->
psz_filename
);
p_sys
->
psz_filename
=
strdup
(
newval
.
psz_string
);
p_sys
->
psz_filename
=
strdup
(
newval
.
psz_string
);
p_sys
->
b_new
PNG
=
VLC_TRUE
;
p_sys
->
b_new
_png
=
VLC_TRUE
;
}
}
else
if
(
!
strncmp
(
psz_var
,
"logo-x"
,
6
)
)
else
if
(
!
strncmp
(
psz_var
,
"logo-x"
,
6
)
)
{
{
...
@@ -773,7 +753,7 @@ static int LogoCallback( vlc_object_t *p_this, char const *psz_var,
...
@@ -773,7 +753,7 @@ static int LogoCallback( vlc_object_t *p_this, char const *psz_var,
else
if
(
!
strncmp
(
psz_var
,
"logo-transparency"
,
9
)
)
else
if
(
!
strncmp
(
psz_var
,
"logo-transparency"
,
9
)
)
{
{
p_sys
->
i_trans
=
__MAX
(
__MIN
(
newval
.
i_int
,
255
),
0
);
p_sys
->
i_trans
=
__MAX
(
__MIN
(
newval
.
i_int
,
255
),
0
);
p_sys
->
b_new
PNG
=
VLC_TRUE
;
p_sys
->
b_new
_png
=
VLC_TRUE
;
}
}
p_sys
->
b_need_update
=
VLC_TRUE
;
p_sys
->
b_need_update
=
VLC_TRUE
;
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
...
...
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