Commit 26e60046 authored by Jean-Paul Saman's avatar Jean-Paul Saman

Forward port of branches/0.8.1-jpsaman-thedj revision 12070. The OSD menu...

Forward port of branches/0.8.1-jpsaman-thedj revision 12070. The OSD menu subsystem consists of two parts a core part (src/osd, include/vlc_osd.h) and a subfilter (modules/video_filter/osdmenu.c). The OSD menu can be used locally or it can be streamed. It depends on the way the functionality is called from the vlc commandline. Currently there is only one way to make the subpictures appear on the video and that is through the rc-interface. The following commands are supported by it: "menu on" (show OSD menu), "menu off" (hide OSD menu), "menu left" (highlight button on the left), "menu right" (highlight button on the right), "menu up" (highlight button above), "menu down" (highlight button below) or "menu select" (perform hotkey action). When there is no button on the left, right, up or down then the menu-command will be ignored.

To stream use a commandline similar to this:

./vlc dvdsimple:///dev/dvd --sub-filter=osdmenu --osdmenu-file=share/osdmenu/default.cfg --extraintf rc --sout '#transcode{sfilter=osdmenu}:std{mux=ts,access=udp,url=127.0.0.1:1234}' -vvvv

For local playback a commandline like this is needed:

./vlc dvdsimple:///dev/dvd --sub-filter=osdmenu --osdmenu-file=share/osdmenu/default.cfg -vvvv

Have fun with the basic functionality - jpsaman.
parent d8fc9f3b
......@@ -112,6 +112,7 @@ HEADERS_include = \
include/vlc_messages.h \
include/vlc_meta.h \
include/vlc_objects.h \
include/vlc_osd.h \
include/vlc_playlist.h \
include/vlc_spu.h \
include/vlc_stream.h \
......@@ -382,6 +383,9 @@ SOURCES_libvlc_common = \
src/stream_output/announce.c \
src/stream_output/sap.c \
src/stream_output/acl.c \
src/osd/osd.c \
src/osd/osd_widgets.c \
src/osd/osd_parser.c \
src/misc/charset.c \
src/misc/httpd.c \
src/misc/tls.c \
......@@ -813,6 +817,49 @@ package-win32-base:
cp $$i $(top_builddir)/vlc-${VERSION}/skins/ || true ; \
done
mkdir -p "$(srcdir)/vlc-${VERSION}/osdmenu"
mkdir -p "$(srcdir)/vlc-${VERSION}/osdmenu/dvd"
mkdir -p "$(srcdir)/vlc-${VERSION}/osdmenu/dvd/selected"
mkdir -p "$(srcdir)/vlc-${VERSION}/osdmenu/dvd/unselect"
mkdir -p "$(srcdir)/vlc-${VERSION}/osdmenu/dvd/selection"
mkdir -p "$(srcdir)/vlc-${VERSION}/osdmenu/dvd/volume"
for i in $(srcdir)/share/osdmenu/*.*; do \
cp $$i $(srcdir)/vlc-${VERSION}/osdmenu/ || true ; \
unix2dos $(srcdir)/vlc-${VERSION}/osdmenu/`basename $$i` ; \
done
for i in $(srcdir)/share/osdmenu/dvd/*.*; do \
cp $$i $(srcdir)/vlc-${VERSION}/osdmenu/dvd || true ; \
done
for i in $(srcdir)/share/osdmenu/dvd/unselect/*.*; do \
cp $$i $(srcdir)/vlc-${VERSION}/osdmenu/dvd/unselect || true ; \
done
for i in $(srcdir)/share/osdmenu/dvd/selected/*.*; do \
cp $$i $(srcdir)/vlc-${VERSION}/osdmenu/dvd/selected/ || true ; \
done
for i in $(srcdir)/share/osdmenu/dvd/selection/*.*; do \
cp $$i $(srcdir)/vlc-${VERSION}/osdmenu/dvd/selection/ || true ; \
done
for i in $(srcdir)/share/osdmenu/dvd/volume/*.*; do \
cp $$i $(srcdir)/vlc-${VERSION}/osdmenu/dvd/volume/ || true ; \
done
mkdir -p "$(srcdir)/vlc-${VERSION}/osdmenu/default"
mkdir -p "$(srcdir)/vlc-${VERSION}/osdmenu/default/selected"
mkdir -p "$(srcdir)/vlc-${VERSION}/osdmenu/default/selection"
mkdir -p "$(srcdir)/vlc-${VERSION}/osdmenu/default/volume"
for i in $(srcdir)/share/osdmenu/default/*.*; do \
cp $$i $(srcdir)/vlc-${VERSION}/osdmenu/default || true ; \
done
for i in $(srcdir)/share/osdmenu/default/selected/*.*; do \
cp $$i $(srcdir)/vlc-${VERSION}/osdmenu/default/selected/ || true ; \
done
for i in $(srcdir)/share/osdmenu/default/selection/*.*; do \
cp $$i $(srcdir)/vlc-${VERSION}/osdmenu/default/selection/ || true ; \
done
for i in $(srcdir)/share/osdmenu/default/volume/*.*; do \
cp $$i $(srcdir)/vlc-${VERSION}/osdmenu/default/volume/ || true ; \
done
mkdir -p "$(top_builddir)/vlc-${VERSION}/http/admin"
mkdir -p "$(top_builddir)/vlc-${VERSION}/http/vlm"
cp $(srcdir)/share/http/*.html $(top_builddir)/vlc-${VERSION}/http/ ;
......
......@@ -2689,6 +2689,7 @@ AC_CHECK_HEADERS(png.h, [
AC_CHECK_LIB(png, png_set_rows, [
VLC_ADD_LDFLAGS([png],[-lpng -lz])
VLC_ADD_PLUGINS([png])
VLC_ADD_PLUGINS([osdmenu])
AC_DEFINE(HAVE_LIBPNG, [], [Define if you have the PNG library: libpng])],
[],[-lz])
LDFLAGS="${LDFLAGS_save}"
......
/*****************************************************************************
* stream_output.h : stream output module
*****************************************************************************
* Copyright (C) 2002 the VideoLAN team
* Copyright (C) 2002-2005 the VideoLAN team
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
* Jean-Paul Saman <jpsaman #_at_# m2x.nl>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -206,6 +207,9 @@ struct sout_stream_t
sout_cfg_t *p_cfg;
char *psz_next;
/* Subpicture unit */
spu_t *p_spu;
/* add, remove a stream */
sout_stream_id_t *(*pf_add)( sout_stream_t *, es_format_t * );
int (*pf_del)( sout_stream_t *, sout_stream_id_t * );
......
......@@ -405,6 +405,13 @@ typedef struct vod_media_t vod_media_t;
typedef struct opengl_t opengl_t;
typedef struct opengl_sys_t opengl_sys_t;
/* osdmenu */
typedef struct osd_menu_t osd_menu_t;
typedef struct osd_state_t osd_state_t;
typedef struct osd_event_t osd_event_t;
typedef struct osd_button_t osd_button_t;
typedef struct osd_menu_state_t osd_menu_state_t;
/* VLM */
typedef struct vlm_t vlm_t;
typedef struct vlm_message_t vlm_message_t;
......
......@@ -59,6 +59,7 @@
#define VLC_OBJECT_TLS (-25)
#define VLC_OBJECT_SD (-26)
#define VLC_OBJECT_XML (-27)
#define VLC_OBJECT_OSDMENU (-28)
#define VLC_OBJECT_GENERIC (-666)
......
/*****************************************************************************
* osd.h - OSD menu definitions and function prototypes
*****************************************************************************
* Copyright (C) 2004-2005 M2X
* $Id: osd.h 9451 2004-12-01 01:07:08Z jpsaman $
*
* Authors: Jean-Paul Saman <jpsaman #_at_# m2x dot nl>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/**
* \file
* The OSD menu core creates the OSD menu structure in memory. It parses a
* configuration file that defines all elements that are part of the menu. The
* core also handles all actions and menu structure updates on behalf of video
* subpicture filters.
*
* The file modules/video_filters/osdmenu.c implements a subpicture filter that
* specifies the final information on positioning of the current state image.
* A subpicture filter is called each time a video picture has to be rendered, it
* also gives a start and end date to the subpicture. The subpicture can be streamed
* if used inside a transcoding command. For example:
*
* vlc dvdsimple:///dev/dvd --extraintf rc
* --sout='#transcode{osdenc=dvbsub,osdcoded=YUVP,sfilter=osdmenu}
* --osdmenu-file share/osdmenu/dvd.cfg
*
* Each OSD menu element, called "action", defines a hotkey action. Each action
* can have several states (unselect, select, pressed). Each state has an image
* that represents the state visually. The commands "menu right", "menu left",
* "menu up" and "menu down" are used to navigate through the OSD menu structure.
* The commands "menu on" or "menu show" and "menu off" or "menu hide" respectively
* show and hide the OSD menu subpictures.
*
* There is one special element called "range". A range is an arbritary range
* of state images that can be browsed using "menu up" and "menu down" commands
* on the rc interface.
*
* The OSD menu configuration file uses a very simple syntax and basic parser.
* A configuration file has the ".cfg". An example is "share/osdmenu/dvd256.cfg".
*/
#ifndef _VLC_OSD_H
#define _VLC_OSD_H 1
#include "vlc_video.h"
# ifdef __cplusplus
extern "C" {
# endif
/**
* The OSD Menu configuration file format.
*
* The configuration file syntax is very basic and so is its parser. See the
* BNF formal representation below:
*
* The keywords FILENAME and PATHNAME represent the filename and pathname specification
* that is valid for the Operating System VLC is compiled for.
*
* The hotkey actions that are supported by VLC are documented in the file src/libvlc. The
* file include/vlc_keys.h defines some hotkey internals.
*
* CONFIG_FILE = FILENAME '.cfg'
* WS = [ ' ' | '\t' ]+
* OSDMEN_PATH = PATHNAME
* DIR = 'dir' WS OSDMENU_PATH '\n'
* STATE = [ 'unselect' | 'select' | 'pressed' ]
* HOTKEY_ACTION = 'key-' [ 'a' .. 'z', 'A' .. 'Z', '-' ]+
*
* ACTION_TYPE = 'type' 'volume' '\n'
* ACTION_BLOCK_START = 'action' WS HOTKEY_ACTION WS '('POS','POS')' '\n'
* ACTION_BLOCK_END = 'end' '\n'
* ACTION_STATE = STATE WS FILENAME '\n'
* ACTION_RANGE_START = 'range' WS HOTKEY_ACTION WS DEFAULT_INDEX '\n'
* ACTION_RANGE_END = 'end' '\n'
* ACTION_RANGE_STATE = FILENAME '\n'
*
* ACTION_BLOCK_RANGE = ACTION_RANGE_START [WS ACTION_RANGE_STATE]+ WS ACTION_RANGE_END
* ACTION_BLOCK = ACTION_BLOCK_START [WS ACTION_TYPE*] [ [WS ACTION_STATE]+3 | [WS ACTION_BLOCK_RANGE]+1 ] ACTION_BLOCK_END
* CONFIG_FILE_CONTENTS = DIR [ACTION_BLOCK]+
*
*/
/**
* OSD menu button states
*
* Every button has three states, either it is unselected, selected or pressed.
* An OSD menu skin can associate images with each state.
*
* OSD_BUTTON_UNSELECT 0
* OSD_BUTTON_SELECT 1
* OSD_BUTTON_PRESSED 2
*/
#define OSD_BUTTON_UNSELECT 0
#define OSD_BUTTON_SELECT 1
#define OSD_BUTTON_PRESSED 2
/**
* OSD State object
*
* The OSD state object holds the state and associated images for a particular state
* on the screen. The picture is displayed when this state is the active state.
*/
struct osd_state_t
{
osd_state_t *p_next; /*< pointer to next state */
osd_state_t *p_prev; /*< pointer to previous state */
picture_t *p_pic; /*< picture of state */
char *psz_state; /*< state name */
int i_state; /*< state index */
};
/**
* OSD Button object
*
* An OSD Button has different states. Each state has an image for display.
*/
struct osd_button_t
{
osd_button_t *p_next; /*< pointer to next button */
osd_button_t *p_prev; /*< pointer to previous button */
osd_button_t *p_up; /*< pointer to up button */
osd_button_t *p_down; /*< pointer to down button */
osd_state_t *p_current_state; /*< pointer to current state image */
osd_state_t *p_states; /*< doubly linked list of states */
picture_t *p_feedback; /*< feedback picture */
char *psz_name; /*< name of button */
/* These member should probably be a struct hotkey */
char *psz_action; /*< hotkey action name on button*/
char *psz_action_down; /*< hotkey action name on range buttons for command "menu down" */
/* end of hotkey specifics */
int i_x; /*< x-position of button visible state image */
int i_y; /*< y-position of button visible state image */
/* range style button */
vlc_bool_t b_range; /*< button should be interpreted as range */
int i_ranges; /*< number of states */
};
/**
* OSD Menu State object
*
* Represents the current state as displayed.
*/
/* Represent the menu state */
struct osd_menu_state_t
{
int i_x; /*< x position of spu region */
int i_y; /*< y position of spu region */
int i_width; /*< width of spu region */
int i_height; /*< height of spu region */
picture_t *p_pic; /*< pointer to picture to display */
osd_button_t *p_visible; /*< shortcut to visible button */
vlc_bool_t b_menu_visible; /*< menu currently visible? */
vlc_bool_t b_update; /*< update OSD Menu when VLC_TRUE */
/* quick hack to volume state. */
osd_button_t *p_volume; /*< pointer to volume range object. */
};
/**
* OSD Menu object
*
* The main OSD Menu object, which holds a linked list to all buttons
* and images that defines the menu. The p_state variable represents the
* current state of the OSD Menu.
*/
struct osd_menu_t
{
VLC_COMMON_MEMBERS
int i_x; /*< x-position of OSD Menu on the video screen */
int i_y; /*< y-position of OSD Menu on the video screen */
int i_width; /*< width of OSD Menu on the video screen */
int i_height; /*< height of OSD Menu on the video screen */
char *psz_path; /*< directory where OSD menu images are stored */
osd_button_t *p_button; /*< doubly linked list of buttons */
osd_menu_state_t *p_state; /*< current state of OSD menu */
/* quick link in the linked list. */
osd_button_t *p_last_button; /*< pointer to last button in the list */
};
/**
* Initialize an osd_menu_t object
*
* This functions has to be called before any call to other osd_menu_t* functions.
* It creates the osd_menu object and holds a pointer to it during its lifetime.
*/
VLC_EXPORT( osd_menu_t *, __osd_MenuCreate, ( vlc_object_t *, const char * ) );
/**
* Delete the osd_menu_t object
*
* This functions has to be called to release the associated module and memory
* for the osdmenu. After return of this function the pointer to osd_menu_t* is invalid.
*/
VLC_EXPORT( void, __osd_MenuDelete, ( vlc_object_t *, osd_menu_t * ) );
/**
* Change state on an osd_button_t.
*
* This function selects the specified state and returns a pointer to it. The
* following states are currently supported:
* \see OSD_BUTTON_UNSELECT
* \see OSD_BUTTON_SELECT
* \see OSD_BUTTON_PRESSED
*/
VLC_EXPORT( osd_state_t *, __osd_StateChange, ( osd_state_t *, const int ) );
#define osd_MenuCreate(object,file) __osd_MenuCreate( VLC_OBJECT(object), file )
#define osd_MenuDelete(object,osd) __osd_MenuDelete( VLC_OBJECT(object), osd )
#define osd_StateChange(object,value) __osd_StateChange( object, value )
/**
* Show the OSD menu.
*
* Show the OSD menu on the video output or mux it into the stream.
* Every change to the OSD menu will now be visible in the output. An output
* can be a video output window or a stream (\see stream output)
*/
VLC_EXPORT( void, __osd_MenuShow, ( vlc_object_t * ) );
/**
* Hide the OSD menu.
*
* Stop showing the OSD menu on the video output or mux it into the stream.
*/
VLC_EXPORT( void, __osd_MenuHide, ( vlc_object_t * ) );
/**
* Activate the action of this OSD menu item.
*
* The rc interface command "menu select" triggers the sending of an hotkey action
* to the hotkey interface. The hotkey that belongs to the current highlighted
* OSD menu item will be used.
*/
VLC_EXPORT( void, __osd_MenuActivate, ( vlc_object_t * ) );
#define osd_MenuShow(object) __osd_MenuShow( VLC_OBJECT(object) )
#define osd_MenuHide(object) __osd_MenuHide( VLC_OBJECT(object) )
#define osd_MenuActivate(object) __osd_MenuActivate( VLC_OBJECT(object) )
/**
* Next OSD menu item
*
* Select the next OSD menu item to be highlighted.
* Note: The actual position on screen of the menu item is determined by the the
* OSD menu configuration file.
*/
VLC_EXPORT( void, __osd_MenuNext, ( vlc_object_t * ) );
/**
* Previous OSD menu item
*
* Select the previous OSD menu item to be highlighted.
* Note: The actual position on screen of the menu item is determined by the the
* OSD menu configuration file.
*/
VLC_EXPORT( void, __osd_MenuPrev, ( vlc_object_t * ) );
/**
* OSD menu item above
*
* Select the OSD menu item above the current item to be highlighted.
* Note: The actual position on screen of the menu item is determined by the the
* OSD menu configuration file.
*/
VLC_EXPORT( void, __osd_MenuUp, ( vlc_object_t * ) );
/**
* OSD menu item below
*
* Select the next OSD menu item below the current item to be highlighted.
* Note: The actual position on screen of the menu item is determined by the the
* OSD menu configuration file.
*/
VLC_EXPORT( void, __osd_MenuDown, ( vlc_object_t * ) );
#define osd_MenuNext(object) __osd_MenuNext( VLC_OBJECT(object) )
#define osd_MenuPrev(object) __osd_MenuPrev( VLC_OBJECT(object) )
#define osd_MenuUp(object) __osd_MenuUp( VLC_OBJECT(object) )
#define osd_MenuDown(object) __osd_MenuDown( VLC_OBJECT(object) )
/**
* Turn Volume Up
*
* Use the OSD menu to turn the audio volume up.
*/
VLC_EXPORT( void, __osd_VolumeUp, ( vlc_object_t * ) );
/**
* Turn Volume Down
*
* Use the OSD menu to turn the audio volume down.
*/
VLC_EXPORT( void, __osd_VolumeDown, ( vlc_object_t * ) );
#define osd_VolumeUp(object) __osd_VolumeUp( VLC_OBJECT(object) )
#define osd_VolumeDown(object) __osd_VolumeDown( VLC_OBJECT(object) )
/**
* Retrieve a non modifyable pointer to the OSD Menu state
*
*/
static inline const osd_menu_state_t *osd_GetMenuState( osd_menu_t *p_osd )
{
return( p_osd->p_state );
}
/**
* Get the last key press received by the OSD Menu
*
* Returns 0 when no key has been pressed or the value of the key pressed.
*/
static inline vlc_bool_t osd_GetKeyPressed( osd_menu_t *p_osd )
{
return( p_osd->p_state->b_update );
}
/**
* Set the key pressed to a value.
*
* Assign a new key value to the last key pressed on the OSD Menu.
*/
static inline void osd_SetKeyPressed( vlc_object_t *p_this, int i_value )
{
vlc_value_t val;
val.i_int = i_value;
var_Set( p_this, "key-pressed", val );
}
/**
* Update the OSD Menu visibility flag.
*
* VLC_TRUE means OSD Menu should be shown. VLC_FALSE means OSD Menu should not be shown.
*/
static inline void osd_SetMenuVisible( osd_menu_t *p_osd, vlc_bool_t b_value )
{
vlc_value_t val;
val.b_bool = p_osd->p_state->b_menu_visible = b_value;
var_Set( p_osd, "osd-menu-visible", val );
}
/**
* Update the OSD Menu update flag
*
* If the OSD Menu should be updated then set the update flag to VLC_TRUE, else to VLC_FALSE.
*/
static inline void osd_SetMenuUpdate( osd_menu_t *p_osd, vlc_bool_t b_value )
{
vlc_value_t val;
val.b_bool = p_osd->p_state->b_update = b_value;
var_Set( p_osd, "osd-menu-update", val );
}
/**
* Default feedback images
*
* Functions that provide the default OSD feedback images on hotkey commands. These feedback
* images are also part of the osd_button_t object. The types are declared in the include file
* include/osd.h
* @see osd.h
*/
VLC_EXPORT( picture_t *, osd_Slider, ( int i_width, int i_height, int i_position, short i_type ) );
VLC_EXPORT( picture_t *, osd_Icon, ( int i_width, int i_height, short i_type ) );
/**
* Loading and parse the OSD Configuration file
*
* These functions load/unload the OSD menu configuration file and create/destroy the
* themable OSD menu structure on the OSD object.
*/
VLC_EXPORT( int, osd_ConfigLoader, ( vlc_object_t *, const char *, osd_menu_t ** ) );
VLC_EXPORT( void, osd_ConfigUnload, ( vlc_object_t *, osd_menu_t ** ) );
# ifdef __cplusplus
}
# endif
#endif /* _VLC_OSD_H */
......@@ -391,6 +391,22 @@ struct module_symbols_t
char * (*__vlc_fix_readdir_charset_inner) (vlc_object_t *, const char *);
int (*vlc_scandir_inner) (const char *name, struct dirent ***namelist, int (*filter) ( const struct dirent * ), int (*compar) ( const struct dirent **, const struct dirent ** ));
int (*vlc_alphasort_inner) (const struct dirent **a, const struct dirent **b);
osd_state_t * (*__osd_StateChange_inner) (osd_state_t *, const int);
picture_t * (*osd_Slider_inner) (int i_width, int i_height, int i_position, short i_type);
void (*osd_ConfigUnload_inner) (vlc_object_t *, osd_menu_t **);
void (*__osd_MenuShow_inner) (vlc_object_t *);
picture_t * (*osd_Icon_inner) (int i_width, int i_height, short i_type);
void (*__osd_VolumeDown_inner) (vlc_object_t *);
void (*__osd_MenuNext_inner) (vlc_object_t *);
void (*__osd_MenuDelete_inner) (vlc_object_t *, osd_menu_t *);
void (*__osd_MenuHide_inner) (vlc_object_t *);
int (*osd_ConfigLoader_inner) (vlc_object_t *, const char *, osd_menu_t **);
void (*__osd_MenuUp_inner) (vlc_object_t *);
void (*__osd_MenuDown_inner) (vlc_object_t *);
osd_menu_t * (*__osd_MenuCreate_inner) (vlc_object_t *, const char *);
void (*__osd_MenuPrev_inner) (vlc_object_t *);
void (*__osd_VolumeUp_inner) (vlc_object_t *);
void (*__osd_MenuActivate_inner) (vlc_object_t *);
};
# if defined (__PLUGIN__)
# define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner
......@@ -766,6 +782,22 @@ struct module_symbols_t
# define __vlc_fix_readdir_charset (p_symbols)->__vlc_fix_readdir_charset_inner
# define vlc_scandir (p_symbols)->vlc_scandir_inner
# define vlc_alphasort (p_symbols)->vlc_alphasort_inner
# define __osd_StateChange (p_symbols)->__osd_StateChange_inner
# define osd_Slider (p_symbols)->osd_Slider_inner
# define osd_ConfigUnload (p_symbols)->osd_ConfigUnload_inner
# define __osd_MenuShow (p_symbols)->__osd_MenuShow_inner
# define osd_Icon (p_symbols)->osd_Icon_inner
# define __osd_VolumeDown (p_symbols)->__osd_VolumeDown_inner
# define __osd_MenuNext (p_symbols)->__osd_MenuNext_inner
# define __osd_MenuDelete (p_symbols)->__osd_MenuDelete_inner
# define __osd_MenuHide (p_symbols)->__osd_MenuHide_inner
# define osd_ConfigLoader (p_symbols)->osd_ConfigLoader_inner
# define __osd_MenuUp (p_symbols)->__osd_MenuUp_inner
# define __osd_MenuDown (p_symbols)->__osd_MenuDown_inner
# define __osd_MenuCreate (p_symbols)->__osd_MenuCreate_inner
# define __osd_MenuPrev (p_symbols)->__osd_MenuPrev_inner
# define __osd_VolumeUp (p_symbols)->__osd_VolumeUp_inner
# define __osd_MenuActivate (p_symbols)->__osd_MenuActivate_inner
# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)
/******************************************************************
* STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access.
......@@ -1144,6 +1176,22 @@ struct module_symbols_t
((p_symbols)->__vlc_fix_readdir_charset_inner) = __vlc_fix_readdir_charset; \
((p_symbols)->vlc_scandir_inner) = vlc_scandir; \
((p_symbols)->vlc_alphasort_inner) = vlc_alphasort; \
((p_symbols)->__osd_StateChange_inner) = __osd_StateChange; \
((p_symbols)->osd_Slider_inner) = osd_Slider; \
((p_symbols)->osd_ConfigUnload_inner) = osd_ConfigUnload; \
((p_symbols)->__osd_MenuShow_inner) = __osd_MenuShow; \
((p_symbols)->osd_Icon_inner) = osd_Icon; \
((p_symbols)->__osd_VolumeDown_inner) = __osd_VolumeDown; \
((p_symbols)->__osd_MenuNext_inner) = __osd_MenuNext; \
((p_symbols)->__osd_MenuDelete_inner) = __osd_MenuDelete; \
((p_symbols)->__osd_MenuHide_inner) = __osd_MenuHide; \
((p_symbols)->osd_ConfigLoader_inner) = osd_ConfigLoader; \
((p_symbols)->__osd_MenuUp_inner) = __osd_MenuUp; \
((p_symbols)->__osd_MenuDown_inner) = __osd_MenuDown; \
((p_symbols)->__osd_MenuCreate_inner) = __osd_MenuCreate; \
((p_symbols)->__osd_MenuPrev_inner) = __osd_MenuPrev; \
((p_symbols)->__osd_VolumeUp_inner) = __osd_VolumeUp; \
((p_symbols)->__osd_MenuActivate_inner) = __osd_MenuActivate; \
(p_symbols)->net_ConvertIPv4_deprecated = NULL; \
(p_symbols)->vlc_fix_readdir_charset_deprecated = NULL; \
......
......@@ -342,6 +342,8 @@ $Id$
* opie: interface for Opie using QT/Embedded library.
* osdmenu: video_filter for displaying and streaming a On Screen Display menu
* oss: audio output module using the OSS /dev/dsp interface.
* packetizer_copy: Simple copy packetizer
......
......@@ -1557,16 +1557,247 @@ static int OpenEncoder( vlc_object_t *p_this )
return VLC_SUCCESS;
}
/* FIXME: this routine is a hack to convert VLC_FOURCC('Y','U','V','A')
* into VLC_FOURCC('Y','U','V','P')
*/
static subpicture_t *YuvaYuvp( encoder_t *p_enc, subpicture_t *p_subpic )
{
subpicture_region_t *p_region = NULL;
for( p_region = p_subpic->p_region; p_region; p_region = p_region->p_next )
{
video_format_t *p_fmt = &p_region->fmt;
int i = 0, j = 0, n = 0, p = 0;
int i_max_entries = 256;
#ifdef RANDOM_DITHERING
int i_seed = 0xdeadbeef; /* random seed */
#else
int *pi_delta;
#endif
int i_pixels = p_region->picture.p[0].i_visible_lines
* p_region->picture.p[0].i_pitch;
int i_iterator = p_region->picture.p[0].i_visible_lines * 3 / 4
* p_region->picture.p[0].i_pitch
+ p_region->picture.p[0].i_pitch * 1 / 3;
int i_tolerance = 0;
p_fmt->i_chroma = VLC_FOURCC('Y','U','V','P');
p_fmt->p_palette = (video_palette_t *) malloc( sizeof( video_palette_t ) );
p_fmt->p_palette->i_entries = 0;
/* Find best iterator using Euclide’s algorithm */
for( ; i_iterator > 1 ; i_iterator-- )
{
int a = i_pixels;
int b = i_iterator;
int c;
while( b )
{
c = a % b;
a = b;
b = c;
}
if( a == 1 )
{
break;
}
}
/* Count colors, build best palette */
for( i_tolerance = 0; i_tolerance < 128; i_tolerance++ )
{
vlc_bool_t b_success = VLC_TRUE;
p_fmt->p_palette->i_entries = 0;
for( i = 0; i < i_pixels ; )
{
uint8_t y, u, v, a;
y = p_region->picture.p[0].p_pixels[i];
u = p_region->picture.p[1].p_pixels[i];
v = p_region->picture.p[2].p_pixels[i];
a = p_region->picture.p[3].p_pixels[i];
for( j = 0; j < p_fmt->p_palette->i_entries; j++ )
{
if( abs((int)p_fmt->p_palette->palette[j][0] - (int)y) <= i_tolerance &&
abs((int)p_fmt->p_palette->palette[j][1] - (int)u) <= i_tolerance &&
abs((int)p_fmt->p_palette->palette[j][2] - (int)v) <= i_tolerance &&
abs((int)p_fmt->p_palette->palette[j][3] - (int)a) <= i_tolerance / 2 )
{
break;
}
}
if( j == p_fmt->p_palette->i_entries )
{
p_fmt->p_palette->palette[j][0] = y;
p_fmt->p_palette->palette[j][1] = u;
p_fmt->p_palette->palette[j][2] = v;
p_fmt->p_palette->palette[j][3] = a;
p_fmt->p_palette->i_entries++;
}
if( p_fmt->p_palette->i_entries >= i_max_entries )
{
b_success = VLC_FALSE;
break;
}
i += i_iterator;
if( i > i_pixels )
{
i -= i_pixels;
}
}
if( b_success )
{
break;
}
}
#if DEBUG_DVBSUB
msg_Dbg( p_enc, "best palette has %d colors", p_fmt->p_palette->i_entries );
#endif
#ifndef RANDOM_DITHERING
pi_delta = malloc( ( p_region->picture.p[0].i_pitch + 1 )
* sizeof(int) * 4 );
for( i = 0; i < (p_region->picture.p[0].i_pitch + 1) * 4 ; i++ )
{
pi_delta[ i ] = 0;
}
#endif
/* Fill image with our new colours */
for( p = 0; p < p_region->picture.p[0].i_visible_lines ; p++ )
{
int i_ydelta = 0, i_udelta = 0, i_vdelta = 0, i_adelta = 0;
for( n = 0; n < p_region->picture.p[0].i_pitch ; n++ )
{
int i_offset = p * p_region->picture.p[0].i_pitch + n;
int y, u, v, a;
int i_mindist, i_best;
y = (int)p_region->picture.p[0].p_pixels[i_offset];
u = (int)p_region->picture.p[1].p_pixels[i_offset];
v = (int)p_region->picture.p[2].p_pixels[i_offset];
a = (int)p_region->picture.p[3].p_pixels[i_offset];
/* Add dithering compensation */
#ifdef RANDOM_DITHERING
y += ((i_seed & 0xff) - 0x80) * i_tolerance / 0x80;
u += (((i_seed >> 8) & 0xff) - 0x80) * i_tolerance / 0x80;