mirror of https://code.videolan.org/videolan/vlc
No functionnal changes (vout).
K&R and removed variables prefixe.
This commit is contained in:
parent
790c5845af
commit
c26db46d1e
|
@ -80,7 +80,7 @@ VLC_EXPORT( void, spu_PutSubpicture, ( spu_t *, subpicture_t * ) );
|
|||
*
|
||||
* The returned value if non NULL must be released by subpicture_Delete().
|
||||
*/
|
||||
VLC_EXPORT( subpicture_t *, spu_Render, ( spu_t *, const vlc_fourcc_t *p_chroma_list, const video_format_t *p_fmt_dst, const video_format_t *p_fmt_src, mtime_t render_subtitle_date, mtime_t render_osd_date, bool b_subtitle_only ) );
|
||||
VLC_EXPORT( subpicture_t *, spu_Render, ( spu_t *, const vlc_fourcc_t *p_chroma_list, const video_format_t *p_fmt_dst, const video_format_t *p_fmt_src, mtime_t render_subtitle_date, mtime_t render_osd_date, bool ignore_osd ) );
|
||||
|
||||
/**
|
||||
* It registers a new SPU channel.
|
||||
|
|
|
@ -55,207 +55,190 @@ static const char *deinterlace_modes[] = {
|
|||
static bool DeinterlaceIsModeValid(const char *mode)
|
||||
{
|
||||
for (unsigned i = 0; deinterlace_modes[i]; i++) {
|
||||
if( !strcmp(deinterlace_modes[i], mode))
|
||||
if (!strcmp(deinterlace_modes[i], mode))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static char *FilterFind( char *psz_filter_base, const char *psz_module )
|
||||
static char *FilterFind(char *filter_base, const char *module_name)
|
||||
{
|
||||
const size_t i_module = strlen( psz_module );
|
||||
const char *psz_filter = psz_filter_base;
|
||||
const size_t module_length = strlen(module_name);
|
||||
const char *filter = filter_base;
|
||||
|
||||
if( !psz_filter || i_module <= 0 )
|
||||
if (!filter || module_length <= 0)
|
||||
return NULL;
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
char *psz_find = strstr( psz_filter, psz_module );
|
||||
if( !psz_find )
|
||||
for (;;) {
|
||||
char *start = strstr(filter, module_name);
|
||||
if (!start)
|
||||
return NULL;
|
||||
if( psz_find[i_module] == '\0' || psz_find[i_module] == ':' )
|
||||
return psz_find;
|
||||
psz_filter = &psz_find[i_module];
|
||||
if (start[module_length] == '\0' || start[module_length] == ':')
|
||||
return start;
|
||||
filter = &start[module_length];
|
||||
}
|
||||
}
|
||||
|
||||
static bool DeinterlaceIsPresent( vout_thread_t *p_vout )
|
||||
static bool DeinterlaceIsPresent(vout_thread_t *vout)
|
||||
{
|
||||
char *psz_filter = var_GetNonEmptyString( p_vout, "video-filter" );
|
||||
char *filter = var_GetNonEmptyString(vout, "video-filter");
|
||||
|
||||
bool b_found = FilterFind( psz_filter, "deinterlace" ) != NULL;
|
||||
bool is_found = FilterFind(filter, "deinterlace") != NULL;
|
||||
|
||||
free( psz_filter );
|
||||
free(filter);
|
||||
|
||||
return b_found;
|
||||
return is_found;
|
||||
}
|
||||
|
||||
static void DeinterlaceRemove( vout_thread_t *p_vout )
|
||||
static void DeinterlaceRemove(vout_thread_t *vout)
|
||||
{
|
||||
char *psz_filter = var_GetNonEmptyString( p_vout, "video-filter" );
|
||||
char *filter = var_GetNonEmptyString(vout, "video-filter");
|
||||
|
||||
char *psz = FilterFind( psz_filter, "deinterlace" );
|
||||
if( !psz )
|
||||
{
|
||||
free( psz_filter );
|
||||
char *start = FilterFind(filter, "deinterlace");
|
||||
if (!start) {
|
||||
free(filter);
|
||||
return;
|
||||
}
|
||||
|
||||
/* */
|
||||
strcpy( &psz[0], &psz[strlen("deinterlace")] );
|
||||
if( *psz == ':' )
|
||||
strcpy( &psz[0], &psz[1] );
|
||||
strcpy(&start[0], &start[strlen("deinterlace")]);
|
||||
if (*start == ':')
|
||||
strcpy(&start[0], &start[1]);
|
||||
|
||||
var_SetString( p_vout, "video-filter", psz_filter );
|
||||
free( psz_filter );
|
||||
var_SetString(vout, "video-filter", filter);
|
||||
free(filter);
|
||||
}
|
||||
static void DeinterlaceAdd( vout_thread_t *p_vout )
|
||||
static void DeinterlaceAdd(vout_thread_t *vout)
|
||||
{
|
||||
char *psz_filter = var_GetNonEmptyString( p_vout, "video-filter" );
|
||||
char *filter = var_GetNonEmptyString(vout, "video-filter");
|
||||
|
||||
if( FilterFind( psz_filter, "deinterlace" ) )
|
||||
{
|
||||
free( psz_filter );
|
||||
if (FilterFind(filter, "deinterlace")) {
|
||||
free(filter);
|
||||
return;
|
||||
}
|
||||
|
||||
/* */
|
||||
if( psz_filter )
|
||||
{
|
||||
char *psz_tmp = psz_filter;
|
||||
if( asprintf( &psz_filter, "%s:%s", psz_tmp, "deinterlace" ) < 0 )
|
||||
psz_filter = psz_tmp;
|
||||
if (filter) {
|
||||
char *tmp = filter;
|
||||
if (asprintf(&filter, "%s:%s", tmp, "deinterlace") < 0)
|
||||
filter = tmp;
|
||||
else
|
||||
free( psz_tmp );
|
||||
}
|
||||
else
|
||||
{
|
||||
psz_filter = strdup( "deinterlace" );
|
||||
free(tmp);
|
||||
} else {
|
||||
filter = strdup("deinterlace");
|
||||
}
|
||||
|
||||
if( psz_filter )
|
||||
{
|
||||
var_SetString( p_vout, "video-filter", psz_filter );
|
||||
free( psz_filter );
|
||||
if (filter) {
|
||||
var_SetString(vout, "video-filter", filter);
|
||||
free(filter);
|
||||
}
|
||||
}
|
||||
|
||||
static int DeinterlaceCallback( vlc_object_t *p_this, char const *psz_cmd,
|
||||
vlc_value_t oldval, vlc_value_t newval, void *p_data )
|
||||
static int DeinterlaceCallback(vlc_object_t *object, char const *cmd,
|
||||
vlc_value_t oldval, vlc_value_t newval, void *data)
|
||||
{
|
||||
VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(newval); VLC_UNUSED(p_data);
|
||||
vout_thread_t *p_vout = (vout_thread_t *)p_this;
|
||||
VLC_UNUSED(cmd); VLC_UNUSED(oldval); VLC_UNUSED(newval); VLC_UNUSED(data);
|
||||
vout_thread_t *vout = (vout_thread_t *)object;
|
||||
|
||||
/* */
|
||||
const int i_deinterlace = var_GetInteger( p_this, "deinterlace" );
|
||||
char *psz_mode = var_GetString( p_this, "deinterlace-mode" );
|
||||
const bool is_needed = var_GetBool( p_this, "deinterlace-needed" );
|
||||
if( !psz_mode || !DeinterlaceIsModeValid(psz_mode) )
|
||||
const int deinterlace_state = var_GetInteger(vout, "deinterlace");
|
||||
char *mode = var_GetString(vout, "deinterlace-mode");
|
||||
const bool is_needed = var_GetBool(vout, "deinterlace-needed");
|
||||
if (!mode || !DeinterlaceIsModeValid(mode))
|
||||
return VLC_EGENERIC;
|
||||
|
||||
/* */
|
||||
char *psz_old = var_CreateGetString( p_vout, "sout-deinterlace-mode" );
|
||||
var_SetString( p_vout, "sout-deinterlace-mode", psz_mode );
|
||||
char *old = var_CreateGetString(vout, "sout-deinterlace-mode");
|
||||
var_SetString(vout, "sout-deinterlace-mode", mode);
|
||||
|
||||
msg_Dbg( p_vout, "deinterlace %d, mode %s, is_needed %d", i_deinterlace, psz_mode, is_needed );
|
||||
if( i_deinterlace == 0 || ( i_deinterlace == -1 && !is_needed ) )
|
||||
{
|
||||
DeinterlaceRemove( p_vout );
|
||||
}
|
||||
else if( !DeinterlaceIsPresent( p_vout ) )
|
||||
{
|
||||
DeinterlaceAdd( p_vout );
|
||||
}
|
||||
else if( psz_old && strcmp( psz_old, psz_mode ) )
|
||||
{
|
||||
var_TriggerCallback( p_vout, "video-filter" );
|
||||
}
|
||||
msg_Dbg(vout, "deinterlace %d, mode %s, is_needed %d", deinterlace_state, mode, is_needed);
|
||||
if (deinterlace_state == 0 || (deinterlace_state == -1 && !is_needed))
|
||||
DeinterlaceRemove(vout);
|
||||
else if (!DeinterlaceIsPresent(vout))
|
||||
DeinterlaceAdd(vout);
|
||||
else if (old && strcmp(old, mode))
|
||||
var_TriggerCallback(vout, "video-filter");
|
||||
|
||||
/* */
|
||||
free( psz_old );
|
||||
free( psz_mode );
|
||||
free(old);
|
||||
free(mode);
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
|
||||
void vout_InitInterlacingSupport( vout_thread_t *p_vout, bool is_interlaced )
|
||||
void vout_InitInterlacingSupport(vout_thread_t *vout, bool is_interlaced)
|
||||
{
|
||||
vlc_value_t val, text;
|
||||
|
||||
msg_Dbg( p_vout, "Deinterlacing available" );
|
||||
msg_Dbg(vout, "Deinterlacing available");
|
||||
|
||||
/* Create the configuration variables */
|
||||
/* */
|
||||
var_Create( p_vout, "deinterlace", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT | VLC_VAR_HASCHOICE );
|
||||
int i_deinterlace = var_GetInteger( p_vout, "deinterlace" );
|
||||
i_deinterlace = __MAX( __MIN( i_deinterlace, 1 ), -1 );
|
||||
var_Create(vout, "deinterlace", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT | VLC_VAR_HASCHOICE);
|
||||
int deinterlace_state = var_GetInteger(vout, "deinterlace");
|
||||
deinterlace_state = __MAX(__MIN(deinterlace_state, 1), -1);
|
||||
|
||||
text.psz_string = _("Deinterlace");
|
||||
var_Change( p_vout, "deinterlace", VLC_VAR_SETTEXT, &text, NULL );
|
||||
var_Change(vout, "deinterlace", VLC_VAR_SETTEXT, &text, NULL);
|
||||
|
||||
const module_config_t *p_optd = config_FindConfig( VLC_OBJECT(p_vout), "deinterlace" );
|
||||
var_Change( p_vout, "deinterlace", VLC_VAR_CLEARCHOICES, NULL, NULL );
|
||||
for( int i = 0; p_optd && i < p_optd->i_list; i++ )
|
||||
{
|
||||
val.i_int = p_optd->pi_list[i];
|
||||
text.psz_string = (char*)vlc_gettext(p_optd->ppsz_list_text[i]);
|
||||
var_Change( p_vout, "deinterlace", VLC_VAR_ADDCHOICE, &val, &text );
|
||||
const module_config_t *optd = config_FindConfig(VLC_OBJECT(vout), "deinterlace");
|
||||
var_Change(vout, "deinterlace", VLC_VAR_CLEARCHOICES, NULL, NULL);
|
||||
for (int i = 0; optd && i < optd->i_list; i++) {
|
||||
val.i_int = optd->pi_list[i];
|
||||
text.psz_string = (char*)vlc_gettext(optd->ppsz_list_text[i]);
|
||||
var_Change(vout, "deinterlace", VLC_VAR_ADDCHOICE, &val, &text);
|
||||
}
|
||||
var_AddCallback( p_vout, "deinterlace", DeinterlaceCallback, NULL );
|
||||
var_AddCallback(vout, "deinterlace", DeinterlaceCallback, NULL);
|
||||
/* */
|
||||
var_Create( p_vout, "deinterlace-mode", VLC_VAR_STRING | VLC_VAR_DOINHERIT | VLC_VAR_HASCHOICE );
|
||||
char *psz_deinterlace = var_GetNonEmptyString( p_vout, "deinterlace-mode" );
|
||||
var_Create(vout, "deinterlace-mode", VLC_VAR_STRING | VLC_VAR_DOINHERIT | VLC_VAR_HASCHOICE);
|
||||
char *deinterlace_mode = var_GetNonEmptyString(vout, "deinterlace-mode");
|
||||
|
||||
text.psz_string = _("Deinterlace mode");
|
||||
var_Change( p_vout, "deinterlace-mode", VLC_VAR_SETTEXT, &text, NULL );
|
||||
var_Change(vout, "deinterlace-mode", VLC_VAR_SETTEXT, &text, NULL);
|
||||
|
||||
const module_config_t *p_optm = config_FindConfig( VLC_OBJECT(p_vout), "deinterlace-mode" );
|
||||
var_Change( p_vout, "deinterlace-mode", VLC_VAR_CLEARCHOICES, NULL, NULL );
|
||||
for( int i = 0; p_optm && i < p_optm->i_list; i++ )
|
||||
{
|
||||
if( !DeinterlaceIsModeValid( p_optm->ppsz_list[i] ) )
|
||||
const module_config_t *optm = config_FindConfig(VLC_OBJECT(vout), "deinterlace-mode");
|
||||
var_Change(vout, "deinterlace-mode", VLC_VAR_CLEARCHOICES, NULL, NULL);
|
||||
for (int i = 0; optm && i < optm->i_list; i++) {
|
||||
if (!DeinterlaceIsModeValid(optm->ppsz_list[i]))
|
||||
continue;
|
||||
|
||||
val.psz_string = p_optm->ppsz_list[i];
|
||||
text.psz_string = (char*)vlc_gettext(p_optm->ppsz_list_text[i]);
|
||||
var_Change( p_vout, "deinterlace-mode", VLC_VAR_ADDCHOICE, &val, &text );
|
||||
val.psz_string = optm->ppsz_list[i];
|
||||
text.psz_string = (char*)vlc_gettext(optm->ppsz_list_text[i]);
|
||||
var_Change(vout, "deinterlace-mode", VLC_VAR_ADDCHOICE, &val, &text);
|
||||
}
|
||||
var_AddCallback( p_vout, "deinterlace-mode", DeinterlaceCallback, NULL );
|
||||
var_AddCallback(vout, "deinterlace-mode", DeinterlaceCallback, NULL);
|
||||
/* */
|
||||
var_Create( p_vout, "deinterlace-needed", VLC_VAR_BOOL );
|
||||
var_AddCallback( p_vout, "deinterlace-needed", DeinterlaceCallback, NULL );
|
||||
var_Create(vout, "deinterlace-needed", VLC_VAR_BOOL);
|
||||
var_AddCallback(vout, "deinterlace-needed", DeinterlaceCallback, NULL);
|
||||
|
||||
/* Override the initial value from filters if present */
|
||||
char *psz_filter_mode = NULL;
|
||||
if( DeinterlaceIsPresent( p_vout ) )
|
||||
psz_filter_mode = var_CreateGetNonEmptyString( p_vout, "sout-deinterlace-mode" );
|
||||
if( psz_filter_mode )
|
||||
{
|
||||
i_deinterlace = 1;
|
||||
free( psz_deinterlace );
|
||||
psz_deinterlace = psz_filter_mode;
|
||||
char *filter_mode = NULL;
|
||||
if (DeinterlaceIsPresent(vout))
|
||||
filter_mode = var_CreateGetNonEmptyString(vout, "sout-deinterlace-mode");
|
||||
if (filter_mode) {
|
||||
deinterlace_state = 1;
|
||||
free(deinterlace_mode);
|
||||
deinterlace_mode = filter_mode;
|
||||
}
|
||||
|
||||
/* */
|
||||
val.psz_string = psz_deinterlace ? psz_deinterlace : p_optm->orig.psz;
|
||||
var_Change( p_vout, "deinterlace-mode", VLC_VAR_SETVALUE, &val, NULL );
|
||||
val.psz_string = deinterlace_mode ? deinterlace_mode : optm->orig.psz;
|
||||
var_Change(vout, "deinterlace-mode", VLC_VAR_SETVALUE, &val, NULL);
|
||||
val.b_bool = is_interlaced;
|
||||
var_Change( p_vout, "deinterlace-needed", VLC_VAR_SETVALUE, &val, NULL );
|
||||
var_Change(vout, "deinterlace-needed", VLC_VAR_SETVALUE, &val, NULL);
|
||||
|
||||
var_SetInteger( p_vout, "deinterlace", i_deinterlace );
|
||||
free( psz_deinterlace );
|
||||
var_SetInteger(vout, "deinterlace", deinterlace_state);
|
||||
free(deinterlace_mode);
|
||||
}
|
||||
|
||||
void vout_SetInterlacingState( vout_thread_t *p_vout, vout_interlacing_support_t *state, bool is_interlaced )
|
||||
void vout_SetInterlacingState(vout_thread_t *vout, vout_interlacing_support_t *state, bool is_interlaced)
|
||||
{
|
||||
/* Wait 30s before quiting interlacing mode */
|
||||
const int interlacing_change = (!!is_interlaced) - (!!state->is_interlaced);
|
||||
if ((interlacing_change == 1) ||
|
||||
(interlacing_change == -1 && state->date + 30000000 < mdate())) {
|
||||
|
||||
msg_Dbg( p_vout, "Detected %s video",
|
||||
is_interlaced ? "interlaced" : "progressive" );
|
||||
var_SetBool( p_vout, "deinterlace-needed", is_interlaced );
|
||||
msg_Dbg(vout, "Detected %s video",
|
||||
is_interlaced ? "interlaced" : "progressive");
|
||||
var_SetBool(vout, "deinterlace-needed", is_interlaced);
|
||||
|
||||
state->is_interlaced = is_interlaced;
|
||||
}
|
||||
|
|
|
@ -31,113 +31,101 @@
|
|||
|
||||
#include "postprocessing.h"
|
||||
|
||||
static bool PostProcessIsPresent( const char *psz_filter )
|
||||
static bool PostProcessIsPresent(const char *filter)
|
||||
{
|
||||
const char *psz_pp = "postproc";
|
||||
const size_t i_pp = strlen(psz_pp);
|
||||
return psz_filter &&
|
||||
!strncmp( psz_filter, psz_pp, strlen(psz_pp) ) &&
|
||||
( psz_filter[i_pp] == '\0' || psz_filter[i_pp] == ':' );
|
||||
const char *pp = "postproc";
|
||||
const size_t pp_length = strlen(pp);
|
||||
return filter &&
|
||||
!strncmp(filter, pp, strlen(pp)) &&
|
||||
(filter[pp_length] == '\0' || filter[pp_length] == ':');
|
||||
}
|
||||
|
||||
static int PostProcessCallback( vlc_object_t *p_this, char const *psz_cmd,
|
||||
vlc_value_t oldval, vlc_value_t newval, void *p_data )
|
||||
static int PostProcessCallback(vlc_object_t *object, char const *cmd,
|
||||
vlc_value_t oldval, vlc_value_t newval, void *data)
|
||||
{
|
||||
vout_thread_t *p_vout = (vout_thread_t *)p_this;
|
||||
VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
|
||||
vout_thread_t *vout = (vout_thread_t *)object;
|
||||
VLC_UNUSED(cmd); VLC_UNUSED(oldval); VLC_UNUSED(data);
|
||||
|
||||
static const char *psz_pp = "postproc";
|
||||
static const char *pp = "postproc";
|
||||
|
||||
char *psz_vf2 = var_GetString( p_vout, "video-filter" );
|
||||
char *filters = var_GetString(vout, "video-filter");
|
||||
|
||||
if( newval.i_int <= 0 )
|
||||
{
|
||||
if( PostProcessIsPresent( psz_vf2 ) )
|
||||
{
|
||||
strcpy( psz_vf2, &psz_vf2[strlen(psz_pp)] );
|
||||
if( *psz_vf2 == ':' )
|
||||
strcpy( psz_vf2, &psz_vf2[1] );
|
||||
if (newval.i_int <= 0) {
|
||||
if (PostProcessIsPresent(filters)) {
|
||||
strcpy(filters, &filters[strlen(pp)]);
|
||||
if (*filters == ':')
|
||||
strcpy(filters, &filters[1]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !PostProcessIsPresent( psz_vf2 ) )
|
||||
{
|
||||
if( psz_vf2 )
|
||||
{
|
||||
char *psz_tmp = psz_vf2;
|
||||
if( asprintf( &psz_vf2, "%s:%s", psz_pp, psz_tmp ) < 0 )
|
||||
psz_vf2 = psz_tmp;
|
||||
} else {
|
||||
if (!PostProcessIsPresent(filters)) {
|
||||
if (filters) {
|
||||
char *tmp = filters;
|
||||
if (asprintf(&filters, "%s:%s", pp, tmp) < 0)
|
||||
filters = tmp;
|
||||
else
|
||||
free( psz_tmp );
|
||||
}
|
||||
else
|
||||
{
|
||||
psz_vf2 = strdup( psz_pp );
|
||||
free(tmp);
|
||||
} else {
|
||||
filters = strdup(pp);
|
||||
}
|
||||
}
|
||||
}
|
||||
if( newval.i_int > 0 )
|
||||
var_SetInteger( p_vout, "postproc-q", newval.i_int );
|
||||
if( psz_vf2 )
|
||||
{
|
||||
var_SetString( p_vout, "video-filter", psz_vf2 );
|
||||
free( psz_vf2 );
|
||||
}
|
||||
else if( newval.i_int > 0 )
|
||||
{
|
||||
var_TriggerCallback( p_vout, "video-filter" );
|
||||
if (newval.i_int > 0)
|
||||
var_SetInteger(vout, "postproc-q", newval.i_int);
|
||||
if (filters) {
|
||||
var_SetString(vout, "video-filter", filters);
|
||||
free(filters);
|
||||
} else if (newval.i_int > 0) {
|
||||
var_TriggerCallback(vout, "video-filter");
|
||||
}
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
static void PostProcessEnable( vout_thread_t *p_vout )
|
||||
static void PostProcessEnable(vout_thread_t *vout)
|
||||
{
|
||||
vlc_value_t text;
|
||||
msg_Dbg( p_vout, "Post-processing available" );
|
||||
var_Create( p_vout, "postprocess", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
|
||||
msg_Dbg(vout, "Post-processing available");
|
||||
var_Create(vout, "postprocess", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE);
|
||||
text.psz_string = _("Post processing");
|
||||
var_Change( p_vout, "postprocess", VLC_VAR_SETTEXT, &text, NULL );
|
||||
var_Change(vout, "postprocess", VLC_VAR_SETTEXT, &text, NULL);
|
||||
|
||||
for( int i = 0; i <= 6; i++ )
|
||||
{
|
||||
for (int i = 0; i <= 6; i++) {
|
||||
vlc_value_t val;
|
||||
vlc_value_t text;
|
||||
char psz_text[1+1];
|
||||
char tmp[1+1];
|
||||
|
||||
val.i_int = i;
|
||||
snprintf( psz_text, sizeof(psz_text), "%d", i );
|
||||
if( i == 0 )
|
||||
snprintf(tmp, sizeof(tmp), "%d", i);
|
||||
if (i == 0)
|
||||
text.psz_string = _("Disable");
|
||||
else
|
||||
text.psz_string = psz_text;
|
||||
var_Change( p_vout, "postprocess", VLC_VAR_ADDCHOICE, &val, &text );
|
||||
text.psz_string = tmp;
|
||||
var_Change(vout, "postprocess", VLC_VAR_ADDCHOICE, &val, &text);
|
||||
}
|
||||
var_AddCallback( p_vout, "postprocess", PostProcessCallback, NULL );
|
||||
var_AddCallback(vout, "postprocess", PostProcessCallback, NULL);
|
||||
|
||||
/* */
|
||||
char *psz_filter = var_GetNonEmptyString( p_vout, "video-filter" );
|
||||
int i_postproc_q = 0;
|
||||
if( PostProcessIsPresent( psz_filter ) )
|
||||
i_postproc_q = var_CreateGetInteger( p_vout, "postproc-q" );
|
||||
char *filters = var_GetNonEmptyString(vout, "video-filter");
|
||||
int postproc_q = 0;
|
||||
if (PostProcessIsPresent(filters))
|
||||
postproc_q = var_CreateGetInteger(vout, "postproc-q");
|
||||
|
||||
var_SetInteger( p_vout, "postprocess", i_postproc_q );
|
||||
var_SetInteger(vout, "postprocess", postproc_q);
|
||||
|
||||
free( psz_filter );
|
||||
free(filters);
|
||||
}
|
||||
static void PostProcessDisable( vout_thread_t *p_vout )
|
||||
static void PostProcessDisable(vout_thread_t *vout)
|
||||
{
|
||||
msg_Dbg( p_vout, "Post-processing no more available" );
|
||||
var_Destroy( p_vout, "postprocess" );
|
||||
msg_Dbg(vout, "Post-processing no more available");
|
||||
var_Destroy(vout, "postprocess");
|
||||
}
|
||||
|
||||
void vout_SetPostProcessingState(vout_thread_t *vout, vout_postprocessing_support_t *state, int qtype)
|
||||
{
|
||||
const int postproc_change = (qtype != QTYPE_NONE) - (state->qtype != QTYPE_NONE);
|
||||
if (postproc_change == 1)
|
||||
PostProcessEnable(vout);
|
||||
else if (postproc_change == -1)
|
||||
PostProcessDisable(vout);
|
||||
if (postproc_change)
|
||||
state->qtype = qtype;
|
||||
const int postproc_change = (qtype != QTYPE_NONE) - (state->qtype != QTYPE_NONE);
|
||||
if (postproc_change == 1)
|
||||
PostProcessEnable(vout);
|
||||
else if (postproc_change == -1)
|
||||
PostProcessDisable(vout);
|
||||
if (postproc_change)
|
||||
state->qtype = qtype;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,285 +37,276 @@
|
|||
#define EPG_NAME_SIZE 0.05
|
||||
#define EPG_PROGRAM_SIZE 0.03
|
||||
|
||||
static subpicture_region_t * vout_OSDEpgSlider( int i_x, int i_y,
|
||||
int i_width, int i_height,
|
||||
float f_ratio )
|
||||
static subpicture_region_t * vout_OSDEpgSlider(int x, int y,
|
||||
int width, int height,
|
||||
float ratio)
|
||||
{
|
||||
video_format_t fmt;
|
||||
subpicture_region_t *p_region;
|
||||
subpicture_region_t *region;
|
||||
|
||||
/* Create a new subpicture region */
|
||||
video_format_Init( &fmt, VLC_CODEC_YUVA );
|
||||
fmt.i_width = fmt.i_visible_width = i_width;
|
||||
fmt.i_height = fmt.i_visible_height = i_height;
|
||||
video_format_Init(&fmt, VLC_CODEC_YUVA);
|
||||
fmt.i_width = fmt.i_visible_width = width;
|
||||
fmt.i_height = fmt.i_visible_height = height;
|
||||
fmt.i_sar_num = 0;
|
||||
fmt.i_sar_den = 1;
|
||||
|
||||
p_region = subpicture_region_New( &fmt );
|
||||
if( !p_region )
|
||||
region = subpicture_region_New(&fmt);
|
||||
if (!region)
|
||||
return NULL;
|
||||
|
||||
p_region->i_x = i_x;
|
||||
p_region->i_y = i_y;
|
||||
region->i_x = x;
|
||||
region->i_y = y;
|
||||
|
||||
picture_t *p_picture = p_region->p_picture;
|
||||
picture_t *picture = region->p_picture;
|
||||
|
||||
f_ratio = __MIN( __MAX( f_ratio, 0 ), 1 );
|
||||
int i_filled_part_width = f_ratio * i_width;
|
||||
ratio = __MIN(__MAX(ratio, 0), 1);
|
||||
int filled_part_width = ratio * width;
|
||||
|
||||
for( int j = 0; j < i_height; j++ )
|
||||
{
|
||||
for( int i = 0; i < i_width; i++ )
|
||||
{
|
||||
#define WRITE_COMP( plane, value ) \
|
||||
p_picture->p[plane].p_pixels[p_picture->p[plane].i_pitch * j + i] = value
|
||||
for (int j = 0; j < height; j++) {
|
||||
for (int i = 0; i < width; i++) {
|
||||
#define WRITE_COMP(plane, value) \
|
||||
picture->p[plane].p_pixels[picture->p[plane].i_pitch * j + i] = value
|
||||
|
||||
/* Draw the slider. */
|
||||
bool is_outline = j == 0 || j == i_height - 1
|
||||
|| i == 0 || i == i_width - 1;
|
||||
WRITE_COMP( 0, is_outline ? 0x00 : 0xff );
|
||||
WRITE_COMP( 1, 0x80 );
|
||||
WRITE_COMP( 2, 0x80 );
|
||||
bool is_outline = j == 0 || j == height - 1 ||
|
||||
i == 0 || i == width - 1;
|
||||
WRITE_COMP(0, is_outline ? 0x00 : 0xff);
|
||||
WRITE_COMP(1, 0x80);
|
||||
WRITE_COMP(2, 0x80);
|
||||
|
||||
/* We can see the video through the part of the slider
|
||||
which corresponds to the leaving time. */
|
||||
bool is_border = j < 3 || j > i_height - 4
|
||||
|| i < 3 || i > i_width - 4
|
||||
|| i < i_filled_part_width;
|
||||
WRITE_COMP( 3, is_border ? 0xff : 0x00 );
|
||||
bool is_border = j < 3 || j > height - 4 ||
|
||||
i < 3 || i > width - 4 ||
|
||||
i < filled_part_width;
|
||||
WRITE_COMP(3, is_border ? 0xff : 0x00);
|
||||
|
||||
#undef WRITE_COMP
|
||||
}
|
||||
}
|
||||
|
||||
return p_region;
|
||||
return region;
|
||||
}
|
||||
|
||||
|
||||
static subpicture_region_t * vout_OSDEpgText( const char *psz_string,
|
||||
int i_x, int i_y,
|
||||
int i_size, uint32_t i_color )
|
||||
static subpicture_region_t * vout_OSDEpgText(const char *text,
|
||||
int x, int y,
|
||||
int size, uint32_t color)
|
||||
{
|
||||
video_format_t fmt;
|
||||
subpicture_region_t *p_region;
|
||||
subpicture_region_t *region;
|
||||
|
||||
if( !psz_string )
|
||||
if (!text)
|
||||
return NULL;
|
||||
|
||||
/* Create a new subpicture region */
|
||||
video_format_Init( &fmt, VLC_CODEC_TEXT );
|
||||
video_format_Init(&fmt, VLC_CODEC_TEXT);
|
||||
fmt.i_sar_num = 0;
|
||||
fmt.i_sar_den = 1;
|
||||
|
||||
p_region = subpicture_region_New( &fmt );
|
||||
if( !p_region )
|
||||
region = subpicture_region_New(&fmt);
|
||||
if (!region)
|
||||
return NULL;
|
||||
|
||||
/* Set subpicture parameters */
|
||||
p_region->psz_text = strdup( psz_string );
|
||||
p_region->i_align = 0;
|
||||
p_region->i_x = i_x;
|
||||
p_region->i_y = i_y;
|
||||
region->psz_text = strdup(text);
|
||||
region->i_align = 0;
|
||||
region->i_x = x;
|
||||
region->i_y = y;
|
||||
|
||||
/* Set text style */
|
||||
p_region->p_style = text_style_New();
|
||||
if( p_region->p_style )
|
||||
{
|
||||
p_region->p_style->i_font_size = i_size;
|
||||
p_region->p_style->i_font_color = i_color;
|
||||
p_region->p_style->i_font_alpha = 0;
|
||||
region->p_style = text_style_New();
|
||||
if (region->p_style) {
|
||||
region->p_style->i_font_size = size;
|
||||
region->p_style->i_font_color = color;
|
||||
region->p_style->i_font_alpha = 0;
|
||||
}
|
||||
|
||||
return p_region;
|
||||
return region;
|
||||
}
|
||||
|
||||
|
||||
static subpicture_region_t * vout_BuildOSDEpg( vlc_epg_t *p_epg,
|
||||
int i_x, int i_y,
|
||||
int i_visible_width,
|
||||
int i_visible_height )
|
||||
static subpicture_region_t * vout_BuildOSDEpg(vlc_epg_t *epg,
|
||||
int x, int y,
|
||||
int visible_width,
|
||||
int visible_height)
|
||||
{
|
||||
subpicture_region_t *p_region_ret;
|
||||
subpicture_region_t **pp_region = &p_region_ret;
|
||||
subpicture_region_t *head;
|
||||
subpicture_region_t **last_ptr = &head;
|
||||
|
||||
time_t i_test = time( NULL );
|
||||
time_t current_time = time(NULL);
|
||||
|
||||
/* Display the name of the channel. */
|
||||
*pp_region = vout_OSDEpgText( p_epg->psz_name,
|
||||
i_x + i_visible_width * EPG_LEFT,
|
||||
i_y + i_visible_height * EPG_TOP,
|
||||
i_visible_height * EPG_NAME_SIZE,
|
||||
0x00ffffff );
|
||||
*last_ptr = vout_OSDEpgText(epg->psz_name,
|
||||
x + visible_width * EPG_LEFT,
|
||||
y + visible_height * EPG_TOP,
|
||||
visible_height * EPG_NAME_SIZE,
|
||||
0x00ffffff);
|
||||
|
||||
if( !*pp_region )
|
||||
return p_region_ret;
|
||||
if (!*last_ptr)
|
||||
return head;
|
||||
|
||||
/* Display the name of the current program. */
|
||||
pp_region = &(* pp_region)->p_next;
|
||||
*pp_region = vout_OSDEpgText( p_epg->p_current->psz_name,
|
||||
i_x + i_visible_width * ( EPG_LEFT + 0.025 ),
|
||||
i_y + i_visible_height * ( EPG_TOP + 0.05 ),
|
||||
i_visible_height * EPG_PROGRAM_SIZE,
|
||||
0x00ffffff );
|
||||
last_ptr = &(*last_ptr)->p_next;
|
||||
*last_ptr = vout_OSDEpgText(epg->p_current->psz_name,
|
||||
x + visible_width * (EPG_LEFT + 0.025),
|
||||
y + visible_height * (EPG_TOP + 0.05),
|
||||
visible_height * EPG_PROGRAM_SIZE,
|
||||
0x00ffffff);
|
||||
|
||||
if( !*pp_region )
|
||||
return p_region_ret;
|
||||
if (!*last_ptr)
|
||||
return head;
|
||||
|
||||
/* Display the current program time slider. */
|
||||
pp_region = &(* pp_region)->p_next;
|
||||
*pp_region = vout_OSDEpgSlider( i_x + i_visible_width * EPG_LEFT,
|
||||
i_y + i_visible_height * ( EPG_TOP + 0.1 ),
|
||||
i_visible_width * ( 1 - 2 * EPG_LEFT ),
|
||||
i_visible_height * 0.05,
|
||||
( i_test - p_epg->p_current->i_start )
|
||||
/ (float)p_epg->p_current->i_duration );
|
||||
last_ptr = &(*last_ptr)->p_next;
|
||||
*last_ptr = vout_OSDEpgSlider(x + visible_width * EPG_LEFT,
|
||||
y + visible_height * (EPG_TOP + 0.1),
|
||||
visible_width * (1 - 2 * EPG_LEFT),
|
||||
visible_height * 0.05,
|
||||
(current_time - epg->p_current->i_start)
|
||||
/ (float)epg->p_current->i_duration);
|
||||
|
||||
if( !*pp_region )
|
||||
return p_region_ret;
|
||||
if (!*last_ptr)
|
||||
return head;
|
||||
|
||||
/* Format the hours of the beginning and the end of the current program. */
|
||||
struct tm tm_start, tm_end;
|
||||
time_t t_start = p_epg->p_current->i_start;
|
||||
time_t t_end = p_epg->p_current->i_start + p_epg->p_current->i_duration;
|
||||
localtime_r( &t_start, &tm_start );
|
||||
localtime_r( &t_end, &tm_end );
|
||||
char psz_start[128];
|
||||
char psz_end[128];
|
||||
snprintf( psz_start, sizeof(psz_start), "%2.2d:%2.2d",
|
||||
tm_start.tm_hour, tm_start.tm_min );
|
||||
snprintf( psz_end, sizeof(psz_end), "%2.2d:%2.2d",
|
||||
tm_end.tm_hour, tm_end.tm_min );
|
||||
time_t t_start = epg->p_current->i_start;
|
||||
time_t t_end = epg->p_current->i_start + epg->p_current->i_duration;
|
||||
localtime_r(&t_start, &tm_start);
|
||||
localtime_r(&t_end, &tm_end);
|
||||
char text_start[128];
|
||||
char text_end[128];
|
||||
snprintf(text_start, sizeof(text_start), "%2.2d:%2.2d",
|
||||
tm_start.tm_hour, tm_start.tm_min);
|
||||
snprintf(text_end, sizeof(text_end), "%2.2d:%2.2d",
|
||||
tm_end.tm_hour, tm_end.tm_min);
|
||||
|
||||
/* Display those hours. */
|
||||
pp_region = &(* pp_region)->p_next;
|
||||
*pp_region = vout_OSDEpgText( psz_start,
|
||||
i_x + i_visible_width * ( EPG_LEFT + 0.02 ),
|
||||
i_y + i_visible_height * ( EPG_TOP + 0.15 ),
|
||||
i_visible_height * EPG_PROGRAM_SIZE,
|
||||
0x00ffffff );
|
||||
last_ptr = &(*last_ptr)->p_next;
|
||||
*last_ptr = vout_OSDEpgText(text_start,
|
||||
x + visible_width * (EPG_LEFT + 0.02),
|
||||
y + visible_height * (EPG_TOP + 0.15),
|
||||
visible_height * EPG_PROGRAM_SIZE,
|
||||
0x00ffffff);
|
||||
|
||||
if( !*pp_region )
|
||||
return p_region_ret;
|
||||
if (!*last_ptr)
|
||||
return head;
|
||||
|
||||
pp_region = &(* pp_region)->p_next;
|
||||
*pp_region = vout_OSDEpgText( psz_end,
|
||||
i_x + i_visible_width * ( 1 - EPG_LEFT - 0.085 ),
|
||||
i_y + i_visible_height * ( EPG_TOP + 0.15 ),
|
||||
i_visible_height * EPG_PROGRAM_SIZE,
|
||||
0x00ffffff );
|
||||
last_ptr = &(*last_ptr)->p_next;
|
||||
*last_ptr = vout_OSDEpgText(text_end,
|
||||
x + visible_width * (1 - EPG_LEFT - 0.085),
|
||||
y + visible_height * (EPG_TOP + 0.15),
|
||||
visible_height * EPG_PROGRAM_SIZE,
|
||||
0x00ffffff);
|
||||
|
||||
return p_region_ret;
|
||||
return head;
|
||||
}
|
||||
|
||||
struct subpicture_updater_sys_t
|
||||
{
|
||||
vlc_epg_t *p_epg;
|
||||
vlc_epg_t *epg;
|
||||
};
|
||||
|
||||
static int OSDEpgValidate( subpicture_t *p_subpic,
|
||||
bool has_src_changed, const video_format_t *p_fmt_src,
|
||||
bool has_dst_changed, const video_format_t *p_fmt_dst,
|
||||
mtime_t i_ts )
|
||||
static int OSDEpgValidate(subpicture_t *subpic,
|
||||
bool has_src_changed, const video_format_t *fmt_src,
|
||||
bool has_dst_changed, const video_format_t *fmt_dst,
|
||||
mtime_t ts)
|
||||
{
|
||||
VLC_UNUSED(p_subpic); VLC_UNUSED(i_ts); VLC_UNUSED(p_fmt_src);
|
||||
VLC_UNUSED(has_dst_changed); VLC_UNUSED(p_fmt_dst);
|
||||
VLC_UNUSED(subpic); VLC_UNUSED(ts); VLC_UNUSED(fmt_src);
|
||||
VLC_UNUSED(has_dst_changed); VLC_UNUSED(fmt_dst);
|
||||
|
||||
if( !has_src_changed && !has_dst_changed)
|
||||
if (!has_src_changed && !has_dst_changed)
|
||||
return VLC_SUCCESS;
|
||||
return VLC_EGENERIC;
|
||||
}
|
||||
|
||||
static void OSDEpgUpdate( subpicture_t *p_subpic,
|
||||
const video_format_t *p_fmt_src,
|
||||
const video_format_t *p_fmt_dst,
|
||||
mtime_t i_ts )
|
||||
static void OSDEpgUpdate(subpicture_t *subpic,
|
||||
const video_format_t *fmt_src,
|
||||
const video_format_t *fmt_dst,
|
||||
mtime_t ts)
|
||||
{
|
||||
subpicture_updater_sys_t *p_sys = p_subpic->updater.p_sys;
|
||||
VLC_UNUSED(p_fmt_dst); VLC_UNUSED(i_ts);
|
||||
subpicture_updater_sys_t *sys = subpic->updater.p_sys;
|
||||
VLC_UNUSED(fmt_dst); VLC_UNUSED(ts);
|
||||
|
||||
p_subpic->i_original_picture_width = p_fmt_src->i_width;
|
||||
p_subpic->i_original_picture_height = p_fmt_src->i_height;
|
||||
p_subpic->p_region = vout_BuildOSDEpg( p_sys->p_epg,
|
||||
p_fmt_src->i_x_offset,
|
||||
p_fmt_src->i_y_offset,
|
||||
p_fmt_src->i_visible_width,
|
||||
p_fmt_src->i_visible_height );
|
||||
subpic->i_original_picture_width = fmt_src->i_width;
|
||||
subpic->i_original_picture_height = fmt_src->i_height;
|
||||
subpic->p_region = vout_BuildOSDEpg(sys->epg,
|
||||
fmt_src->i_x_offset,
|
||||
fmt_src->i_y_offset,
|
||||
fmt_src->i_visible_width,
|
||||
fmt_src->i_visible_height);
|
||||
}
|
||||
|
||||
static void OSDEpgDestroy( subpicture_t *p_subpic )
|
||||
static void OSDEpgDestroy(subpicture_t *subpic)
|
||||
{
|
||||
subpicture_updater_sys_t *p_sys = p_subpic->updater.p_sys;
|
||||
subpicture_updater_sys_t *sys = subpic->updater.p_sys;
|
||||
|
||||
vlc_epg_Delete( p_sys->p_epg );
|
||||
free( p_sys );
|
||||
vlc_epg_Delete(sys->epg);
|
||||
free(sys);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Show EPG information about the current program of an input item
|
||||
* \param p_vout pointer to the vout the information is to be showed on
|
||||
* \param vout pointer to the vout the information is to be showed on
|
||||
* \param p_input pointer to the input item the information is to be showed
|
||||
*/
|
||||
int vout_OSDEpg( vout_thread_t *p_vout, input_item_t *p_input )
|
||||
int vout_OSDEpg(vout_thread_t *vout, input_item_t *input)
|
||||
{
|
||||
subpicture_t *p_spu;
|
||||
mtime_t i_now = mdate();
|
||||
char *now_playing = input_item_GetNowPlaying(input);
|
||||
vlc_epg_t *epg = NULL;
|
||||
|
||||
char *psz_now_playing = input_item_GetNowPlaying( p_input );
|
||||
vlc_epg_t *p_epg = NULL;
|
||||
|
||||
vlc_mutex_lock( &p_input->lock );
|
||||
vlc_mutex_lock(&input->lock);
|
||||
|
||||
/* Look for the current program EPG event */
|
||||
for( int i = 0; i < p_input->i_epg; i++ )
|
||||
{
|
||||
vlc_epg_t *p_tmp = p_input->pp_epg[i];
|
||||
for (int i = 0; i < input->i_epg; i++) {
|
||||
vlc_epg_t *tmp = input->pp_epg[i];
|
||||
|
||||
if( p_tmp->p_current && p_tmp->p_current->psz_name
|
||||
&& psz_now_playing != NULL
|
||||
&& !strcmp( p_tmp->p_current->psz_name, psz_now_playing ) )
|
||||
{
|
||||
p_epg = vlc_epg_New( p_tmp->psz_name );
|
||||
vlc_epg_Merge( p_epg, p_tmp );
|
||||
if (tmp->p_current &&
|
||||
tmp->p_current->psz_name && now_playing != NULL &&
|
||||
!strcmp(tmp->p_current->psz_name, now_playing)) {
|
||||
epg = vlc_epg_New(tmp->psz_name);
|
||||
vlc_epg_Merge(epg, tmp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
vlc_mutex_unlock( &p_input->lock );
|
||||
vlc_mutex_unlock(&input->lock);
|
||||
|
||||
/* If no EPG event has been found. */
|
||||
if( p_epg == NULL )
|
||||
if (epg == NULL)
|
||||
return VLC_EGENERIC;
|
||||
|
||||
subpicture_updater_sys_t *p_sys = malloc( sizeof( *p_sys ) );
|
||||
if( !p_sys )
|
||||
{
|
||||
vlc_epg_Delete( p_epg );
|
||||
subpicture_updater_sys_t *sys = malloc(sizeof(*sys));
|
||||
if (!sys) {
|
||||
vlc_epg_Delete(epg);
|
||||
return VLC_EGENERIC;
|
||||
}
|
||||
p_sys->p_epg = p_epg;
|
||||
sys->epg = epg;
|
||||
subpicture_updater_t updater = {
|
||||
.pf_validate = OSDEpgValidate,
|
||||
.pf_update = OSDEpgUpdate,
|
||||
.pf_destroy = OSDEpgDestroy,
|
||||
.p_sys = p_sys
|
||||
.p_sys = sys
|
||||
};
|
||||
|
||||
p_spu = subpicture_New( &updater );
|
||||
if( !p_spu )
|
||||
{
|
||||
vlc_epg_Delete( p_sys->p_epg );
|
||||
free( p_sys );
|
||||
const mtime_t now = mdate();
|
||||
subpicture_t *subpic = subpicture_New(&updater);
|
||||
if (!subpic) {
|
||||
vlc_epg_Delete(sys->epg);
|
||||
free(sys);
|
||||
return VLC_EGENERIC;
|
||||
}
|
||||
|
||||
p_spu->i_channel = SPU_DEFAULT_CHANNEL;
|
||||
p_spu->i_start = i_now;
|
||||
p_spu->i_stop = i_now + 3000 * INT64_C(1000);
|
||||
p_spu->b_ephemer = true;
|
||||
p_spu->b_absolute = true;
|
||||
p_spu->b_fade = true;
|
||||
subpic->i_channel = SPU_DEFAULT_CHANNEL;
|
||||
subpic->i_start = now;
|
||||
subpic->i_stop = now + 3000 * INT64_C(1000);
|
||||
subpic->b_ephemer = true;
|
||||
subpic->b_absolute = true;
|
||||
subpic->b_fade = true;
|
||||
|
||||
vout_PutSubpicture( p_vout, p_spu );
|
||||
vout_PutSubpicture(vout, subpic);
|
||||
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue