Commit c26db46d authored by Laurent Aimar's avatar Laurent Aimar

No functionnal changes (vout).

K&R and removed variables prefixe.
parent 790c5845
...@@ -80,7 +80,7 @@ VLC_EXPORT( void, spu_PutSubpicture, ( spu_t *, subpicture_t * ) ); ...@@ -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(). * 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. * It registers a new SPU channel.
......
...@@ -55,207 +55,190 @@ static const char *deinterlace_modes[] = { ...@@ -55,207 +55,190 @@ static const char *deinterlace_modes[] = {
static bool DeinterlaceIsModeValid(const char *mode) static bool DeinterlaceIsModeValid(const char *mode)
{ {
for (unsigned i = 0; deinterlace_modes[i]; i++) { for (unsigned i = 0; deinterlace_modes[i]; i++) {
if( !strcmp(deinterlace_modes[i], mode)) if (!strcmp(deinterlace_modes[i], mode))
return true; return true;
} }
return false; 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 size_t module_length = strlen(module_name);
const char *psz_filter = psz_filter_base; const char *filter = filter_base;
if( !psz_filter || i_module <= 0 ) if (!filter || module_length <= 0)
return NULL; return NULL;
for( ;; ) for (;;) {
{ char *start = strstr(filter, module_name);
char *psz_find = strstr( psz_filter, psz_module ); if (!start)
if( !psz_find )
return NULL; return NULL;
if( psz_find[i_module] == '\0' || psz_find[i_module] == ':' ) if (start[module_length] == '\0' || start[module_length] == ':')
return psz_find; return start;
psz_filter = &psz_find[i_module]; 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" ); char *start = FilterFind(filter, "deinterlace");
if( !psz ) if (!start) {
{ free(filter);
free( psz_filter );
return; return;
} }
/* */ /* */
strcpy( &psz[0], &psz[strlen("deinterlace")] ); strcpy(&start[0], &start[strlen("deinterlace")]);
if( *psz == ':' ) if (*start == ':')
strcpy( &psz[0], &psz[1] ); strcpy(&start[0], &start[1]);
var_SetString( p_vout, "video-filter", psz_filter ); var_SetString(vout, "video-filter", filter);
free( psz_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" ) ) if (FilterFind(filter, "deinterlace")) {
{ free(filter);
free( psz_filter );
return; return;
} }
/* */ /* */
if( psz_filter ) if (filter) {
{ char *tmp = filter;
char *psz_tmp = psz_filter; if (asprintf(&filter, "%s:%s", tmp, "deinterlace") < 0)
if( asprintf( &psz_filter, "%s:%s", psz_tmp, "deinterlace" ) < 0 ) filter = tmp;
psz_filter = psz_tmp;
else else
free( psz_tmp ); free(tmp);
} } else {
else filter = strdup("deinterlace");
{
psz_filter = strdup( "deinterlace" );
} }
if( psz_filter ) if (filter) {
{ var_SetString(vout, "video-filter", filter);
var_SetString( p_vout, "video-filter", psz_filter ); free(filter);
free( psz_filter );
} }
} }
static int DeinterlaceCallback( vlc_object_t *p_this, char const *psz_cmd, static int DeinterlaceCallback(vlc_object_t *object, char const *cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data ) vlc_value_t oldval, vlc_value_t newval, void *data)
{ {
VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(newval); VLC_UNUSED(p_data); VLC_UNUSED(cmd); VLC_UNUSED(oldval); VLC_UNUSED(newval); VLC_UNUSED(data);
vout_thread_t *p_vout = (vout_thread_t *)p_this; vout_thread_t *vout = (vout_thread_t *)object;
/* */ /* */
const int i_deinterlace = var_GetInteger( p_this, "deinterlace" ); const int deinterlace_state = var_GetInteger(vout, "deinterlace");
char *psz_mode = var_GetString( p_this, "deinterlace-mode" ); char *mode = var_GetString(vout, "deinterlace-mode");
const bool is_needed = var_GetBool( p_this, "deinterlace-needed" ); const bool is_needed = var_GetBool(vout, "deinterlace-needed");
if( !psz_mode || !DeinterlaceIsModeValid(psz_mode) ) if (!mode || !DeinterlaceIsModeValid(mode))
return VLC_EGENERIC; return VLC_EGENERIC;
/* */ /* */
char *psz_old = var_CreateGetString( p_vout, "sout-deinterlace-mode" ); char *old = var_CreateGetString(vout, "sout-deinterlace-mode");
var_SetString( p_vout, "sout-deinterlace-mode", psz_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 ); msg_Dbg(vout, "deinterlace %d, mode %s, is_needed %d", deinterlace_state, mode, is_needed);
if( i_deinterlace == 0 || ( i_deinterlace == -1 && !is_needed ) ) if (deinterlace_state == 0 || (deinterlace_state == -1 && !is_needed))
{ DeinterlaceRemove(vout);
DeinterlaceRemove( p_vout ); else if (!DeinterlaceIsPresent(vout))
} DeinterlaceAdd(vout);
else if( !DeinterlaceIsPresent( p_vout ) ) else if (old && strcmp(old, mode))
{ var_TriggerCallback(vout, "video-filter");
DeinterlaceAdd( p_vout );
}
else if( psz_old && strcmp( psz_old, psz_mode ) )
{
var_TriggerCallback( p_vout, "video-filter" );
}
/* */ /* */
free( psz_old ); free(old);
free( psz_mode ); free(mode);
return VLC_SUCCESS; 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; vlc_value_t val, text;
msg_Dbg( p_vout, "Deinterlacing available" ); msg_Dbg(vout, "Deinterlacing available");
/* Create the configuration variables */ /* Create the configuration variables */
/* */ /* */
var_Create( p_vout, "deinterlace", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT | VLC_VAR_HASCHOICE ); var_Create(vout, "deinterlace", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT | VLC_VAR_HASCHOICE);
int i_deinterlace = var_GetInteger( p_vout, "deinterlace" ); int deinterlace_state = var_GetInteger(vout, "deinterlace");
i_deinterlace = __MAX( __MIN( i_deinterlace, 1 ), -1 ); deinterlace_state = __MAX(__MIN(deinterlace_state, 1), -1);
text.psz_string = _("Deinterlace"); 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" ); const module_config_t *optd = config_FindConfig(VLC_OBJECT(vout), "deinterlace");
var_Change( p_vout, "deinterlace", VLC_VAR_CLEARCHOICES, NULL, NULL ); var_Change(vout, "deinterlace", VLC_VAR_CLEARCHOICES, NULL, NULL);
for( int i = 0; p_optd && i < p_optd->i_list; i++ ) for (int i = 0; optd && i < optd->i_list; i++) {
{ val.i_int = optd->pi_list[i];
val.i_int = p_optd->pi_list[i]; text.psz_string = (char*)vlc_gettext(optd->ppsz_list_text[i]);
text.psz_string = (char*)vlc_gettext(p_optd->ppsz_list_text[i]); var_Change(vout, "deinterlace", VLC_VAR_ADDCHOICE, &val, &text);
var_Change( p_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 ); var_Create(vout, "deinterlace-mode", VLC_VAR_STRING | VLC_VAR_DOINHERIT | VLC_VAR_HASCHOICE);
char *psz_deinterlace = var_GetNonEmptyString( p_vout, "deinterlace-mode" ); char *deinterlace_mode = var_GetNonEmptyString(vout, "deinterlace-mode");
text.psz_string = _("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" ); const module_config_t *optm = config_FindConfig(VLC_OBJECT(vout), "deinterlace-mode");
var_Change( p_vout, "deinterlace-mode", VLC_VAR_CLEARCHOICES, NULL, NULL ); var_Change(vout, "deinterlace-mode", VLC_VAR_CLEARCHOICES, NULL, NULL);
for( int i = 0; p_optm && i < p_optm->i_list; i++ ) for (int i = 0; optm && i < optm->i_list; i++) {
{ if (!DeinterlaceIsModeValid(optm->ppsz_list[i]))
if( !DeinterlaceIsModeValid( p_optm->ppsz_list[i] ) )
continue; continue;
val.psz_string = p_optm->ppsz_list[i]; val.psz_string = optm->ppsz_list[i];
text.psz_string = (char*)vlc_gettext(p_optm->ppsz_list_text[i]); text.psz_string = (char*)vlc_gettext(optm->ppsz_list_text[i]);
var_Change( p_vout, "deinterlace-mode", VLC_VAR_ADDCHOICE, &val, &text ); 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_Create(vout, "deinterlace-needed", VLC_VAR_BOOL);
var_AddCallback( p_vout, "deinterlace-needed", DeinterlaceCallback, NULL ); var_AddCallback(vout, "deinterlace-needed", DeinterlaceCallback, NULL);
/* Override the initial value from filters if present */ /* Override the initial value from filters if present */
char *psz_filter_mode = NULL; char *filter_mode = NULL;
if( DeinterlaceIsPresent( p_vout ) ) if (DeinterlaceIsPresent(vout))
psz_filter_mode = var_CreateGetNonEmptyString( p_vout, "sout-deinterlace-mode" ); filter_mode = var_CreateGetNonEmptyString(vout, "sout-deinterlace-mode");
if( psz_filter_mode ) if (filter_mode) {
{ deinterlace_state = 1;
i_deinterlace = 1; free(deinterlace_mode);
free( psz_deinterlace ); deinterlace_mode = filter_mode;
psz_deinterlace = psz_filter_mode;
} }
/* */ /* */
val.psz_string = psz_deinterlace ? psz_deinterlace : p_optm->orig.psz; val.psz_string = deinterlace_mode ? deinterlace_mode : optm->orig.psz;
var_Change( p_vout, "deinterlace-mode", VLC_VAR_SETVALUE, &val, NULL ); var_Change(vout, "deinterlace-mode", VLC_VAR_SETVALUE, &val, NULL);
val.b_bool = is_interlaced; 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 ); var_SetInteger(vout, "deinterlace", deinterlace_state);
free( psz_deinterlace ); 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 */ /* Wait 30s before quiting interlacing mode */
const int interlacing_change = (!!is_interlaced) - (!!state->is_interlaced); const int interlacing_change = (!!is_interlaced) - (!!state->is_interlaced);
if ((interlacing_change == 1) || if ((interlacing_change == 1) ||
(interlacing_change == -1 && state->date + 30000000 < mdate())) { (interlacing_change == -1 && state->date + 30000000 < mdate())) {
msg_Dbg(vout, "Detected %s video",
msg_Dbg( p_vout, "Detected %s video", is_interlaced ? "interlaced" : "progressive");
is_interlaced ? "interlaced" : "progressive" ); var_SetBool(vout, "deinterlace-needed", is_interlaced);
var_SetBool( p_vout, "deinterlace-needed", is_interlaced );
state->is_interlaced = is_interlaced; state->is_interlaced = is_interlaced;
} }
......
...@@ -31,113 +31,101 @@ ...@@ -31,113 +31,101 @@
#include "postprocessing.h" #include "postprocessing.h"
static bool PostProcessIsPresent( const char *psz_filter ) static bool PostProcessIsPresent(const char *filter)
{ {
const char *psz_pp = "postproc"; const char *pp = "postproc";
const size_t i_pp = strlen(psz_pp); const size_t pp_length = strlen(pp);
return psz_filter && return filter &&
!strncmp( psz_filter, psz_pp, strlen(psz_pp) ) && !strncmp(filter, pp, strlen(pp)) &&
( psz_filter[i_pp] == '\0' || psz_filter[i_pp] == ':' ); (filter[pp_length] == '\0' || filter[pp_length] == ':');
} }
static int PostProcessCallback( vlc_object_t *p_this, char const *psz_cmd, static int PostProcessCallback(vlc_object_t *object, char const *cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data ) vlc_value_t oldval, vlc_value_t newval, void *data)
{ {
vout_thread_t *p_vout = (vout_thread_t *)p_this; vout_thread_t *vout = (vout_thread_t *)object;
VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data); 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 (newval.i_int <= 0) {
{ if (PostProcessIsPresent(filters)) {
if( PostProcessIsPresent( psz_vf2 ) ) strcpy(filters, &filters[strlen(pp)]);
{ if (*filters == ':')
strcpy( psz_vf2, &psz_vf2[strlen(psz_pp)] ); strcpy(filters, &filters[1]);
if( *psz_vf2 == ':' )
strcpy( psz_vf2, &psz_vf2[1] );
} }
} } else {
else if (!PostProcessIsPresent(filters)) {
{ if (filters) {
if( !PostProcessIsPresent( psz_vf2 ) ) char *tmp = filters;
{ if (asprintf(&filters, "%s:%s", pp, tmp) < 0)
if( psz_vf2 ) filters = tmp;
{
char *psz_tmp = psz_vf2;
if( asprintf( &psz_vf2, "%s:%s", psz_pp, psz_tmp ) < 0 )
psz_vf2 = psz_tmp;
else else
free( psz_tmp ); free(tmp);
} } else {
else filters = strdup(pp);
{
psz_vf2 = strdup( psz_pp );
} }
} }
} }
if( newval.i_int > 0 ) if (newval.i_int > 0)
var_SetInteger( p_vout, "postproc-q", newval.i_int ); var_SetInteger(vout, "postproc-q", newval.i_int);
if( psz_vf2 ) if (filters) {
{ var_SetString(vout, "video-filter", filters);
var_SetString( p_vout, "video-filter", psz_vf2 ); free(filters);
free( psz_vf2 ); } else if (newval.i_int > 0) {
} var_TriggerCallback(vout, "video-filter");
else if( newval.i_int > 0 )
{
var_TriggerCallback( p_vout, "video-filter" );
} }
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static void PostProcessEnable( vout_thread_t *p_vout ) static void PostProcessEnable(vout_thread_t *vout)
{ {
vlc_value_t text; vlc_value_t text;
msg_Dbg( p_vout, "Post-processing available" ); msg_Dbg(vout, "Post-processing available");
var_Create( p_vout, "postprocess", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ); var_Create(vout, "postprocess", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE);
text.psz_string = _("Post processing"); 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 val;
vlc_value_t text; vlc_value_t text;
char psz_text[1+1]; char tmp[1+1];
val.i_int = i; val.i_int = i;
snprintf( psz_text, sizeof(psz_text), "%d", i ); snprintf(tmp, sizeof(tmp), "%d", i);
if( i == 0 ) if (i == 0)
text.psz_string = _("Disable"); text.psz_string = _("Disable");
else else
text.psz_string = psz_text; text.psz_string = tmp;
var_Change( p_vout, "postprocess", VLC_VAR_ADDCHOICE, &val, &text ); 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" ); char *filters = var_GetNonEmptyString(vout, "video-filter");
int i_postproc_q = 0; int postproc_q = 0;
if( PostProcessIsPresent( psz_filter ) ) if (PostProcessIsPresent(filters))
i_postproc_q = var_CreateGetInteger( p_vout, "postproc-q" ); 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" ); msg_Dbg(vout, "Post-processing no more available");
var_Destroy( p_vout, "postprocess" ); var_Destroy(vout, "postprocess");
} }
void vout_SetPostProcessingState(vout_thread_t *vout, vout_postprocessing_support_t *state, int qtype) 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); const int postproc_change = (qtype != QTYPE_NONE) - (state->qtype != QTYPE_NONE);
if (postproc_change == 1) if (postproc_change == 1)
PostProcessEnable(vout); PostProcessEnable(vout);
else if (postproc_change == -1) else if (postproc_change == -1)
PostProcessDisable(vout); PostProcessDisable(vout);
if (postproc_change) if (postproc_change)
state->qtype = qtype; state->qtype = qtype;
} }
...@@ -37,285 +37,276 @@ ...@@ -37,285 +37,276 @@
#define EPG_NAME_SIZE 0.05 #define EPG_NAME_SIZE 0.05
#define EPG_PROGRAM_SIZE 0.03 #define EPG_PROGRAM_SIZE 0.03
static subpicture_region_t * vout_OSDEpgSlider( int i_x, int i_y, static subpicture_region_t * vout_OSDEpgSlider(int x, int y,
int i_width, int i_height, int width, int height,
float f_ratio ) float ratio)
{ {
video_format_t fmt; video_format_t fmt;
subpicture_region_t *p_region; subpicture_region_t *region;
/* Create a new subpicture region */ /* Create a new subpicture region */
video_format_Init( &fmt, VLC_CODEC_YUVA ); video_format_Init(&fmt, VLC_CODEC_YUVA);
fmt.i_width = fmt.i_visible_width = i_width;