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
13bccc2f
Commit
13bccc2f
authored
Apr 06, 2007
by
Antoine Cellerier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make it possible to change the fake-image at runtime.
Add option to specify the chroma used by fake.
parent
b09aaba5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
99 additions
and
12 deletions
+99
-12
modules/codec/fake.c
modules/codec/fake.c
+99
-12
No files found.
modules/codec/fake.c
View file @
13bccc2f
...
...
@@ -38,6 +38,8 @@ static int OpenDecoder ( vlc_object_t * );
static
void
CloseDecoder
(
vlc_object_t
*
);
static
picture_t
*
DecodeBlock
(
decoder_t
*
,
block_t
**
);
static
int
FakeCallback
(
vlc_object_t
*
,
char
const
*
,
vlc_value_t
,
vlc_value_t
,
void
*
);
/*****************************************************************************
* Module descriptor
...
...
@@ -63,6 +65,9 @@ static picture_t *DecodeBlock ( decoder_t *, block_t ** );
#define DEINTERLACE_MODULE_TEXT N_("Deinterlace module")
#define DEINTERLACE_MODULE_LONGTEXT N_( \
"Deinterlace module to use." )
#define CHROMA_TEXT N_("Chroma used.")
#define CHROMA_LONGTEXT N_( \
"Force use of a specific chroma for output. Default is I420." )
static
const
char
*
ppsz_deinterlace_type
[]
=
{
...
...
@@ -94,8 +99,16 @@ vlc_module_begin();
DEINTERLACE_MODULE_TEXT
,
DEINTERLACE_MODULE_LONGTEXT
,
VLC_FALSE
);
change_string_list
(
ppsz_deinterlace_type
,
0
,
0
);
add_string
(
"fake-chroma"
,
"I420"
,
NULL
,
CHROMA_TEXT
,
CHROMA_LONGTEXT
,
VLC_TRUE
);
vlc_module_end
();
struct
decoder_sys_t
{
picture_t
*
p_image
;
vlc_mutex_t
lock
;
};
/*****************************************************************************
* OpenDecoder: probe the decoder and return score
*****************************************************************************/
...
...
@@ -106,7 +119,7 @@ static int OpenDecoder( vlc_object_t *p_this )
image_handler_t
*
p_handler
;
video_format_t
fmt_in
,
fmt_out
;
picture_t
*
p_image
;
char
*
psz_file
;
char
*
psz_file
,
*
psz_chroma
;
vlc_bool_t
b_keep_ar
;
int
i_aspect
=
0
;
...
...
@@ -115,19 +128,37 @@ static int OpenDecoder( vlc_object_t *p_this )
return
VLC_EGENERIC
;
}
var_Create
(
p_dec
,
"fake-file"
,
VLC_VAR_STRING
|
VLC_VAR_DOINHERIT
);
var_Get
(
p_dec
,
"fake-file"
,
&
val
);
if
(
val
.
psz_string
==
NULL
||
!*
val
.
psz_string
)
p_dec
->
p_sys
=
(
decoder_sys_t
*
)
malloc
(
sizeof
(
decoder_sys_t
)
);
if
(
!
p_dec
->
p_sys
)
{
return
VLC_ENOMEM
;
}
psz_file
=
var_CreateGetNonEmptyStringCommand
(
p_dec
,
"fake-file"
);
if
(
!
psz_file
)
{
if
(
val
.
psz_string
)
free
(
val
.
psz_string
);
msg_Err
(
p_dec
,
"specify a file with --fake-file=..."
);
return
VLC_EGENERIC
;
}
psz_file
=
val
.
psz_string
;
var_AddCallback
(
p_dec
,
"fake-file"
,
FakeCallback
,
p_dec
)
;
memset
(
&
fmt_in
,
0
,
sizeof
(
fmt_in
)
);
memset
(
&
fmt_out
,
0
,
sizeof
(
fmt_out
)
);
fmt_out
.
i_chroma
=
VLC_FOURCC
(
'I'
,
'4'
,
'2'
,
'0'
);
psz_chroma
=
var_CreateGetString
(
p_dec
,
"fake-chroma"
);
if
(
strlen
(
psz_chroma
)
!=
4
)
{
msg_Warn
(
p_dec
,
"Invalid chroma (%s). Using I420."
,
psz_chroma
);
fmt_out
.
i_chroma
=
VLC_FOURCC
(
'I'
,
'4'
,
'2'
,
'0'
);
}
else
{
fmt_out
.
i_chroma
=
VLC_FOURCC
(
psz_chroma
[
0
],
psz_chroma
[
1
],
psz_chroma
[
2
],
psz_chroma
[
3
]
);
}
free
(
psz_chroma
);
var_Create
(
p_dec
,
"fake-keep-ar"
,
VLC_VAR_BOOL
|
VLC_VAR_DOINHERIT
);
var_Get
(
p_dec
,
"fake-keep-ar"
,
&
val
);
...
...
@@ -265,12 +296,14 @@ static int OpenDecoder( vlc_object_t *p_this )
/* Set output properties */
p_dec
->
fmt_out
.
i_cat
=
VIDEO_ES
;
p_dec
->
fmt_out
.
i_codec
=
VLC_FOURCC
(
'I'
,
'4'
,
'2'
,
'0'
)
;
p_dec
->
fmt_out
.
i_codec
=
fmt_out
.
i_chroma
;
p_dec
->
fmt_out
.
video
=
fmt_out
;
/* Set callbacks */
p_dec
->
pf_decode_video
=
DecodeBlock
;
p_dec
->
p_sys
=
(
decoder_sys_t
*
)
p_image
;
p_dec
->
p_sys
->
p_image
=
p_image
;
vlc_mutex_init
(
p_dec
,
&
p_dec
->
p_sys
->
lock
);
return
VLC_SUCCESS
;
}
...
...
@@ -280,7 +313,6 @@ static int OpenDecoder( vlc_object_t *p_this )
****************************************************************************/
static
picture_t
*
DecodeBlock
(
decoder_t
*
p_dec
,
block_t
**
pp_block
)
{
picture_t
*
p_image
=
(
picture_t
*
)
p_dec
->
p_sys
;
picture_t
*
p_pic
;
if
(
pp_block
==
NULL
||
!*
pp_block
)
return
NULL
;
...
...
@@ -291,7 +323,10 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
goto
error
;
}
vout_CopyPicture
(
p_dec
,
p_pic
,
p_image
);
vlc_mutex_lock
(
&
p_dec
->
p_sys
->
lock
);
vout_CopyPicture
(
p_dec
,
p_pic
,
p_dec
->
p_sys
->
p_image
);
vlc_mutex_unlock
(
&
p_dec
->
p_sys
->
lock
);
p_pic
->
date
=
(
*
pp_block
)
->
i_pts
;
error:
...
...
@@ -307,8 +342,60 @@ error:
static
void
CloseDecoder
(
vlc_object_t
*
p_this
)
{
decoder_t
*
p_dec
=
(
decoder_t
*
)
p_this
;
picture_t
*
p_image
=
(
picture_t
*
)
p_dec
->
p_sys
;
picture_t
*
p_image
=
p_dec
->
p_sys
->
p_image
;
if
(
p_image
!=
NULL
)
p_image
->
pf_release
(
p_image
);
vlc_mutex_destroy
(
&
p_dec
->
p_sys
->
lock
);
free
(
p_dec
->
p_sys
);
}
/*****************************************************************************
* FakeCallback: Image source change callback.
*****************************************************************************/
static
int
FakeCallback
(
vlc_object_t
*
p_this
,
char
const
*
psz_var
,
vlc_value_t
oldval
,
vlc_value_t
newval
,
void
*
p_data
)
{
decoder_t
*
p_dec
=
(
decoder_t
*
)
p_data
;
if
(
!
strcmp
(
psz_var
,
"fake-file"
)
)
{
image_handler_t
*
p_handler
;
picture_t
*
p_new_image
;
video_format_t
fmt_in
,
fmt_out
;
char
*
psz_file
=
newval
.
psz_string
;
picture_t
*
p_image
;
vlc_mutex_lock
(
&
p_dec
->
p_sys
->
lock
);
p_image
=
p_dec
->
p_sys
->
p_image
;
if
(
!
psz_file
||
!*
psz_file
)
{
msg_Err
(
p_dec
,
"fake-file value must be non empty."
);
vlc_mutex_unlock
(
&
p_dec
->
p_sys
->
lock
);
return
VLC_EGENERIC
;
}
msg_Dbg
(
p_dec
,
"Changing fake-file to %s."
,
psz_file
);
memset
(
&
fmt_in
,
0
,
sizeof
(
fmt_in
)
);
fmt_out
=
p_dec
->
fmt_out
.
video
;
p_handler
=
image_HandlerCreate
(
p_dec
);
p_new_image
=
image_ReadUrl
(
p_handler
,
psz_file
,
&
fmt_in
,
&
fmt_out
);
image_HandlerDelete
(
p_handler
);
if
(
!
p_new_image
)
{
msg_Err
(
p_dec
,
"error while reading image (%s)"
,
psz_file
);
vlc_mutex_unlock
(
&
p_dec
->
p_sys
->
lock
);
return
VLC_EGENERIC
;
}
p_dec
->
p_sys
->
p_image
=
p_new_image
;
p_image
->
pf_release
(
p_image
);
vlc_mutex_unlock
(
&
p_dec
->
p_sys
->
lock
);
}
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