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
293e5623
Commit
293e5623
authored
Aug 03, 2009
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Converted vout aa to "vout display" API.
parent
d070cdeb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
230 additions
and
168 deletions
+230
-168
modules/video_output/aa.c
modules/video_output/aa.c
+230
-168
No files found.
modules/video_output/aa.c
View file @
293e5623
/*****************************************************************************
/*****************************************************************************
*
vout_aa.c: Aa video output display method for testing purposes
*
aa.c: "vout display" module using aalib
*****************************************************************************
*****************************************************************************
* Copyright (C) 2002-2009 the VideoLAN team
* Copyright (C) 2002-2009 the VideoLAN team
* $Id$
* $Id$
...
@@ -28,227 +28,289 @@
...
@@ -28,227 +28,289 @@
# include "config.h"
# include "config.h"
#endif
#endif
#include <aalib.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
Manage
(
vout_thread_t
*
);
static
void
Render
(
vout_thread_t
*
,
picture_t
*
);
static
void
Display
(
vout_thread_t
*
,
picture_t
*
);
static
void
SetPalette
(
vout_thread_t
*
,
uint16_t
*
,
uint16_t
*
,
uint16_t
*
);
#include <assert.h>
#include <aalib.h>
/* TODO
* - what about RGB palette ?
*/
/*****************************************************************************
/*****************************************************************************
* Module descriptor
* Module descriptor
*****************************************************************************/
*****************************************************************************/
vlc_module_begin
()
static
int
Open
(
vlc_object_t
*
);
set_shortname
(
N_
(
"ASCII Art"
))
static
void
Close
(
vlc_object_t
*
);
set_category
(
CAT_VIDEO
)
set_subcategory
(
SUBCAT_VIDEO_VOUT
)
vlc_module_begin
()
set_description
(
N_
(
"ASCII-art video output"
)
)
set_shortname
(
N_
(
"ASCII Art"
))
set_capability
(
"video output"
,
10
)
set_category
(
CAT_VIDEO
)
add_shortcut
(
"aalib"
)
set_subcategory
(
SUBCAT_VIDEO_VOUT
)
set_callbacks
(
Create
,
Destroy
)
set_description
(
N_
(
"ASCII-art video output"
))
vlc_module_end
()
set_capability
(
"vout display"
,
10
)
add_shortcut
(
"aalib"
)
set_callbacks
(
Open
,
Close
)
vlc_module_end
()
/*****************************************************************************
/*****************************************************************************
* vout_sys_t: aa video output method descriptor
* Local prototypes
*****************************************************************************
* This structure is part of the video output thread descriptor.
* It describes the aa specific properties of an output thread.
*****************************************************************************/
*****************************************************************************/
struct
vout_sys_t
static
picture_t
*
Get
(
vout_display_t
*
);
{
static
void
Prepare
(
vout_display_t
*
,
picture_t
*
);
static
void
Display
(
vout_display_t
*
,
picture_t
*
);
static
int
Control
(
vout_display_t
*
,
int
,
va_list
);
/* */
static
void
Manage
(
vout_display_t
*
);
/* */
struct
vout_display_sys_t
{
struct
aa_context
*
aa_context
;
struct
aa_context
*
aa_context
;
aa_palette
palette
;
aa_palette
palette
;
int
i_width
;
/* width of main window */
int
i_height
;
/* height of main window */
vout_display_cfg_t
state
;
picture_pool_t
*
pool
;
};
};
/*****************************************************************************
/**
* Create: allocates aa video thread output method
*****************************************************************************
* This function allocates and initializes a aa vout method.
* This function allocates and initializes a aa vout method.
*
****************************************************************************
/
*/
static
int
Create
(
vlc_object_t
*
p_this
)
static
int
Open
(
vlc_object_t
*
object
)
{
{
vout_thread_t
*
p_vout
=
(
vout_thread_t
*
)
p_this
;
vout_display_t
*
vd
=
(
vout_display_t
*
)
object
;
vout_display_sys_t
*
sys
;
/* Allocate structure */
/* Allocate structure */
p_vout
->
p_sys
=
malloc
(
sizeof
(
vout_sys_t
)
);
vd
->
sys
=
sys
=
calloc
(
1
,
sizeof
(
*
sys
)
);
if
(
p_vout
->
p_sys
==
NULL
)
if
(
!
sys
)
return
VLC_ENOMEM
;
return
VLC_ENOMEM
;
/* Don't parse any options, but take $AAOPTS into account */
/* Don't parse any options, but take $AAOPTS into account */
aa_parseoptions
(
NULL
,
NULL
,
NULL
,
NULL
);
aa_parseoptions
(
NULL
,
NULL
,
NULL
,
NULL
);
if
(
!
(
p_vout
->
p_sys
->
aa_context
=
aa_autoinit
(
&
aa_defparams
)))
/* */
{
sys
->
aa_context
=
aa_autoinit
(
&
aa_defparams
);
msg_Err
(
p_vout
,
"cannot initialize aalib"
);
if
(
!
sys
->
aa_context
)
{
free
(
p_vout
->
p_sys
);
msg_Err
(
vd
,
"cannot initialize aalib"
);
return
VLC_EGENERIC
;
goto
error
;
}
}
p_vout
->
pf_init
=
Init
;
aa_autoinitkbd
(
sys
->
aa_context
,
0
);
p_vout
->
pf_end
=
End
;
aa_autoinitmouse
(
sys
->
aa_context
,
AA_MOUSEALLMASK
);
p_vout
->
pf_manage
=
Manage
;
p_vout
->
pf_render
=
Render
;
p_vout
->
pf_display
=
Display
;
p_vout
->
p_sys
->
i_width
=
aa_imgwidth
(
p_vout
->
p_sys
->
aa_context
);
/* */
p_vout
->
p_sys
->
i_height
=
aa_imgheight
(
p_vout
->
p_sys
->
aa_context
)
;
video_format_t
fmt
=
vd
->
fmt
;
aa_autoinitkbd
(
p_vout
->
p_sys
->
aa_context
,
0
)
;
fmt
.
i_chroma
=
VLC_CODEC_RGB8
;
aa_autoinitmouse
(
p_vout
->
p_sys
->
aa_context
,
AA_MOUSEPRESSMASK
);
fmt
.
i_width
=
aa_imgwidth
(
sys
->
aa_context
);
aa_hidemouse
(
p_vout
->
p_sys
->
aa_context
);
fmt
.
i_height
=
aa_imgheight
(
sys
->
aa_context
);
return
VLC_SUCCESS
;
/* */
}
vout_display_info_t
info
=
vd
->
info
;
info
.
has_pictures_invalid
=
true
;
/*****************************************************************************
/* Setup vout_display now that everything is fine */
* Init: initialize aa video thread output method
vd
->
fmt
=
fmt
;
*****************************************************************************/
vd
->
info
=
info
;
static
int
Init
(
vout_thread_t
*
p_vout
)
{
int
i_index
;
picture_t
*
p_pic
=
NULL
;
I_OUTPUTPICTURES
=
0
;
p_vout
->
output
.
i_chroma
=
VLC_CODEC_RGB8
;
p_vout
->
output
.
i_width
=
p_vout
->
p_sys
->
i_width
;
p_vout
->
output
.
i_height
=
p_vout
->
p_sys
->
i_height
;
p_vout
->
output
.
i_aspect
=
p_vout
->
p_sys
->
i_width
*
VOUT_ASPECT_FACTOR
/
p_vout
->
p_sys
->
i_height
;
p_vout
->
output
.
pf_setpalette
=
SetPalette
;
/* Find an empty picture slot */
for
(
i_index
=
0
;
i_index
<
VOUT_MAX_PICTURES
;
i_index
++
)
{
if
(
p_vout
->
p_picture
[
i_index
].
i_status
==
FREE_PICTURE
)
{
p_pic
=
p_vout
->
p_picture
+
i_index
;
break
;
}
}
if
(
p_pic
==
NULL
)
return
VLC_EGENERIC
;
/* Allocate the picture */
vd
->
get
=
Get
;
p_pic
->
p
->
p_pixels
=
aa_image
(
p_vout
->
p_sys
->
aa_context
);
vd
->
prepare
=
Prepare
;
p_pic
->
p
->
i_lines
=
p_vout
->
p_sys
->
i_height
;
vd
->
display
=
Display
;
p_pic
->
p
->
i_visible_lines
=
p_vout
->
p_sys
->
i_height
;
vd
->
control
=
Control
;
p_pic
->
p
->
i_pitch
=
p_vout
->
p_sys
->
i_width
;
vd
->
manage
=
Manage
;
p_pic
->
p
->
i_pixel_pitch
=
1
;
p_pic
->
p
->
i_visible_pitch
=
p_vout
->
p_sys
->
i_width
;
p_pic
->
i_planes
=
1
;
p_pic
->
i_status
=
DESTROYED_PICTURE
;
/* Inspect initial configuration and send correction events
p_pic
->
i_type
=
DIRECT_PICTURE
;
* FIXME how to handle aspect ratio with aa ? */
sys
->
state
=
*
vd
->
cfg
;
PP_OUTPUTPICTURE
[
I_OUTPUTPICTURES
]
=
p_pic
;
sys
->
state
.
is_fullscreen
=
false
;
I_OUTPUTPICTURES
++
;
vout_display_SendEventFullscreen
(
vd
,
false
);
vout_display_SendEventDisplaySize
(
vd
,
fmt
.
i_width
,
fmt
.
i_height
);
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
error:
if
(
sys
&&
sys
->
aa_context
)
aa_close
(
sys
->
aa_context
);
free
(
sys
);
return
VLC_EGENERIC
;
}
}
/**
***************************************************************************
/**
*
End: terminate aa video thread
output method
*
Close a aa video
output method
*
****************************************************************************
/
*/
static
void
End
(
vout_thread_t
*
p_vout
)
static
void
Close
(
vlc_object_t
*
object
)
{
{
;
vout_display_t
*
vd
=
(
vout_display_t
*
)
object
;
vout_display_sys_t
*
sys
=
vd
->
sys
;
if
(
sys
->
pool
)
picture_pool_Delete
(
sys
->
pool
);
aa_close
(
sys
->
aa_context
);
free
(
sys
);
}
}
/*****************************************************************************
/**
* Destroy: destroy aa video thread output method
* Return a direct buffer
*****************************************************************************
*/
* Terminate an output method created by AaCreateOutputMethod
static
picture_t
*
Get
(
vout_display_t
*
vd
)
*****************************************************************************/
static
void
Destroy
(
vlc_object_t
*
p_this
)
{
{
vout_thread_t
*
p_vout
=
(
vout_thread_t
*
)
p_this
;
vout_display_sys_t
*
sys
=
vd
->
sys
;
if
(
!
sys
->
pool
)
{
picture_resource_t
rsc
;
memset
(
&
rsc
,
0
,
sizeof
(
rsc
));
rsc
.
p
[
0
].
p_pixels
=
aa_image
(
sys
->
aa_context
);
rsc
.
p
[
0
].
i_pitch
=
aa_imgwidth
(
sys
->
aa_context
);
rsc
.
p
[
0
].
i_lines
=
aa_imgheight
(
sys
->
aa_context
);
picture_t
*
p_picture
=
picture_NewFromResource
(
&
vd
->
fmt
,
&
rsc
);
if
(
!
p_picture
)
return
NULL
;
aa_close
(
p_vout
->
p_sys
->
aa_context
);
sys
->
pool
=
picture_pool_New
(
1
,
&
p_picture
);
free
(
p_vout
->
p_sys
);
if
(
!
sys
->
pool
)
return
NULL
;
}
return
picture_pool_Get
(
sys
->
pool
);
}
}
/*****************************************************************************
/**
* Manage: handle aa events
* Prepare a picture for display */
*****************************************************************************
static
void
Prepare
(
vout_display_t
*
vd
,
picture_t
*
picture
)
* This function should be called regularly by video output thread. It manages
* console events. It returns a non null value on error.
*****************************************************************************/
static
int
Manage
(
vout_thread_t
*
p_vout
)
{
{
int
event
,
x
,
y
,
b
;
vout_display_sys_t
*
sys
=
vd
->
sys
;
event
=
aa_getevent
(
p_vout
->
p_sys
->
aa_context
,
0
);
switch
(
event
)
assert
(
vd
->
fmt
.
i_width
==
aa_imgwidth
(
sys
->
aa_context
)
&&
{
vd
->
fmt
.
i_height
==
aa_imgheight
(
sys
->
aa_context
));
case
AA_MOUSE
:
aa_getmouse
(
p_vout
->
p_sys
->
aa_context
,
&
x
,
&
y
,
&
b
);
#if 0
if
(
b
&
AA_BUTTON3
)
if (picture->format.p_palette) {
var_SetBool
(
p_vout
->
p_libvlc
,
"intf-popupmenu"
,
true
);
for (int i = 0; i < 256; i++) {
break
;
aa_setpalette(vd->sys->palette, 256 - i,
case
AA_RESIZE
:
red[ i ], green[ i ], blue[ i ]);
p_vout
->
i_changes
|=
VOUT_SIZE_CHANGE
;
}
aa_resize
(
p_vout
->
p_sys
->
aa_context
);
p_vout
->
p_sys
->
i_width
=
aa_imgwidth
(
p_vout
->
p_sys
->
aa_context
);
p_vout
->
p_sys
->
i_height
=
aa_imgheight
(
p_vout
->
p_sys
->
aa_context
);
break
;
default:
break
;
}
}
return
VLC_SUCCESS
;
#endif
aa_fastrender
(
sys
->
aa_context
,
0
,
0
,
vd
->
fmt
.
i_width
,
vd
->
fmt
.
i_height
);
}
}
/**
***************************************************************************
/**
*
Render: render previously calculated output
*
Display a picture
*
****************************************************************************
/
*/
static
void
Render
(
vout_thread_t
*
p_vout
,
picture_t
*
p_pic
)
static
void
Display
(
vout_display_t
*
vd
,
picture_t
*
picture
)
{
{
aa_fastrender
(
p_vout
->
p_sys
->
aa_context
,
0
,
0
,
vout_display_sys_t
*
sys
=
vd
->
sys
;
aa_imgwidth
(
p_vout
->
p_sys
->
aa_context
),
aa_imgheight
(
p_vout
->
p_sys
->
aa_context
)
);
aa_flush
(
sys
->
aa_context
);
picture_Release
(
picture
);
}
}
/**
***************************************************************************
/**
*
Display: displays previously rendered output
*
Control for vout display
*
****************************************************************************
/
*/
static
void
Display
(
vout_thread_t
*
p_vout
,
picture_t
*
p_pic
)
static
int
Control
(
vout_display_t
*
vd
,
int
query
,
va_list
args
)
{
{
/* No need to do anything, the fake direct buffers stay as they are */
vout_display_sys_t
*
sys
=
vd
->
sys
;
unsigned
int
i_width
,
i_height
,
i_x
,
i_y
;
switch
(
query
)
{
case
VOUT_DISPLAY_CHANGE_DISPLAY_SIZE
:
/* We have to ignore what is requested */
vout_display_SendEventPicturesInvalid
(
vd
);
return
VLC_SUCCESS
;
case
VOUT_DISPLAY_RESET_PICTURES
:
if
(
sys
->
pool
)
picture_pool_Delete
(
sys
->
pool
);
sys
->
pool
=
NULL
;
vout_PlacePicture
(
p_vout
,
p_vout
->
p_sys
->
i_width
,
p_vout
->
p_sys
->
i_height
,
vd
->
fmt
.
i_width
=
aa_imgwidth
(
sys
->
aa_context
);
&
i_x
,
&
i_y
,
&
i_width
,
&
i_height
);
vd
->
fmt
.
i_height
=
aa_imgheight
(
sys
->
aa_context
);
return
VLC_SUCCESS
;
aa_flush
(
p_vout
->
p_sys
->
aa_context
);
case
VOUT_DISPLAY_HIDE_MOUSE
:
aa_hidemouse
(
sys
->
aa_context
);
return
VLC_SUCCESS
;
default:
msg_Err
(
vd
,
"Unsupported query in vout display aalib"
);
return
VLC_EGENERIC
;
}
}
}
/*****************************************************************************
* SetPalette: set the 8bpp palette
/**
*
****************************************************************************/
*
Proccess pending event
static
void
SetPalette
(
vout_thread_t
*
p_vout
,
*/
uint16_t
*
red
,
uint16_t
*
green
,
uint16_t
*
blue
)
static
void
Manage
(
vout_display_t
*
vd
)
{
{
int
i
;
vout_display_sys_t
*
sys
=
vd
->
sys
;
for
(;;)
{
const
int
event
=
aa_getevent
(
sys
->
aa_context
,
0
);
if
(
!
event
)
return
;
switch
(
event
)
{
case
AA_MOUSE
:
{
int
x
,
y
;
int
button
;
int
vlc
;
aa_getmouse
(
sys
->
aa_context
,
&
x
,
&
y
,
&
button
);
vlc
=
0
;
if
(
button
&
AA_BUTTON1
)
vlc
|=
1
<<
MOUSE_BUTTON_LEFT
;
if
(
button
&
AA_BUTTON2
)
vlc
|=
1
<<
MOUSE_BUTTON_CENTER
;
if
(
button
&
AA_BUTTON3
)
vlc
|=
1
<<
MOUSE_BUTTON_RIGHT
;
vout_display_SendEventMouseState
(
vd
,
x
,
y
,
vlc
);
aa_showcursor
(
sys
->
aa_context
);
/* Not perfect, we show it on click too */
break
;
}
/* Fill colors with color information */
case
AA_RESIZE
:
for
(
i
=
0
;
i
<
256
;
i
++
)
aa_resize
(
sys
->
aa_context
);
{
vout_display_SendEventDisplaySize
(
vd
,
aa_setpalette
(
p_vout
->
p_sys
->
palette
,
256
-
i
,
aa_imgwidth
(
sys
->
aa_context
),
red
[
i
],
green
[
i
],
blue
[
i
]
);
aa_imgheight
(
sys
->
aa_context
));
break
;
/* TODO keys support to complete */
case
AA_UP
:
vout_display_SendEventKey
(
vd
,
KEY_UP
);
break
;
case
AA_DOWN
:
vout_display_SendEventKey
(
vd
,
KEY_DOWN
);
break
;
case
AA_RIGHT
:
vout_display_SendEventKey
(
vd
,
KEY_RIGHT
);
break
;
case
AA_LEFT
:
vout_display_SendEventKey
(
vd
,
KEY_LEFT
);
break
;
case
AA_BACKSPACE
:
vout_display_SendEventKey
(
vd
,
KEY_BACKSPACE
);
break
;
case
AA_ESC
:
vout_display_SendEventKey
(
vd
,
KEY_ESC
);
break
;
case
0x20
:
vout_display_SendEventKey
(
vd
,
KEY_SPACE
);
break
;
default:
if
(
event
>=
0x20
&&
event
<=
0x7f
)
vout_display_SendEventKey
(
vd
,
event
);
break
;
}
}
}
}
}
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