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
24dc93c6
Commit
24dc93c6
authored
Sep 07, 2009
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Converted vmem to "vout display" API.
parent
74b6f45e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
200 additions
and
207 deletions
+200
-207
modules/video_output/vmem.c
modules/video_output/vmem.c
+200
-207
No files found.
modules/video_output/vmem.c
View file @
24dc93c6
...
@@ -29,284 +29,277 @@
...
@@ -29,284 +29,277 @@
# include "config.h"
# include "config.h"
#endif
#endif
#include <assert.h>
#include <vlc_common.h>
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_plugin.h>
#include <vlc_vout.h>
#include <vlc_vout_display.h>
#include <vlc_picture_pool.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
int
LockPicture
(
vout_thread_t
*
,
picture_t
*
);
static
int
UnlockPicture
(
vout_thread_t
*
,
picture_t
*
);
/*****************************************************************************
/*****************************************************************************
* Module descriptor
* Module descriptor
*****************************************************************************/
*****************************************************************************/
#define T_WIDTH N_(
"Width"
)
#define T_WIDTH N_(
"Width"
)
#define LT_WIDTH N_(
"Video memory buffer width."
)
#define LT_WIDTH N_(
"Video memory buffer width."
)
#define T_HEIGHT N_(
"Height"
)
#define T_HEIGHT N_(
"Height"
)
#define LT_HEIGHT N_(
"Video memory buffer height."
)
#define LT_HEIGHT N_(
"Video memory buffer height."
)
#define T_PITCH N_(
"Pitch"
)
#define T_PITCH N_(
"Pitch"
)
#define LT_PITCH N_(
"Video memory buffer pitch in bytes."
)
#define LT_PITCH N_(
"Video memory buffer pitch in bytes."
)
#define T_CHROMA N_(
"Chroma"
)
#define T_CHROMA N_(
"Chroma"
)
#define LT_CHROMA N_(
"Output chroma for the memory image as a 4-character " \
#define LT_CHROMA N_("Output chroma for the memory image as a 4-character " \
"string, eg. \"RV32\"."
)
"string, eg. \"RV32\".")
#define T_LOCK N_(
"Lock function"
)
#define T_LOCK N_(
"Lock function"
)
#define LT_LOCK N_(
"Address of the locking callback function. This " \
#define LT_LOCK N_("Address of the locking callback function. This " \
"function must fill in valid plane memory address " \
"function must fill in valid plane memory address " \
"information for use by the video renderer." )
"information for use by the video renderer.")
#define T_UNLOCK N_( "Unlock function" )
#define LT_UNLOCK N_( "Address of the unlocking callback function" )
#define T_
DATA N_( "Callback data"
)
#define T_
UNLOCK N_("Unlock function"
)
#define LT_
DATA N_( "Data for the locking and unlocking functions"
)
#define LT_
UNLOCK N_("Address of the unlocking callback function"
)
vlc_module_begin
()
#define T_DATA N_("Callback data")
set_description
(
N_
(
"Video memory output"
)
)
#define LT_DATA N_("Data for the locking and unlocking functions")
set_shortname
(
N_
(
"Video memory"
)
)
set_category
(
CAT_VIDEO
)
static
int
Open
(
vlc_object_t
*
);
set_subcategory
(
SUBCAT_VIDEO_VOUT
)
static
void
Close
(
vlc_object_t
*
);
set_capability
(
"video output"
,
0
)
add_integer
(
"vmem-width"
,
320
,
NULL
,
T_WIDTH
,
LT_WIDTH
,
false
)
vlc_module_begin
()
add_integer
(
"vmem-height"
,
200
,
NULL
,
T_HEIGHT
,
LT_HEIGHT
,
false
)
set_description
(
N_
(
"Video memory output"
))
add_integer
(
"vmem-pitch"
,
640
,
NULL
,
T_PITCH
,
LT_PITCH
,
false
)
set_shortname
(
N_
(
"Video memory"
))
add_string
(
"vmem-chroma"
,
"RV16"
,
NULL
,
T_CHROMA
,
LT_CHROMA
,
true
)
add_string
(
"vmem-lock"
,
"0"
,
NULL
,
T_LOCK
,
LT_LOCK
,
true
)
add_string
(
"vmem-unlock"
,
"0"
,
NULL
,
T_UNLOCK
,
LT_UNLOCK
,
true
)
add_string
(
"vmem-data"
,
"0"
,
NULL
,
T_DATA
,
LT_DATA
,
true
)
set_callbacks
(
Create
,
Destroy
)
set_category
(
CAT_VIDEO
)
vlc_module_end
()
set_subcategory
(
SUBCAT_VIDEO_VOUT
)
set_capability
(
"vout display"
,
0
)
/*****************************************************************************
add_integer
(
"vmem-width"
,
320
,
NULL
,
T_WIDTH
,
LT_WIDTH
,
false
)
* vout_sys_t: video output descriptor
add_integer
(
"vmem-height"
,
200
,
NULL
,
T_HEIGHT
,
LT_HEIGHT
,
false
)
*****************************************************************************/
add_integer
(
"vmem-pitch"
,
640
,
NULL
,
T_PITCH
,
LT_PITCH
,
false
)
struct
vout_sys_t
add_string
(
"vmem-chroma"
,
"RV16"
,
NULL
,
T_CHROMA
,
LT_CHROMA
,
true
)
{
add_string
(
"vmem-lock"
,
"0"
,
NULL
,
T_LOCK
,
LT_LOCK
,
true
)
int
i_width
,
i_height
,
i_pitch
;
add_string
(
"vmem-unlock"
,
"0"
,
NULL
,
T_UNLOCK
,
LT_UNLOCK
,
true
)
add_string
(
"vmem-data"
,
"0"
,
NULL
,
T_DATA
,
LT_DATA
,
true
)
void
(
*
pf_lock
)
(
void
*
,
void
**
);
set_callbacks
(
Open
,
Close
)
void
(
*
pf_unlock
)
(
void
*
);
vlc_module_end
()
void
*
p_data
;
};
/*****************************************************************************
/*****************************************************************************
* Create: allocates video thread
* Local prototypes
*****************************************************************************
* This function allocates and initializes a vout method.
*****************************************************************************/
*****************************************************************************/
static
int
Create
(
vlc_object_t
*
p_this
)
struct
picture_sys_t
{
{
void
(
*
lock
)(
void
*
sys
,
void
**
plane
);
vout_thread_t
*
p_vout
=
(
vout_thread_t
*
)
p_this
;
void
(
*
unlock
)(
void
*
sys
);
void
*
sys
;
};
/* Allocate instance and initialize some members */
struct
vout_display_sys_t
{
p_vout
->
p_sys
=
malloc
(
sizeof
(
vout_sys_t
)
);
picture_pool_t
*
pool
;
if
(
!
p_vout
->
p_sys
)
};
return
VLC_ENOMEM
;
p_vout
->
pf_init
=
Init
;
static
picture_t
*
Get
(
vout_display_t
*
);
p_vout
->
pf_end
=
End
;
static
void
Display
(
vout_display_t
*
,
picture_t
*
);
p_vout
->
pf_manage
=
NULL
;
static
int
Control
(
vout_display_t
*
,
int
,
va_list
);
p_vout
->
pf_render
=
NULL
;
static
void
Manage
(
vout_display_t
*
);
p_vout
->
pf_display
=
NULL
;
return
VLC_SUCCESS
;
static
int
Lock
(
picture_t
*
)
;
}
static
void
Unlock
(
picture_t
*
);
/*****************************************************************************
/*****************************************************************************
* Init: initialize video thread
* Open: allocates video thread
*****************************************************************************
* This function allocates and initializes a vout method.
*****************************************************************************/
*****************************************************************************/
static
int
Init
(
vout_thread_t
*
p_vout
)
static
int
Open
(
vlc_object_t
*
object
)
{
{
int
i_index
;
vout_display_t
*
vd
=
(
vout_display_t
*
)
object
;
picture_t
*
p_pic
;
char
*
psz_chroma
,
*
psz_tmp
;
/* */
int
i_width
,
i_height
,
i_pitch
;
char
*
chroma_format
=
var_CreateGetString
(
vd
,
"vmem-chroma"
);
vlc_fourcc_t
i_chroma
;
const
vlc_fourcc_t
chroma
=
vlc_fourcc_GetCodecFromString
(
VIDEO_ES
,
chroma_format
);
free
(
chroma_format
);
i_width
=
var_CreateGetInteger
(
p_vout
,
"vmem-width"
);
if
(
!
chroma
)
{
i_height
=
var_CreateGetInteger
(
p_vout
,
"vmem-height"
);
msg_Err
(
vd
,
"vmem-chroma should be 4 characters long"
);
i_pitch
=
var_CreateGetInteger
(
p_vout
,
"vmem-pitch"
);
psz_chroma
=
var_CreateGetString
(
p_vout
,
"vmem-chroma"
);
if
(
!
psz_chroma
)
{
msg_Err
(
p_vout
,
"Cannot find chroma information."
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
i_chroma
=
vlc_fourcc_GetCodecFromString
(
VIDEO_ES
,
psz_chroma
);
/* */
free
(
psz_chroma
)
;
picture_sys_t
cfg
;
if
(
!
i_chroma
)
char
*
tmp
;
{
tmp
=
var_CreateGetString
(
vd
,
"vmem-lock"
);
msg_Err
(
p_vout
,
"vmem-chroma should be 4 characters long"
);
cfg
.
lock
=
(
void
(
*
)(
void
*
,
void
**
))(
intptr_t
)
atoll
(
tmp
);
return
VLC_EGENERIC
;
free
(
tmp
);
}
psz_tmp
=
var_CreateGetString
(
p_vout
,
"vmem-lock"
);
tmp
=
var_CreateGetString
(
vd
,
"vmem-unlock"
);
p_vout
->
p_sys
->
pf_lock
=
(
void
(
*
)
(
void
*
,
void
**
))(
intptr_t
)
atoll
(
psz_tmp
);
cfg
.
unlock
=
(
void
(
*
)(
void
*
))(
intptr_t
)
atoll
(
tmp
);
free
(
psz_tmp
);
free
(
tmp
);
psz_tmp
=
var_CreateGetString
(
p_vout
,
"vmem-unlock"
);
tmp
=
var_CreateGetString
(
vd
,
"vmem-data"
);
p_vout
->
p_sys
->
pf_unlock
=
(
void
(
*
)
(
void
*
))(
intptr_t
)
atoll
(
psz_tmp
);
cfg
.
sys
=
(
void
*
)(
intptr_t
)
atoll
(
tmp
);
free
(
psz_tmp
);
free
(
tmp
);
/* pf_lock and pf_unlock are mandatory */
/* lock and unlock are mandatory */
if
(
!
p_vout
->
p_sys
->
pf_lock
||
!
p_vout
->
p_sys
->
pf_unlock
)
if
(
!
cfg
.
lock
||
!
cfg
.
unlock
)
{
{
msg_Err
(
vd
,
"Invalid lock or unlock callbacks"
);
msg_Err
(
p_vout
,
"Invalid lock or unlock callbacks"
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
psz_tmp
=
var_CreateGetString
(
p_vout
,
"vmem-data"
);
/* */
p_vout
->
p_sys
->
p_data
=
(
void
*
)(
intptr_t
)
atoll
(
psz_tmp
);
video_format_t
fmt
=
vd
->
fmt
;
free
(
psz_tmp
);
I_OUTPUTPICTURES
=
0
;
/* Initialize the output structure */
fmt
.
i_chroma
=
chroma
;
p_vout
->
output
.
i_chroma
=
i_chroma
;
fmt
.
i_width
=
var_CreateGetInteger
(
vd
,
"vmem-width"
);
p_vout
->
output
.
pf_setpalette
=
NULL
;
fmt
.
i_height
=
var_CreateGetInteger
(
vd
,
"vmem-height"
);
p_vout
->
output
.
i_width
=
i_width
;
p_vout
->
output
.
i_height
=
i_height
;
p_vout
->
output
.
i_aspect
=
p_vout
->
output
.
i_width
*
VOUT_ASPECT_FACTOR
/
p_vout
->
output
.
i_height
;
/* Define the bitmasks */
/* Define the bitmasks */
switch
(
i_chroma
)
switch
(
chroma
)
{
{
case
VLC_CODEC_RGB15
:
case
VLC_CODEC_RGB15
:
p_vout
->
outpu
t
.
i_rmask
=
0x001f
;
fm
t
.
i_rmask
=
0x001f
;
p_vout
->
outpu
t
.
i_gmask
=
0x03e0
;
fm
t
.
i_gmask
=
0x03e0
;
p_vout
->
outpu
t
.
i_bmask
=
0x7c00
;
fm
t
.
i_bmask
=
0x7c00
;
break
;
break
;
case
VLC_CODEC_RGB16
:
case
VLC_CODEC_RGB16
:
fmt
.
i_rmask
=
0x001f
;
p_vout
->
output
.
i_rmask
=
0x001f
;
fmt
.
i_gmask
=
0x07e0
;
p_vout
->
output
.
i_gmask
=
0x07e0
;
fmt
.
i_bmask
=
0xf800
;
p_vout
->
output
.
i_bmask
=
0xf800
;
break
;
break
;
case
VLC_CODEC_RGB24
:
case
VLC_CODEC_RGB24
:
fmt
.
i_rmask
=
0xff0000
;
p_vout
->
output
.
i_rmask
=
0xff0000
;
fmt
.
i_gmask
=
0x00ff00
;
p_vout
->
output
.
i_gmask
=
0x00ff00
;
fmt
.
i_bmask
=
0x0000ff
;
p_vout
->
output
.
i_bmask
=
0x0000ff
;
break
;
break
;
case
VLC_CODEC_RGB32
:
case
VLC_CODEC_RGB32
:
fmt
.
i_rmask
=
0xff0000
;
p_vout
->
output
.
i_rmask
=
0xff0000
;
fmt
.
i_gmask
=
0x00ff00
;
p_vout
->
output
.
i_gmask
=
0x00ff00
;
fmt
.
i_bmask
=
0x0000ff
;
p_vout
->
output
.
i_bmask
=
0x0000ff
;
break
;
default:
fmt
.
i_rmask
=
0
;
fmt
.
i_gmask
=
0
;
fmt
.
i_bmask
=
0
;
break
;
break
;
}
}
/* Try to initialize 1 direct buffer */
/* */
p_pic
=
NULL
;
vout_display_sys_t
*
sys
;
vd
->
sys
=
sys
=
calloc
(
1
,
sizeof
(
*
sys
));
/* Find an empty picture slot */
if
(
!
sys
)
for
(
i_index
=
0
;
i_index
<
VOUT_MAX_PICTURES
;
i_index
++
)
return
VLC_EGENERIC
;
{
if
(
p_vout
->
p_picture
[
i_index
].
i_status
==
FREE_PICTURE
)
{
p_pic
=
p_vout
->
p_picture
+
i_index
;
break
;
}
}
/* Allocate the picture */
/* */
if
(
p_pic
==
NULL
)
const
int
pitch
=
var_CreateGetInteger
(
vd
,
"vmem-pitch"
);
{
picture_resource_t
rsc
;
return
VLC_SUCCESS
;
rsc
.
p_sys
=
malloc
(
sizeof
(
*
rsc
.
p_sys
));
*
rsc
.
p_sys
=
cfg
;
for
(
int
i
=
0
;
i
<
PICTURE_PLANE_MAX
;
i
++
)
{
/* vmem-lock is responsible for the allocation */
rsc
.
p
[
i
].
p_pixels
=
NULL
;
rsc
.
p
[
i
].
i_lines
=
fmt
.
i_height
;
rsc
.
p
[
i
].
i_pitch
=
pitch
;
}
}
picture_t
*
picture
=
picture_NewFromResource
(
&
fmt
,
&
rsc
);
if
(
picture_Setup
(
p_pic
,
p_vout
->
output
.
i_chroma
,
if
(
!
picture
)
{
p_vout
->
output
.
i_width
,
p_vout
->
output
.
i_height
,
free
(
rsc
.
p_sys
);
p_vout
->
output
.
i_aspect
)
)
free
(
sys
);
{
free
(
p_pic
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
p_pic
->
p
->
i_pitch
=
i_pitch
;
/* */
picture_pool_configuration_t
pool
;
p_pic
->
pf_lock
=
LockPicture
;
memset
(
&
pool
,
0
,
sizeof
(
pool
));
p_pic
->
pf_unlock
=
UnlockPicture
;
pool
.
picture_count
=
1
;
pool
.
picture
=
&
picture
;
p_pic
->
i_status
=
DESTROYED_PICTURE
;
pool
.
lock
=
Lock
;
p_pic
->
i_type
=
DIRECT_PICTURE
;
pool
.
unlock
=
Unlock
;
sys
->
pool
=
picture_pool_NewExtended
(
&
pool
);
PP_OUTPUTPICTURE
[
I_OUTPUTPICTURES
]
=
p_pic
;
if
(
!
sys
->
pool
)
{
picture_Release
(
picture
);
I_OUTPUTPICTURES
++
;
free
(
sys
);
return
VLC_SUCCESS
;
}
/* */
vout_display_info_t
info
=
vd
->
info
;
info
.
has_hide_mouse
=
true
;
/* */
vd
->
fmt
=
fmt
;
vd
->
info
=
info
;
vd
->
get
=
Get
;
vd
->
prepare
=
NULL
;
vd
->
display
=
Display
;
vd
->
control
=
Control
;
vd
->
manage
=
Manage
;
/* */
vout_display_SendEventFullscreen
(
vd
,
false
);
vout_display_SendEventDisplaySize
(
vd
,
fmt
.
i_width
,
fmt
.
i_height
);
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
/*****************************************************************************
static
void
Close
(
vlc_object_t
*
object
)
* End: terminate video thread output method
*****************************************************************************/
static
void
End
(
vout_thread_t
*
p_vout
)
{
{
(
void
)
p_vout
;
vout_display_t
*
vd
=
(
vout_display_t
*
)
object
;
vout_display_sys_t
*
sys
=
vd
->
sys
;
picture_pool_Delete
(
sys
->
pool
);
free
(
sys
);
}
}
/*****************************************************************************
/* */
* Destroy: destroy video thread
static
picture_t
*
Get
(
vout_display_t
*
vd
)
*****************************************************************************
* Terminate an output method created by Create
*****************************************************************************/
static
void
Destroy
(
vlc_object_t
*
p_this
)
{
{
vout_thread_t
*
p_vout
=
(
vout_thread_t
*
)
p_this
;
return
picture_pool_Get
(
vd
->
sys
->
pool
);
}
/* Destroy structure */
static
void
Display
(
vout_display_t
*
vd
,
picture_t
*
picture
)
free
(
p_vout
->
p_sys
);
{
VLC_UNUSED
(
vd
);
assert
(
!
picture_IsReferenced
(
picture
));
picture_Release
(
picture
);
}
static
int
Control
(
vout_display_t
*
vd
,
int
query
,
va_list
args
)
{
switch
(
query
)
{
case
VOUT_DISPLAY_CHANGE_FULLSCREEN
:
case
VOUT_DISPLAY_CHANGE_DISPLAY_SIZE
:
{
const
vout_display_cfg_t
*
cfg
=
va_arg
(
args
,
const
vout_display_cfg_t
*
);
if
(
cfg
->
display
.
width
!=
vd
->
fmt
.
i_width
||
cfg
->
display
.
height
!=
vd
->
fmt
.
i_height
)
return
VLC_EGENERIC
;
if
(
cfg
->
is_fullscreen
)
return
VLC_EGENERIC
;
return
VLC_SUCCESS
;
}
default:
return
VLC_EGENERIC
;
}
}
static
void
Manage
(
vout_display_t
*
vd
)
{
VLC_UNUSED
(
vd
);
}
}
/*****************************************************************************
/* */
* LockPicture: lock a picture
static
int
Lock
(
picture_t
*
picture
)
*****************************************************************************
* This function locks the picture and prepares it for direct pixel access.
*****************************************************************************/
static
int
LockPicture
(
vout_thread_t
*
p_vout
,
picture_t
*
p_pic
)
{
{
int
i_index
;
picture_sys_t
*
sys
=
picture
->
p_sys
;
void
*
planes
[
p_pic
->
i_planes
];
p_vout
->
p_sys
->
pf_lock
(
p_vout
->
p_sys
->
p_data
,
planes
);
void
*
planes
[
PICTURE_PLANE_MAX
];
sys
->
lock
(
sys
->
sys
,
planes
);
for
(
i_index
=
0
;
i_index
<
p_pic
->
i_planes
;
i_index
++
)
for
(
int
i
=
0
;
i
<
picture
->
i_planes
;
i
++
)
{
picture
->
p
[
i
].
p_pixels
=
planes
[
i
];
p_pic
->
p
[
i_index
].
p_pixels
=
planes
[
i_index
];
}
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
static
void
Unlock
(
picture_t
*
picture
)
/*****************************************************************************
* UnlockPicture: unlock a picture
*****************************************************************************
* This function unlocks a previously locked picture.
*****************************************************************************/
static
int
UnlockPicture
(
vout_thread_t
*
p_vout
,
picture_t
*
p_pic
)
{
{
p
_vout
->
p_sys
->
pf_unlock
(
p_vout
->
p_sys
->
p_data
)
;
p
icture_sys_t
*
sys
=
picture
->
p_sys
;
(
void
)
p_pic
;
sys
->
unlock
(
sys
->
sys
);
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