static int Mouse( filter_t *p_filter, vlc_mouse_t *p_mouse, const vlc_mouse_t *p_old, const vlc_mouse_t *p_new ) { filter_sys_t *p_sys = p_filter->p_sys; vlc_mutex_lock( &p_sys->lock ); logo_t *p_logo = LogoListCurrent( &p_sys->list ); const picture_t *p_pic = p_logo->p_pic; if( p_pic ) { const video_format_t *p_fmt = &p_pic->format; const int i_logo_w = p_fmt->i_visible_width; const int i_logo_h = p_fmt->i_visible_height; /* Check if we are over the logo */ const bool b_over = p_new->i_x >= p_sys->i_pos_x && p_new->i_x < p_sys->i_pos_x + i_logo_w && p_new->i_y >= p_sys->i_pos_y && p_new->i_y < p_sys->i_pos_y + i_logo_h; if( b_over && vlc_mouse_HasPressed( p_old, p_new, MOUSE_BUTTON_LEFT ) ) p_sys->b_mouse_grab = true; else if( vlc_mouse_HasReleased( p_old, p_new, MOUSE_BUTTON_LEFT ) ) p_sys->b_mouse_grab = false; if( p_sys->b_mouse_grab ) { int i_dx, i_dy; vlc_mouse_GetMotion( &i_dx, &i_dy, p_old, p_new ); p_sys->i_pos_x = VLC_CLIP( p_sys->i_pos_x + i_dx, 0, p_filter->fmt_in.video.i_width - i_logo_w ); p_sys->i_pos_y = VLC_CLIP( p_sys->i_pos_y + i_dy, 0, p_filter->fmt_in.video.i_height - i_logo_h ); /* object under mouse has moved */ var_SetBool( p_filter->p_parent, "mouse-object", true ); } else if( b_over ) { /* object under mouse stoped moving */ var_SetBool( p_filter->p_parent, "mouse-object", false ); } if( p_sys->b_mouse_grab || b_over ) { vlc_mutex_unlock( &p_sys->lock ); return VLC_EGENERIC; } } vlc_mutex_unlock( &p_sys->lock ); *p_mouse = *p_new; return VLC_SUCCESS; }
/***************************************************************************** * Create: creates the module *****************************************************************************/ static int Create( vlc_object_t *p_this ) { filter_t *p_filter = (filter_t *)p_this; filter_sys_t *p_sys; char *psz_fontfile = NULL; vlc_value_t val; HDC hdc; /* Allocate structure */ p_filter->p_sys = p_sys = malloc( sizeof( filter_sys_t ) ); if( !p_sys ) return VLC_ENOMEM; p_sys->i_font_size = 0; p_sys->i_display_height = 0; var_Create( p_filter, "win32text-font", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_filter, "win32text-fontsize", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_filter, "win32text-rel-fontsize", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_filter, "win32text-opacity", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Get( p_filter, "win32text-opacity", &val ); p_sys->i_font_opacity = VLC_CLIP( val.i_int, 0, 255 ); var_Create( p_filter, "win32text-color", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Get( p_filter, "win32text-color", &val ); p_sys->i_font_color = VLC_CLIP( val.i_int, 0, 0xFFFFFF ); p_sys->hfont = p_sys->hfont_bak = 0; hdc = GetDC( NULL ); p_sys->hcdc = CreateCompatibleDC( hdc ); p_sys->i_logpy = GetDeviceCaps( hdc, LOGPIXELSY ); ReleaseDC( NULL, hdc ); SetBkMode( p_sys->hcdc, TRANSPARENT ); var_Get( p_filter, "win32text-fontsize", &val ); p_sys->i_default_font_size = val.i_int; if( SetFont( p_filter, 0 ) != VLC_SUCCESS ) goto error; free( psz_fontfile ); p_filter->pf_render_text = RenderText; p_filter->pf_render_html = NULL; return VLC_SUCCESS; error: free( psz_fontfile ); free( p_sys ); return VLC_EGENERIC; }
/***************************************************************************** * Callback to update params on the fly *****************************************************************************/ static int BarGraphCallback(vlc_object_t *p_this, char const *psz_var, vlc_value_t oldval, vlc_value_t newval, void *p_data) { VLC_UNUSED(p_this); VLC_UNUSED(oldval); filter_sys_t *p_sys = p_data; BarGraph_t *p_BarGraph = &p_sys->p_BarGraph; vlc_mutex_lock(&p_sys->lock); if (!strcmp(psz_var, CFG_PREFIX "x")) p_sys->i_pos_x = newval.i_int; else if (!strcmp(psz_var, CFG_PREFIX "y")) p_sys->i_pos_y = newval.i_int; else if (!strcmp(psz_var, CFG_PREFIX "position")) p_sys->i_pos = newval.i_int; else if (!strcmp(psz_var, CFG_PREFIX "transparency")) p_BarGraph->i_alpha = VLC_CLIP(newval.i_int, 0, 255); else if (!strcmp(psz_var, CFG_PREFIX "i_values")) { if (newval.psz_string) parse_i_values(p_BarGraph, newval.psz_string); Draw(p_BarGraph); } else if (!strcmp(psz_var, CFG_PREFIX "alarm")) { p_BarGraph->alarm = newval.b_bool; Draw(p_BarGraph); } else if (!strcmp(psz_var, CFG_PREFIX "barWidth")) { p_BarGraph->barWidth = newval.i_int; Draw(p_BarGraph); } else if (!strcmp(psz_var, CFG_PREFIX "barHeight")) { p_BarGraph->scale = newval.i_int; Draw(p_BarGraph); } p_sys->b_spu_update = true; vlc_mutex_unlock(&p_sys->lock); return VLC_SUCCESS; }
/***************************************************************************** * Volume related *****************************************************************************/ static int vlclua_volume_set( lua_State *L ) { playlist_t *p_this = vlclua_get_playlist_internal( L ); int i_volume = VLC_CLIP( luaL_checkint( L, 1 ), 0, AOUT_VOLUME_MAX ); int i_ret = aout_VolumeSet( p_this, i_volume ); return vlclua_push_ret( L, i_ret ); }
static picture_t *Filter(filter_t *filter, picture_t *src) { filter_sys_t *sys = filter->p_sys; picture_t *dst = filter_NewPicture(filter); if (!dst) { picture_Release(src); return NULL; } vlc_mutex_lock(&sys->lock); float strength = VLC_CLIP(sys->strength, STRENGTH_MIN, STRENGTH_MAX); int radius = VLC_CLIP((sys->radius + 1) & ~1, RADIUS_MIN, RADIUS_MAX); vlc_mutex_unlock(&sys->lock); const video_format_t *fmt = &filter->fmt_in.video; struct vf_priv_s *cfg = &sys->cfg; cfg->thresh = (1 << 15) / strength; if (cfg->radius != radius) { cfg->radius = radius; cfg->buf = aligned_alloc(16, (((fmt->i_width + 15) & ~15) * (cfg->radius + 1) / 2 + 32) * sizeof(*cfg->buf)); } for (int i = 0; i < dst->i_planes; i++) { const plane_t *srcp = &src->p[i]; plane_t *dstp = &dst->p[i]; const vlc_chroma_description_t *chroma = sys->chroma; int w = fmt->i_width * chroma->p[i].w.num / chroma->p[i].w.den; int h = fmt->i_height * chroma->p[i].h.num / chroma->p[i].h.den; int r = (cfg->radius * chroma->p[i].w.num / chroma->p[i].w.den + cfg->radius * chroma->p[i].h.num / chroma->p[i].h.den) / 2; r = VLC_CLIP((r + 1) & ~1, RADIUS_MIN, RADIUS_MAX); if (__MIN(w, h) > 2 * r && cfg->buf) { filter_plane(cfg, dstp->p_pixels, srcp->p_pixels, w, h, dstp->i_pitch, srcp->i_pitch, r); } else { plane_CopyPixels(dstp, srcp); } } picture_CopyProperties(dst, src); picture_Release(src); return dst; }
static int Control(demux_t *demux, int query, va_list args) { demux_sys_t *sys = demux->p_sys; switch (query) { case DEMUX_CAN_SEEK: *va_arg(args, bool *) = sys->duration >= 0 && !sys->is_realtime; return VLC_SUCCESS; case DEMUX_GET_POSITION: { double *position = va_arg(args, double *); if (sys->duration > 0) *position = date_Get(&sys->pts) / (double)sys->duration; else *position = 0; return VLC_SUCCESS; } case DEMUX_SET_POSITION: { if (sys->duration < 0 || sys->is_realtime) return VLC_EGENERIC; double position = va_arg(args, double); date_Set(&sys->pts, position * sys->duration); return VLC_SUCCESS; } case DEMUX_GET_TIME: { int64_t *time = va_arg(args, int64_t *); *time = sys->pts_origin + date_Get(&sys->pts); return VLC_SUCCESS; } case DEMUX_SET_TIME: { if (sys->duration < 0 || sys->is_realtime) return VLC_EGENERIC; int64_t time = va_arg(args, int64_t); date_Set(&sys->pts, VLC_CLIP(time - sys->pts_origin, 0, sys->duration)); return VLC_SUCCESS; } case DEMUX_SET_NEXT_DEMUX_TIME: { int64_t pts_next = VLC_TS_0 + va_arg(args, int64_t); if (sys->pts_next <= VLC_TS_INVALID) sys->pts_origin = pts_next; sys->pts_next = pts_next; return VLC_SUCCESS; } case DEMUX_GET_LENGTH: { int64_t *length = va_arg(args, int64_t *); *length = __MAX(sys->duration, 0); return VLC_SUCCESS; } case DEMUX_GET_FPS: { double *fps = va_arg(args, double *); *fps = (double)sys->pts.i_divider_num / sys->pts.i_divider_den; return VLC_SUCCESS; } case DEMUX_GET_META: case DEMUX_HAS_UNSUPPORTED_META: case DEMUX_GET_ATTACHMENTS: default: return VLC_EGENERIC; } }
static int MotionBlurCallback( vlc_object_t *p_this, char const *psz_var, vlc_value_t oldval, vlc_value_t newval, void *p_data ) { VLC_UNUSED(p_this); VLC_UNUSED(psz_var); VLC_UNUSED(oldval); filter_sys_t *p_sys = (filter_sys_t *)p_data; atomic_store( &p_sys->i_factor, VLC_CLIP( newval.i_int, 1, 127 ) ); return VLC_SUCCESS; }
static subpicture_region_t * vout_OSDEpgSlider(int x, int y, int width, int height, float ratio) { /* Create a new subpicture region */ video_palette_t palette = { // sunqueen modify start /*.i_entries =*/ 4, /*.palette =*/ { /*[0] =*/ { 0xff, 0x80, 0x80, 0x00 }, /*[1] =*/ { 0x00, 0x80, 0x80, 0x00 }, /*[2] =*/ { 0xff, 0x80, 0x80, 0xff }, /*[3] =*/ { 0x00, 0x80, 0x80, 0xff }, }, // sunqueen modify end }; video_format_t fmt; video_format_Init(&fmt, VLC_CODEC_YUVP); fmt.i_width = fmt.i_visible_width = width; fmt.i_height = fmt.i_visible_height = height; fmt.i_sar_num = 1; fmt.i_sar_den = 1; fmt.p_palette = &palette; subpicture_region_t *region = subpicture_region_New(&fmt); if (!region) return NULL; region->i_x = x; region->i_y = y; picture_t *picture = region->p_picture; ratio = VLC_CLIP(ratio, 0, 1); int filled_part_width = ratio * width; for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { /* Slider border. */ bool is_outline = j == 0 || j == height - 1 || i == 0 || i == width - 1; /* We can see the video through the part of the slider which corresponds to the leaving time. */ bool is_border = j < 3 || j > height - 4 || i < 3 || i > width - 4 || i < filled_part_width; picture->p->p_pixels[picture->p->i_pitch * j + i] = 2 * is_border + is_outline; } } return region; }
static int SharpenCallback( vlc_object_t *p_this, char const *psz_var, vlc_value_t oldval, vlc_value_t newval, void *p_data ) { VLC_UNUSED(p_this); VLC_UNUSED(oldval); VLC_UNUSED(psz_var); filter_sys_t *p_sys = (filter_sys_t *)p_data; atomic_store(&p_sys->sigma, VLC_CLIP(newval.f_float, 0.f, 2.f) * (1 << 20)); return VLC_SUCCESS; }
/***************************************************************************** * Callback to update params on the fly *****************************************************************************/ static int BluescreenCallback( vlc_object_t *p_this, char const *psz_var, vlc_value_t oldval, vlc_value_t newval, void *p_data ) { VLC_UNUSED(p_this); VLC_UNUSED(oldval); filter_sys_t *p_sys = (filter_sys_t *) p_data; vlc_mutex_lock( &p_sys->lock ); #define VAR_IS( a ) !strcmp( psz_var, CFG_PREFIX a ) if( VAR_IS( "u" ) ) p_sys->i_u = VLC_CLIP( newval.i_int, 0, 255 ); else if( VAR_IS( "v" ) ) p_sys->i_v = VLC_CLIP( newval.i_int, 0, 255 ); else if( VAR_IS( "ut" ) ) p_sys->i_ut = VLC_CLIP( newval.i_int, 0, 255 ); else if( VAR_IS( "vt" ) ) p_sys->i_vt = VLC_CLIP( newval.i_int, 0, 255 ); vlc_mutex_unlock( &p_sys->lock ); return VLC_SUCCESS; }
static int SharpenCallback( vlc_object_t *p_this, char const *psz_var, vlc_value_t oldval, vlc_value_t newval, void *p_data ) { VLC_UNUSED(p_this); VLC_UNUSED(oldval); VLC_UNUSED(psz_var); filter_sys_t *p_sys = (filter_sys_t *)p_data; vlc_mutex_lock( &p_sys->lock ); init_precalc_table( p_sys, VLC_CLIP( newval.f_float, 0., 2. ) ); vlc_mutex_unlock( &p_sys->lock ); return VLC_SUCCESS; }
static int MotionBlurCallback( vlc_object_t *p_this, char const *psz_var, vlc_value_t oldval, vlc_value_t newval, void *p_data ) { VLC_UNUSED(p_this); VLC_UNUSED(oldval); filter_sys_t *p_sys = (filter_sys_t *)p_data; if( !strcmp( psz_var, FILTER_PREFIX "factor" ) ) { vlc_spin_lock( &p_sys->lock ); p_sys->i_factor = VLC_CLIP( newval.i_int, 1, 127 ); vlc_spin_unlock( &p_sys->lock ); } return VLC_SUCCESS; }
static bool FindLength( demux_t *p_demux ) { demux_sys_t *p_sys = p_demux->p_sys; int64_t i_current_pos = -1, i_size = 0, i_end = 0; if( !var_CreateGetBool( p_demux, "ps-trust-timestamps" ) ) return true; if( p_sys->i_length == VLC_TICK_INVALID ) /* First time */ { p_sys->i_length = VLC_TICK_0; /* Check beginning */ int i = 0; i_current_pos = vlc_stream_Tell( p_demux->s ); while( i < 40 && Probe( p_demux, false ) > 0 ) i++; /* Check end */ i_size = stream_Size( p_demux->s ); i_end = VLC_CLIP( i_size, 0, 200000 ); if( vlc_stream_Seek( p_demux->s, i_size - i_end ) == VLC_SUCCESS ) { i = 0; while( i < 400 && Probe( p_demux, true ) > 0 ) i++; if( i_current_pos >= 0 && vlc_stream_Seek( p_demux->s, i_current_pos ) != VLC_SUCCESS ) return false; } else return false; } /* Find the longest track */ for( int i = 0; i < PS_TK_COUNT; i++ ) { ps_track_t *tk = &p_sys->tk[i]; if( tk->i_first_pts != VLC_TICK_INVALID && tk->i_last_pts > tk->i_first_pts ) { vlc_tick_t i_length = tk->i_last_pts - tk->i_first_pts; if( i_length > p_sys->i_length ) { p_sys->i_length = i_length; p_sys->i_time_track_index = i; msg_Dbg( p_demux, "we found a length of: %"PRId64 "s", SEC_FROM_VLC_TICK(p_sys->i_length) ); } } } return true; }
static ssize_t AStreamReadNoSeekStream(stream_t *s, void *buf, size_t len) { stream_sys_t *sys = s->p_sys; stream_track_t *tk = &sys->tk[sys->i_tk]; if (tk->i_start >= tk->i_end) return 0; /* EOF */ #ifdef STREAM_DEBUG msg_Dbg(s, "AStreamReadStream: %zd pos=%"PRId64" tk=%d start=%"PRId64 " offset=%d end=%"PRId64, len, sys->i_pos, sys->i_tk, tk->i_start, sys->i_offset, tk->i_end); #endif unsigned i_off = (tk->i_start + sys->i_offset) % STREAM_CACHE_TRACK_SIZE; size_t i_current = __MIN(tk->i_end - tk->i_start - sys->i_offset, STREAM_CACHE_TRACK_SIZE - i_off); ssize_t i_copy = __MIN(i_current, len); if (i_copy <= 0) return 0; /* EOF */ /* Copy data */ /* msg_Dbg(s, "AStreamReadStream: copy %zd", i_copy); */ if (buf != NULL) memcpy(buf, &tk->p_buffer[i_off], i_copy); sys->i_offset += i_copy; /* Update pos now */ sys->i_pos += i_copy; /* */ sys->i_used += i_copy; if (tk->i_end + i_copy <= tk->i_start + sys->i_offset + len) { const size_t i_read_requested = VLC_CLIP(len - i_copy, STREAM_READ_ATONCE / 2, STREAM_READ_ATONCE * 10); if (sys->i_used < i_read_requested) sys->i_used = i_read_requested; AStreamRefillStream(s); } return i_copy; }
/***************************************************************************** * parse_i_values : parse i_values parameter and store the corresponding values *****************************************************************************/ void parse_i_values( BarGraph_t *p_BarGraph, char *i_values) { char* res = NULL; char delim[] = ":"; char* tok; p_BarGraph->nbChannels = 0; p_BarGraph->i_values = NULL; res = strtok_r(i_values, delim, &tok); while (res != NULL) { p_BarGraph->nbChannels++; p_BarGraph->i_values = xrealloc(p_BarGraph->i_values, p_BarGraph->nbChannels*sizeof(int)); p_BarGraph->i_values[p_BarGraph->nbChannels-1] = VLC_CLIP( atof(res)*p_BarGraph->scale, 0, p_BarGraph->scale ); res = strtok_r(NULL, delim, &tok); } }
/** * Common open function */ static int OpenCommon(vlc_object_t *p_this, bool b_sub) { filter_t *p_filter = (filter_t *)p_this; filter_sys_t *p_sys; /* */ if (!b_sub && !es_format_IsSimilar(&p_filter->fmt_in, &p_filter->fmt_out)) { msg_Err(p_filter, "Input and output format does not match"); return VLC_EGENERIC; } /* */ p_filter->p_sys = p_sys = malloc(sizeof(*p_sys)); if (!p_sys) return VLC_ENOMEM; /* */ p_sys->p_blend = NULL; if (!b_sub) { p_sys->p_blend = filter_NewBlend(VLC_OBJECT(p_filter), &p_filter->fmt_in.video); if (!p_sys->p_blend) { free(p_sys); return VLC_EGENERIC; } } /* */ config_ChainParse(p_filter, CFG_PREFIX, ppsz_filter_options, p_filter->p_cfg); /* create and initialize variables */ p_sys->i_pos = var_CreateGetInteger(p_filter, CFG_PREFIX "position"); p_sys->i_pos_x = var_CreateGetInteger(p_filter, CFG_PREFIX "x"); p_sys->i_pos_y = var_CreateGetInteger(p_filter, CFG_PREFIX "y"); BarGraph_t *p_BarGraph = &p_sys->p_BarGraph; p_BarGraph->p_pic = NULL; p_BarGraph->i_alpha = var_CreateGetInteger(p_filter, CFG_PREFIX "transparency"); p_BarGraph->i_alpha = VLC_CLIP(p_BarGraph->i_alpha, 0, 255); p_BarGraph->i_values = NULL; parse_i_values(p_BarGraph, &(char){ 0 });
/***************************************************************************** * parse_i_values : parse i_values parameter and store the corresponding values *****************************************************************************/ void parse_i_values( BarGraph_t *p_BarGraph, char *i_values) { char* res = NULL; char delim[] = ":"; char* tok; float db; p_BarGraph->nbChannels = 0; p_BarGraph->i_values = NULL; res = strtok_r(i_values, delim, &tok); while (res != NULL) { p_BarGraph->nbChannels++; p_BarGraph->i_values = (int *)xrealloc(p_BarGraph->i_values, p_BarGraph->nbChannels*sizeof(int)); // sunqueen modify db = log10(atof(res)) * 20; p_BarGraph->i_values[p_BarGraph->nbChannels-1] = VLC_CLIP( iec_scale(db)*p_BarGraph->scale, 0, p_BarGraph->scale ); res = strtok_r(NULL, delim, &tok); } }
/***************************************************************************** * Callback to update params on the fly *****************************************************************************/ static int BarGraphCallback(vlc_object_t *p_this, char const *psz_var, vlc_value_t oldval, vlc_value_t newval, void *p_data) { VLC_UNUSED(p_this); VLC_UNUSED(oldval); filter_sys_t *p_sys = p_data; BarGraph_t *p_BarGraph = &p_sys->p_BarGraph; char* res = NULL; vlc_mutex_lock(&p_sys->lock); if (!strcmp(psz_var, CFG_PREFIX "x")) p_sys->i_pos_x = newval.i_int; else if (!strcmp(psz_var, CFG_PREFIX "y")) p_sys->i_pos_y = newval.i_int; else if (!strcmp(psz_var, CFG_PREFIX "position")) p_sys->i_pos = newval.i_int; else if (!strcmp(psz_var, CFG_PREFIX "transparency")) p_BarGraph->i_alpha = VLC_CLIP(newval.i_int, 0, 255); else if (!strcmp(psz_var, CFG_PREFIX "i_values")) { char *psz = xstrdup(newval.psz_string ? newval.psz_string : ""); // in case many answer are received at the same time, only keep one res = strchr(psz, '@'); if (res) *res = '\0'; parse_i_values(p_BarGraph, psz); free(psz); Draw(p_BarGraph); } else if (!strcmp(psz_var, CFG_PREFIX "alarm")) { p_BarGraph->alarm = newval.b_bool; Draw(p_BarGraph); } else if (!strcmp(psz_var, CFG_PREFIX "barWidth")) { p_BarGraph->barWidth = newval.i_int; Draw(p_BarGraph); } else if (!strcmp(psz_var, CFG_PREFIX "barHeight")) { p_BarGraph->scale = newval.i_int; Draw(p_BarGraph); } p_sys->b_spu_update = true; vlc_mutex_unlock(&p_sys->lock); return VLC_SUCCESS; }
/***************************************************************************** * Callback to update params on the fly *****************************************************************************/ static int LogoCallback( vlc_object_t *p_this, char const *psz_var, vlc_value_t oldval, vlc_value_t newval, void *p_data ) { VLC_UNUSED(oldval); filter_sys_t *p_sys = (filter_sys_t *)p_data; logo_list_t *p_list = &p_sys->list; vlc_mutex_lock( &p_sys->lock ); if( !strcmp( psz_var, "logo-file" ) ) { LogoListUnload( p_list ); LogoListLoad( p_this, p_list, newval.psz_string ); } else if ( !strcmp( psz_var, "logo-x" ) ) { p_sys->i_pos_x = newval.i_int; } else if ( !strcmp( psz_var, "logo-y" ) ) { p_sys->i_pos_y = newval.i_int; } else if ( !strcmp( psz_var, "logo-position" ) ) { p_sys->i_pos = newval.i_int; } else if ( !strcmp( psz_var, "logo-opacity" ) ) { p_list->i_alpha = VLC_CLIP( newval.i_int, 0, 255 ); } else if ( !strcmp( psz_var, "logo-repeat" ) ) { p_list->i_repeat = newval.i_int; } p_sys->b_spu_update = true; vlc_mutex_unlock( &p_sys->lock ); return VLC_SUCCESS; }
/***************************************************************************** * Callback to update params on the fly *****************************************************************************/ static int BarGraphCallback( vlc_object_t *p_this, char const *psz_var, vlc_value_t oldval, vlc_value_t newval, void *p_data ) { VLC_UNUSED(oldval); filter_sys_t *p_sys = (filter_sys_t *)p_data; BarGraph_t *p_BarGraph = &(p_sys->p_BarGraph); char* res = NULL; vlc_mutex_lock( &p_sys->lock ); if ( !strcmp( psz_var, "audiobargraph_v-x" ) ) { p_sys->i_pos_x = newval.i_int; } else if ( !strcmp( psz_var, "audiobargraph_v-y" ) ) { p_sys->i_pos_y = newval.i_int; } else if ( !strcmp( psz_var, "audiobargraph_v-position" ) ) { p_sys->i_pos = newval.i_int; } else if ( !strcmp( psz_var, "audiobargraph_v-transparency" ) ) { p_BarGraph->i_alpha = VLC_CLIP( newval.i_int, 0, 255 ); } else if ( !strcmp( psz_var, "audiobargraph_v-i_values" ) ) { if( p_BarGraph->p_pic ) { picture_Release( p_BarGraph->p_pic ); p_BarGraph->p_pic = NULL; } char *psz_i_values = strdup( newval.psz_string ); free(p_BarGraph->i_values); //p_BarGraph->i_values = NULL; //p_BarGraph->nbChannels = 0; // in case many answer are received at the same time, only keep one res = strchr(psz_i_values, '@'); if (res) *res = 0; parse_i_values( p_BarGraph, psz_i_values); free( psz_i_values ); LoadBarGraph(p_this,p_BarGraph); } else if ( !strcmp( psz_var, "audiobargraph_v-alarm" ) ) { if( p_BarGraph->p_pic ) { picture_Release( p_BarGraph->p_pic ); p_BarGraph->p_pic = NULL; } p_BarGraph->alarm = newval.i_int; LoadBarGraph(p_this,p_BarGraph); } else if ( !strcmp( psz_var, "audiobargraph_v-barWidth" ) ) { if( p_BarGraph->p_pic ) { picture_Release( p_BarGraph->p_pic ); p_BarGraph->p_pic = NULL; } p_BarGraph->barWidth = newval.i_int; LoadBarGraph(p_this,p_BarGraph); } p_sys->b_spu_update = true; vlc_mutex_unlock( &p_sys->lock ); return VLC_SUCCESS; }
/** * Common open function */ static int OpenCommon( vlc_object_t *p_this, bool b_sub ) { filter_t *p_filter = (filter_t *)p_this; filter_sys_t *p_sys; BarGraph_t *p_BarGraph; char* i_values = NULL; /* */ if( !b_sub && !es_format_IsSimilar( &p_filter->fmt_in, &p_filter->fmt_out ) ) { msg_Err( p_filter, "Input and output format does not match" ); return VLC_EGENERIC; } /* */ p_filter->p_sys = p_sys = malloc( sizeof( *p_sys ) ); if( !p_sys ) return VLC_ENOMEM; p_BarGraph = &(p_sys->p_BarGraph); /* */ p_sys->p_blend = NULL; if( !b_sub ) { p_sys->p_blend = filter_NewBlend( VLC_OBJECT(p_filter), &p_filter->fmt_in.video ); if( !p_sys->p_blend ) { //free( p_BarGraph ); free( p_sys ); return VLC_EGENERIC; } } /* */ config_ChainParse( p_filter, CFG_PREFIX, ppsz_filter_options, p_filter->p_cfg ); /* create and initialize variables */ p_sys->i_pos = var_CreateGetIntegerCommand( p_filter, "audiobargraph_v-position" ); p_sys->i_pos_x = var_CreateGetIntegerCommand( p_filter, "audiobargraph_v-x" ); p_sys->i_pos_y = var_CreateGetIntegerCommand( p_filter, "audiobargraph_v-y" ); p_BarGraph->i_alpha = var_CreateGetIntegerCommand( p_filter, "audiobargraph_v-transparency" ); p_BarGraph->i_alpha = VLC_CLIP( p_BarGraph->i_alpha, 0, 255 ); i_values = var_CreateGetStringCommand( p_filter, "audiobargraph_v-i_values" ); //p_BarGraph->nbChannels = 0; //p_BarGraph->i_values = NULL; parse_i_values(p_BarGraph, i_values); p_BarGraph->alarm = var_CreateGetIntegerCommand( p_filter, "audiobargraph_v-alarm" ); p_BarGraph->barWidth = var_CreateGetIntegerCommand( p_filter, "audiobargraph_v-barWidth" ); p_BarGraph->scale = 400; /* Ignore aligment if a position is given for video filter */ if( !b_sub && p_sys->i_pos_x >= 0 && p_sys->i_pos_y >= 0 ) p_sys->i_pos = 0; vlc_mutex_init( &p_sys->lock ); LoadBarGraph( p_this, p_BarGraph ); p_sys->b_spu_update = true; for( int i = 0; ppsz_filter_callbacks[i]; i++ ) var_AddCallback( p_filter, ppsz_filter_callbacks[i], BarGraphCallback, p_sys ); /* Misc init */ if( b_sub ) { p_filter->pf_sub_source = FilterSub; } else { p_filter->pf_video_filter = FilterVideo; } free( i_values ); return VLC_SUCCESS; }
static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out, subpicture_region_t *p_region_in, const vlc_fourcc_t *p_chroma_list ) { filter_sys_t *p_sys = p_filter->p_sys; int i_font_color, i_font_alpha, i_font_size; uint8_t *p_bitmap; TCHAR *psz_string; int i, i_width, i_height; HBITMAP bitmap, bitmap_bak; BITMAPINFO *p_bmi; RECT rect = { 0, 0, 0, 0 }; /* Sanity check */ if( !p_region_in || !p_region_out ) return VLC_EGENERIC; if( !p_region_in->psz_text || !*p_region_in->psz_text ) return VLC_EGENERIC; psz_string = ToT(p_region_in->psz_text); if( psz_string == NULL ) return VLC_EGENERIC; if( !*psz_string ) { free( psz_string ); return VLC_EGENERIC; } if( p_region_in->p_style ) { i_font_color = VLC_CLIP( p_region_in->p_style->i_font_color, 0, 0xFFFFFF ); i_font_alpha = VLC_CLIP( p_region_in->p_style->i_font_alpha, 0, 255 ); i_font_size = VLC_CLIP( p_region_in->p_style->i_font_size, 0, 255 ); } else { i_font_color = p_sys->i_font_color; i_font_alpha = 255 - p_sys->i_font_opacity; i_font_size = p_sys->i_default_font_size; } SetFont( p_filter, i_font_size ); SetTextColor( p_sys->hcdc, RGB( (i_font_color >> 16) & 0xff, (i_font_color >> 8) & 0xff, i_font_color & 0xff) ); DrawText( p_sys->hcdc, psz_string, -1, &rect, DT_CALCRECT | DT_CENTER | DT_NOPREFIX ); i_width = rect.right; i_height = rect.bottom; p_bmi = malloc(sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*16); memset( p_bmi, 0, sizeof(BITMAPINFOHEADER) ); p_bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); p_bmi->bmiHeader.biWidth = (i_width+3) & ~3; p_bmi->bmiHeader.biHeight = - i_height; p_bmi->bmiHeader.biPlanes = 1; p_bmi->bmiHeader.biBitCount = 8; p_bmi->bmiHeader.biCompression = BI_RGB; p_bmi->bmiHeader.biClrUsed = 16; for( i = 0; i < 16; i++ ) { p_bmi->bmiColors[i].rgbBlue = p_bmi->bmiColors[i].rgbGreen = p_bmi->bmiColors[i].rgbRed = pi_gamma[i]; } bitmap = CreateDIBSection( p_sys->hcdc, p_bmi, DIB_RGB_COLORS, (void **)&p_bitmap, NULL, 0 ); if( !bitmap ) { msg_Err( p_filter, "could not create bitmap" ); free( psz_string ); return VLC_EGENERIC; } bitmap_bak = SelectObject( p_sys->hcdc, bitmap ); FillRect( p_sys->hcdc, &rect, (HBRUSH)GetStockObject(BLACK_BRUSH) ); if( !DrawText( p_sys->hcdc, psz_string, -1, &rect, DT_CENTER | DT_NOPREFIX ) ) { msg_Err( p_filter, "could not draw text" ); } p_region_out->i_x = p_region_in->i_x; p_region_out->i_y = p_region_in->i_y; Render( p_filter, p_region_out, p_bitmap, i_width, i_height ); SelectObject( p_sys->hcdc, bitmap_bak ); DeleteObject( bitmap ); free( psz_string ); return VLC_SUCCESS; }
/* * Load the glyphs of a paragraph. When shaping with HarfBuzz the glyph indices * have already been determined at this point, as well as the advance values. */ static int LoadGlyphs( filter_t *p_filter, paragraph_t *p_paragraph, bool b_use_glyph_indices, bool b_overwrite_advance ) { if( p_paragraph->i_size <= 0 || p_paragraph->i_runs_count <= 0 ) { msg_Err( p_filter, "LoadGlyphs() invalid parameters. " "Paragraph size: %d. Runs count %d", p_paragraph->i_size, p_paragraph->i_runs_count ); return VLC_EGENERIC; } filter_sys_t *p_sys = p_filter->p_sys; for( int i = 0; i < p_paragraph->i_runs_count; ++i ) { run_desc_t *p_run = p_paragraph->p_runs + i; text_style_t *p_style = p_run->p_style; FT_Face p_face = 0; if( !p_run->p_face ) { p_face = LoadFace( p_filter, p_style ); if( !p_face ) { p_face = p_sys->p_face; p_style = &p_sys->style; p_run->p_style = p_style; } p_run->p_face = p_face; } else p_face = p_run->p_face; if( p_sys->p_stroker ) { double f_outline_thickness = var_InheritInteger( p_filter, "freetype-outline-thickness" ) / 100.0; f_outline_thickness = VLC_CLIP( f_outline_thickness, 0.0, 0.5 ); int i_radius = ( p_style->i_font_size << 6 ) * f_outline_thickness; FT_Stroker_Set( p_sys->p_stroker, i_radius, FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0 ); } for( int j = p_run->i_start_offset; j < p_run->i_end_offset; ++j ) { int i_glyph_index; if( b_use_glyph_indices ) i_glyph_index = p_paragraph->pi_glyph_indices[ j ]; else i_glyph_index = FT_Get_Char_Index( p_face, p_paragraph->p_code_points[ j ] ); glyph_bitmaps_t *p_bitmaps = p_paragraph->p_glyph_bitmaps + j; if( FT_Load_Glyph( p_face, i_glyph_index, FT_LOAD_NO_BITMAP | FT_LOAD_DEFAULT ) && FT_Load_Glyph( p_face, i_glyph_index, FT_LOAD_DEFAULT ) ) { p_bitmaps->p_glyph = 0; p_bitmaps->p_outline = 0; p_bitmaps->p_shadow = 0; p_bitmaps->i_x_advance = 0; p_bitmaps->i_y_advance = 0; continue; } if( ( p_style->i_style_flags & STYLE_BOLD ) && !( p_face->style_flags & FT_STYLE_FLAG_BOLD ) ) FT_GlyphSlot_Embolden( p_face->glyph ); if( ( p_style->i_style_flags & STYLE_ITALIC ) && !( p_face->style_flags & FT_STYLE_FLAG_ITALIC ) ) FT_GlyphSlot_Oblique( p_face->glyph ); if( FT_Get_Glyph( p_face->glyph, &p_bitmaps->p_glyph ) ) { p_bitmaps->p_glyph = 0; p_bitmaps->p_outline = 0; p_bitmaps->p_shadow = 0; p_bitmaps->i_x_advance = 0; p_bitmaps->i_y_advance = 0; continue; } if( p_filter->p_sys->p_stroker ) { p_bitmaps->p_outline = p_bitmaps->p_glyph; if( FT_Glyph_StrokeBorder( &p_bitmaps->p_outline, p_filter->p_sys->p_stroker, 0, 0 ) ) p_bitmaps->p_outline = 0; } if( p_filter->p_sys->style.i_shadow_alpha > 0 ) p_bitmaps->p_shadow = p_bitmaps->p_outline ? p_bitmaps->p_outline : p_bitmaps->p_glyph; if( b_overwrite_advance ) { p_bitmaps->i_x_advance = p_face->glyph->advance.x; p_bitmaps->i_y_advance = p_face->glyph->advance.y; } } } return VLC_SUCCESS; }
void vout_InitInterlacingSupport(vout_thread_t *vout, bool is_interlaced) { vlc_value_t val, text; msg_Dbg(vout, "Deinterlacing available"); /* Create the configuration variables */ /* */ var_Create(vout, "deinterlace", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT | VLC_VAR_HASCHOICE); int deinterlace_state = var_GetInteger(vout, "deinterlace"); deinterlace_state = VLC_CLIP(deinterlace_state, -1, 1); text.psz_string = _("Deinterlace"); var_Change(vout, "deinterlace", VLC_VAR_SETTEXT, &text, NULL); const module_config_t *optd = config_FindConfig(VLC_OBJECT(vout), "deinterlace"); var_Change(vout, "deinterlace", VLC_VAR_CLEARCHOICES, NULL, NULL); if (likely(optd != NULL)) for (unsigned i = 0; i < optd->list_count; i++) { val.i_int = optd->list.i[i]; text.psz_string = vlc_gettext(optd->list_text[i]); var_Change(vout, "deinterlace", VLC_VAR_ADDCHOICE, &val, &text); } var_AddCallback(vout, "deinterlace", DeinterlaceCallback, NULL); /* */ 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(vout, "deinterlace-mode", VLC_VAR_SETTEXT, &text, NULL); const module_config_t *optm = config_FindConfig(VLC_OBJECT(vout), "deinterlace-mode"); var_Change(vout, "deinterlace-mode", VLC_VAR_CLEARCHOICES, NULL, NULL); if (likely(optm != NULL)) for (unsigned i = 0; i < optm->list_count; i++) { if (!DeinterlaceIsModeValid(optm->list.psz[i])) continue; val.psz_string = optm->list.psz[i]; text.psz_string = vlc_gettext(optm->list_text[i]); var_Change(vout, "deinterlace-mode", VLC_VAR_ADDCHOICE, &val, &text); } var_AddCallback(vout, "deinterlace-mode", 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 *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 = deinterlace_mode ? deinterlace_mode : optm->orig.psz; var_Change(vout, "deinterlace-mode", VLC_VAR_SETVALUE, &val, NULL); val.b_bool = is_interlaced; var_Change(vout, "deinterlace-needed", VLC_VAR_SETVALUE, &val, NULL); var_SetInteger(vout, "deinterlace", deinterlace_state); free(deinterlace_mode); }
/***************************************************************************** * Open: allocates Wall video thread output method ***************************************************************************** * This function allocates and initializes a Wall vout method. *****************************************************************************/ static int Open( vlc_object_t *p_this ) { video_splitter_t *p_splitter = (video_splitter_t*)p_this; video_splitter_sys_t *p_sys; const panoramix_chroma_t *p_chroma; for( int i = 0; ; i++ ) { vlc_fourcc_t i_chroma = p_chroma_array[i].i_chroma; if( !i_chroma ) { msg_Err( p_splitter, "colorspace not supported by plug-in !" ); return VLC_EGENERIC; } if( i_chroma == p_splitter->fmt.i_chroma ) { p_chroma = &p_chroma_array[i]; break; } } /* Allocate structure */ p_splitter->p_sys = p_sys = malloc( sizeof( *p_sys ) ); if( !p_sys ) return VLC_ENOMEM; /* */ p_sys->p_chroma = p_chroma; /* */ config_ChainParse( p_splitter, CFG_PREFIX, ppsz_filter_options, p_splitter->p_cfg ); /* */ p_sys->i_col = var_InheritInteger( p_splitter, CFG_PREFIX "cols" ); p_sys->i_row = var_InheritInteger( p_splitter, CFG_PREFIX "rows" ); /* Autodetect number of displays */ if( p_sys->i_col < 0 || p_sys->i_row < 0 ) { #ifdef WIN32 const int i_monitor_count = GetSystemMetrics(SM_CMONITORS); if( i_monitor_count > 1 ) { p_sys->i_col = GetSystemMetrics( SM_CXVIRTUALSCREEN ) / GetSystemMetrics( SM_CXSCREEN ); p_sys->i_row = GetSystemMetrics( SM_CYVIRTUALSCREEN ) / GetSystemMetrics( SM_CYSCREEN ); if( p_sys->i_col * p_sys->i_row != i_monitor_count ) { p_sys->i_col = i_monitor_count; p_sys->i_row = 1; } } #else const unsigned i_monitors = CountMonitors( p_this ); if( i_monitors > 1 ) /* Find closest to square */ for( unsigned w = 1; (i_monitors / w) >= w ; w++ ) { if( i_monitors % w ) continue; p_sys->i_row = w; p_sys->i_col = i_monitors / w; } #endif /* By default do 2x1 */ if( p_sys->i_row < 0 ) p_sys->i_row = 1; if( p_sys->i_col < 0 ) p_sys->i_col = 2; var_SetInteger( p_splitter, CFG_PREFIX "cols", p_sys->i_col); var_SetInteger( p_splitter, CFG_PREFIX "rows", p_sys->i_row); } /* */ p_sys->b_attenuate = var_InheritBool( p_splitter, CFG_PREFIX "attenuate"); p_sys->bz_length = var_InheritInteger( p_splitter, CFG_PREFIX "bz-length" ); p_sys->bz_height = var_InheritInteger( p_splitter, CFG_PREFIX "bz-height" ); p_sys->bz_begin = var_InheritInteger( p_splitter, CFG_PREFIX "bz-begin" ); p_sys->bz_middle = var_InheritInteger( p_splitter, CFG_PREFIX "bz-middle" ); p_sys->bz_end = var_InheritInteger( p_splitter, CFG_PREFIX "bz-end" ); p_sys->bz_middle_pos = var_InheritInteger( p_splitter, CFG_PREFIX "bz-middle-pos" ); double d_p = 100.0 / p_sys->bz_middle_pos; p_sys->a_2 = d_p * p_sys->bz_begin - (double)(d_p * d_p / (d_p - 1)) * p_sys->bz_middle + (double)(d_p / (d_p - 1)) * p_sys->bz_end; p_sys->a_1 = -(d_p + 1) * p_sys->bz_begin + (double)(d_p * d_p / (d_p - 1)) * p_sys->bz_middle - (double)(1 / (d_p - 1)) * p_sys->bz_end; p_sys->a_0 = p_sys->bz_begin; /* */ p_sys->i_col = VLC_CLIP( COL_MAX, 1, p_sys->i_col ); p_sys->i_row = VLC_CLIP( ROW_MAX, 1, p_sys->i_row ); msg_Dbg( p_splitter, "opening a %i x %i wall", p_sys->i_col, p_sys->i_row ); if( p_sys->bz_length > 0 && ( p_sys->i_row > 1 || p_sys->i_col > 1 ) ) { const int i_overlap_w2_max = p_splitter->fmt.i_width / p_sys->i_col / 2; const int i_overlap_h2_max = p_splitter->fmt.i_height / p_sys->i_row / 2; const int i_overlap2_max = __MIN( i_overlap_w2_max, i_overlap_h2_max ); if( p_sys->i_col > 1 ) p_sys->i_overlap_w2 = i_overlap2_max * p_sys->bz_length / 100; else p_sys->i_overlap_w2 = 0; if( p_sys->i_row > 1 ) p_sys->i_overlap_h2 = i_overlap2_max * p_sys->bz_height / 100; else p_sys->i_overlap_h2 = 0; /* */ int i_div_max_w = 1; int i_div_max_h = 1; for( int i = 0; i < VOUT_MAX_PLANES; i++ ) { i_div_max_w = __MAX( i_div_max_w, p_chroma->pi_div_w[i] ); i_div_max_h = __MAX( i_div_max_h, p_chroma->pi_div_h[i] ); } p_sys->i_overlap_w2 = i_div_max_w * (p_sys->i_overlap_w2 / i_div_max_w); p_sys->i_overlap_h2 = i_div_max_h * (p_sys->i_overlap_h2 / i_div_max_h); } else { p_sys->i_overlap_w2 = 0; p_sys->i_overlap_h2 = 0; } /* Compute attenuate parameters */ if( p_sys->b_attenuate ) { panoramix_gamma_t p_gamma[VOUT_MAX_PLANES]; p_gamma[0].f_gamma = var_InheritFloat( p_splitter, CFG_PREFIX "bz-gamma-red" ); p_gamma[1].f_gamma = var_InheritFloat( p_splitter, CFG_PREFIX "bz-gamma-green" ); p_gamma[2].f_gamma = var_InheritFloat( p_splitter, CFG_PREFIX "bz-gamma-blue" ); p_gamma[0].f_black_crush = var_InheritInteger( p_splitter, CFG_PREFIX "bz-blackcrush-red" ) / 255.0; p_gamma[1].f_black_crush = var_InheritInteger( p_splitter, CFG_PREFIX "bz-blackcrush-green" ) / 255.0; p_gamma[2].f_black_crush = var_InheritInteger( p_splitter, CFG_PREFIX "bz-blackcrush-blue" ) / 255.0; p_gamma[0].f_white_crush = var_InheritInteger( p_splitter, CFG_PREFIX "bz-whitecrush-red" ) / 255.0; p_gamma[1].f_white_crush = var_InheritInteger( p_splitter, CFG_PREFIX "bz-whitecrush-green" ) / 255.0; p_gamma[2].f_white_crush = var_InheritInteger( p_splitter, CFG_PREFIX "bz-whitecrush-blue" ) / 255.0; p_gamma[0].f_black_level = var_InheritInteger( p_splitter, CFG_PREFIX "bz-blacklevel-red" ) / 255.0; p_gamma[1].f_black_level = var_InheritInteger( p_splitter, CFG_PREFIX "bz-blacklevel-green" ) / 255.0; p_gamma[2].f_black_level = var_InheritInteger( p_splitter, CFG_PREFIX "bz-blacklevel-blue" ) / 255.0; p_gamma[0].f_white_level = var_InheritInteger( p_splitter, CFG_PREFIX "bz-whitelevel-red" ) / 255.0; p_gamma[1].f_white_level = var_InheritInteger( p_splitter, CFG_PREFIX "bz-whitelevel-green" ) / 255.0; p_gamma[2].f_white_level = var_InheritInteger( p_splitter, CFG_PREFIX "bz-whitelevel-blue" ) / 255.0; for( int i = 3; i < VOUT_MAX_PLANES; i++ ) { /* Initialize unsupported planes */ p_gamma[i].f_gamma = 1.0; p_gamma[i].f_black_crush = 140.0/255.0; p_gamma[i].f_white_crush = 200.0/255.0; p_gamma[i].f_black_level = 150.0/255.0; p_gamma[i].f_white_level = 0.0/255.0; } if( p_chroma->i_chroma == VLC_CODEC_YV12 ) { /* Exchange U and V */ panoramix_gamma_t t = p_gamma[1]; p_gamma[1] = p_gamma[2]; p_gamma[2] = t; } for( int i_index = 0; i_index < 256; i_index++ ) { for( int i_index2 = 0; i_index2 <= ACCURACY; i_index2++ ) { for( int i_plane = 0; i_plane < VOUT_MAX_PLANES; i_plane++ ) { double f_factor = GammaFactor( &p_gamma[i_plane], (float)i_index / 255.0 ); float f_lut = clip_unit( 1.0 - ((ACCURACY - (float)i_index2) * f_factor / (ACCURACY - 1)) ); p_sys->p_lut[i_plane][i_index2][i_index] = f_lut * i_index + (int)( (1.0 - f_lut) * (float)p_chroma->pi_black[i_plane] ); } } } for( int i_plane = 0; i_plane < VOUT_MAX_PLANES; i_plane++ ) { if( !p_chroma->pi_div_w[i_plane] || !p_chroma->pi_div_h[i_plane] ) continue; const int i_length_w = (2 * p_sys->i_overlap_w2) / p_chroma->pi_div_w[i_plane]; const int i_length_h = (2 * p_sys->i_overlap_h2) / p_chroma->pi_div_h[i_plane]; for( int i_dir = 0; i_dir < 2; i_dir++ ) { const int i_length = i_dir == 0 ? i_length_w : i_length_h; const int i_den = i_length * i_length; const int a_2 = p_sys->a_2 * (ACCURACY / 100); const int a_1 = p_sys->a_1 * i_length * (ACCURACY / 100); const int a_0 = p_sys->a_0 * i_den * (ACCURACY / 100); for( int i_position = 0; i_position < 2; i_position++ ) { for( int i_index = 0; i_index < i_length; i_index++ ) { const int v = i_position == 1 ? i_index : (i_length - i_index); const int i_lambda = clip_accuracy( ACCURACY - (a_2 * v*v + a_1 * v + a_0) / i_den ); if( i_dir == 0 ) p_sys->lambdav[i_plane][i_position][i_index] = i_lambda; else p_sys->lambdah[i_plane][i_position][i_index] = i_lambda; } } } } } /* */ char *psz_state = var_InheritString( p_splitter, CFG_PREFIX "active" ); /* */ bool pb_active[COL_MAX*ROW_MAX]; for( int i = 0; i < COL_MAX*ROW_MAX; i++ ) pb_active[i] = psz_state == NULL; /* Parse active list if provided */ char *psz_tmp = psz_state; while( psz_tmp && *psz_tmp ) { char *psz_next = strchr( psz_tmp, ',' ); if( psz_next ) *psz_next++ = '\0'; const int i_index = atoi( psz_tmp ); if( i_index >= 0 && i_index < COL_MAX*ROW_MAX ) pb_active[i_index] = true; psz_tmp = psz_next; } free( psz_state ); /* */ p_splitter->i_output = Configuration( p_sys->pp_output, p_sys->i_col, p_sys->i_row, p_splitter->fmt.i_width, p_splitter->fmt.i_height, p_sys->i_overlap_w2, p_sys->i_overlap_h2, p_sys->b_attenuate, pb_active ); p_splitter->p_output = calloc( p_splitter->i_output, sizeof(*p_splitter->p_output) ); if( !p_splitter->p_output ) { free( p_sys ); return VLC_ENOMEM; } for( int y = 0; y < p_sys->i_row; y++ ) { for( int x = 0; x < p_sys->i_col; x++ ) { panoramix_output_t *p_output = &p_sys->pp_output[x][y]; if( !p_output->b_active ) continue; video_splitter_output_t *p_cfg = &p_splitter->p_output[p_output->i_output]; /* */ video_format_Copy( &p_cfg->fmt, &p_splitter->fmt ); p_cfg->fmt.i_visible_width = p_cfg->fmt.i_width = p_output->i_width; p_cfg->fmt.i_visible_height = p_cfg->fmt.i_height = p_output->i_height; p_cfg->window.i_x = p_output->i_x; p_cfg->window.i_y = p_output->i_y; p_cfg->window.i_align = p_output->i_align; p_cfg->psz_module = NULL; } } /* */ p_splitter->pf_filter = Filter; p_splitter->pf_mouse = Mouse; return VLC_SUCCESS; }
/***************************************************************************** * Callback to update params on the fly *****************************************************************************/ static int MosaicCallback( vlc_object_t *p_this, char const *psz_var, vlc_value_t oldval, vlc_value_t newval, void *p_data ) { VLC_UNUSED(oldval); filter_sys_t *p_sys = (filter_sys_t *) p_data; #define VAR_IS( a ) !strcmp( psz_var, CFG_PREFIX a ) if( VAR_IS( "alpha" ) ) { vlc_mutex_lock( &p_sys->lock ); msg_Dbg( p_this, "changing alpha from %d/255 to %d/255", p_sys->i_alpha, (int)newval.i_int); p_sys->i_alpha = VLC_CLIP( newval.i_int, 0, 255 ); vlc_mutex_unlock( &p_sys->lock ); } else if( VAR_IS( "height" ) ) { vlc_mutex_lock( &p_sys->lock ); msg_Dbg( p_this, "changing height from %dpx to %dpx", p_sys->i_height, (int)newval.i_int ); p_sys->i_height = __MAX( newval.i_int, 0 ); vlc_mutex_unlock( &p_sys->lock ); } else if( VAR_IS( "width" ) ) { vlc_mutex_lock( &p_sys->lock ); msg_Dbg( p_this, "changing width from %dpx to %dpx", p_sys->i_width, (int)newval.i_int ); p_sys->i_width = __MAX( newval.i_int, 0 ); vlc_mutex_unlock( &p_sys->lock ); } else if( VAR_IS( "xoffset" ) ) { vlc_mutex_lock( &p_sys->lock ); msg_Dbg( p_this, "changing x offset from %dpx to %dpx", p_sys->i_xoffset, (int)newval.i_int ); p_sys->i_xoffset = __MAX( newval.i_int, 0 ); vlc_mutex_unlock( &p_sys->lock ); } else if( VAR_IS( "yoffset" ) ) { vlc_mutex_lock( &p_sys->lock ); msg_Dbg( p_this, "changing y offset from %dpx to %dpx", p_sys->i_yoffset, (int)newval.i_int ); p_sys->i_yoffset = __MAX( newval.i_int, 0 ); vlc_mutex_unlock( &p_sys->lock ); } else if( VAR_IS( "align" ) ) { int i_old = 0, i_new = 0; vlc_mutex_lock( &p_sys->lock ); newval.i_int = VLC_CLIP( newval.i_int, 0, 10 ); if( newval.i_int == 3 || newval.i_int == 7 ) newval.i_int = 5; while( pi_align_values[i_old] != p_sys->i_align ) i_old++; while( pi_align_values[i_new] != newval.i_int ) i_new++; msg_Dbg( p_this, "changing alignment from %d (%s) to %d (%s)", p_sys->i_align, ppsz_align_descriptions[i_old], (int)newval.i_int, ppsz_align_descriptions[i_new] ); p_sys->i_align = newval.i_int; vlc_mutex_unlock( &p_sys->lock ); } else if( VAR_IS( "borderw" ) ) { vlc_mutex_lock( &p_sys->lock ); msg_Dbg( p_this, "changing border width from %dpx to %dpx", p_sys->i_borderw, (int)newval.i_int ); p_sys->i_borderw = __MAX( newval.i_int, 0 ); vlc_mutex_unlock( &p_sys->lock ); } else if( VAR_IS( "borderh" ) ) { vlc_mutex_lock( &p_sys->lock ); msg_Dbg( p_this, "changing border height from %dpx to %dpx", p_sys->i_borderh, (int)newval.i_int ); p_sys->i_borderh = __MAX( newval.i_int, 0 ); vlc_mutex_unlock( &p_sys->lock ); } else if( VAR_IS( "position" ) ) { if( newval.i_int > 2 || newval.i_int < 0 ) { msg_Err( p_this, "Position is either 0 (%s), 1 (%s) or 2 (%s)", ppsz_pos_descriptions[0], ppsz_pos_descriptions[1], ppsz_pos_descriptions[2] ); } else { vlc_mutex_lock( &p_sys->lock ); msg_Dbg( p_this, "changing position method from %d (%s) to %d (%s)", p_sys->i_position, ppsz_pos_descriptions[p_sys->i_position], (int)newval.i_int, ppsz_pos_descriptions[newval.i_int]); p_sys->i_position = newval.i_int; vlc_mutex_unlock( &p_sys->lock ); } } else if( VAR_IS( "rows" ) ) { vlc_mutex_lock( &p_sys->lock ); msg_Dbg( p_this, "changing number of rows from %d to %d", p_sys->i_rows, (int)newval.i_int ); p_sys->i_rows = __MAX( newval.i_int, 1 ); vlc_mutex_unlock( &p_sys->lock ); } else if( VAR_IS( "cols" ) ) { vlc_mutex_lock( &p_sys->lock ); msg_Dbg( p_this, "changing number of columns from %d to %d", p_sys->i_cols, (int)newval.i_int ); p_sys->i_cols = __MAX( newval.i_int, 1 ); vlc_mutex_unlock( &p_sys->lock ); } else if( VAR_IS( "order" ) ) { char *psz_order; int i_index; vlc_mutex_lock( &p_sys->lock ); msg_Dbg( p_this, "Changing mosaic order to %s", newval.psz_string ); psz_order = newval.psz_string; while( p_sys->i_order_length-- ) { free( p_sys->ppsz_order[p_sys->i_order_length] ); } free( p_sys->ppsz_order ); p_sys->ppsz_order = NULL; if( *psz_order ) { char *psz_end = NULL; i_index = 0; do { psz_end = strchr( psz_order, ',' ); i_index++; p_sys->ppsz_order = (char **)xrealloc( p_sys->ppsz_order, i_index * sizeof(char *) ); // sunqueen modify p_sys->ppsz_order[i_index - 1] = strndup( psz_order, psz_end - psz_order ); psz_order = psz_end+1; } while( psz_end ); p_sys->i_order_length = i_index; } vlc_mutex_unlock( &p_sys->lock ); } else if( VAR_IS( "offsets" ) ) { vlc_mutex_lock( &p_sys->lock ); msg_Info( p_this, "Changing mosaic-offsets to %s", newval.psz_string ); if( p_sys->i_offsets_length != 0 ) { p_sys->i_offsets_length = 0; free( p_sys->pi_x_offsets ); free( p_sys->pi_y_offsets ); p_sys->pi_x_offsets = NULL; p_sys->pi_y_offsets = NULL; } mosaic_ParseSetOffsets( p_this, p_sys, newval.psz_string ); vlc_mutex_unlock( &p_sys->lock ); } else if( VAR_IS( "keep-aspect-ratio" ) ) { vlc_mutex_lock( &p_sys->lock ); if( newval.i_int ) { msg_Dbg( p_this, "keeping aspect ratio" ); p_sys->b_ar = 1; } else { msg_Dbg( p_this, "won't keep aspect ratio" ); p_sys->b_ar = 0; } vlc_mutex_unlock( &p_sys->lock ); } else if( VAR_IS( "keep-picture" ) ) { vlc_mutex_lock( &p_sys->lock ); p_sys->b_keep = newval.b_bool; if ( !p_sys->b_keep && !p_sys->p_image ) { p_sys->p_image = image_HandlerCreate( p_this ); } vlc_mutex_unlock( &p_sys->lock ); } return VLC_SUCCESS; }
/* Out create */ return VLCRET( audio_out_create( p_sys->i_rate, p_sys->i_channel, p_sys->i_sample_type, SOUND_TYPE_MEDIA, &p_sys->out ) ); } static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict p_fmt ) { aout_sys_t *p_sys = p_aout->sys; aout_FormatPrint( p_aout, "Tizen audio is looking for:", p_fmt ); /* Sample rate: tizen accept rate between 8000 and 48000 Hz */ p_sys->i_rate = p_fmt->i_rate = VLC_CLIP( p_fmt->i_rate, 8000, 48000 ); /* Channel */ switch( p_fmt->i_physical_channels ) { case AOUT_CHAN_LEFT: p_sys->i_channel = AUDIO_CHANNEL_MONO; break; default: case AOUT_CHANS_STEREO: p_fmt->i_physical_channels = AOUT_CHANS_STEREO; p_sys->i_channel = AUDIO_CHANNEL_STEREO; break; } /* Sample type */
/** * Common open function */ static int OpenCommon( vlc_object_t *p_this, bool b_sub ) { filter_t *p_filter = (filter_t *)p_this; filter_sys_t *p_sys; char *psz_filename; /* */ if( !b_sub && !es_format_IsSimilar( &p_filter->fmt_in, &p_filter->fmt_out ) ) { msg_Err( p_filter, "Input and output format does not match" ); return VLC_EGENERIC; } /* */ p_filter->p_sys = p_sys = malloc( sizeof( *p_sys ) ); if( !p_sys ) return VLC_ENOMEM; /* */ p_sys->p_blend = NULL; if( !b_sub ) { p_sys->p_blend = filter_NewBlend( VLC_OBJECT(p_filter), &p_filter->fmt_in.video ); if( !p_sys->p_blend ) { free( p_sys ); return VLC_EGENERIC; } } /* */ config_ChainParse( p_filter, CFG_PREFIX, ppsz_filter_options, p_filter->p_cfg ); /* */ logo_list_t *p_list = &p_sys->list; psz_filename = var_CreateGetStringCommand( p_filter, "logo-file" ); if( !psz_filename ) { if( p_sys->p_blend ) filter_DeleteBlend( p_sys->p_blend ); free( p_sys ); return VLC_ENOMEM; } if( *psz_filename == '\0' ) msg_Warn( p_this, "no logo file specified" ); p_list->i_alpha = var_CreateGetIntegerCommand( p_filter, "logo-opacity"); p_list->i_alpha = VLC_CLIP( p_list->i_alpha, 0, 255 ); p_list->i_delay = var_CreateGetIntegerCommand( p_filter, "logo-delay" ); p_list->i_repeat = var_CreateGetIntegerCommand( p_filter, "logo-repeat" ); p_sys->i_pos = var_CreateGetIntegerCommand( p_filter, "logo-position" ); p_sys->i_pos_x = var_CreateGetIntegerCommand( p_filter, "logo-x" ); p_sys->i_pos_y = var_CreateGetIntegerCommand( p_filter, "logo-y" ); p_sys->b_absolute = (p_sys->i_pos < 0); /* Ignore aligment if a position is given for video filter */ if( !b_sub && p_sys->i_pos_x >= 0 && p_sys->i_pos_y >= 0 ) p_sys->i_pos = 0; vlc_mutex_init( &p_sys->lock ); LogoListLoad( p_this, p_list, psz_filename ); p_sys->b_spu_update = true; p_sys->b_mouse_grab = false; for( int i = 0; ppsz_filter_callbacks[i]; i++ ) var_AddCallback( p_filter, ppsz_filter_callbacks[i], LogoCallback, p_sys ); /* Misc init */ if( b_sub ) { p_filter->pf_sub_source = FilterSub; } else { p_filter->pf_video_filter = FilterVideo; p_filter->pf_video_mouse = Mouse; } free( psz_filename ); return VLC_SUCCESS; }