VLC 4.0.0-dev
Loading...
Searching...
No Matches
vout_subpictures.c File Reference
Include dependency graph for vout_subpictures.c:

Data Structures

struct  spu_render_entry_t
struct  spu_render_vector
struct  spu_channel
struct  spu_channel_vector
struct  spu_prerender_vector
struct  subtitle_position_cache
struct  subtitles_positions_vector
struct  spu_private_t
struct  spu_scale_t
struct  spu_area_t
 A few area functions helpers. More...
struct  sub_source

Macros

#define SPU_CHROMALIST_COUNT   10
#define SCALE_UNIT   (10000)
 A few scale functions helpers.

Typedefs

typedef struct spu_private_t spu_private_t

Functions

static void spu_PrerenderCancel (spu_private_t *, const subpicture_t *)
static void spu_channel_Init (struct spu_channel *channel, size_t id, enum vlc_vout_order order, vlc_clock_t *clock)
static int spu_channel_Push (struct spu_channel *channel, subpicture_t *subpic, vlc_tick_t orgstart, vlc_tick_t orgstop)
static void spu_Channel_CleanEntry (spu_private_t *sys, spu_render_entry_t *entry)
static void spu_channel_Clean (spu_private_t *sys, struct spu_channel *channel)
static bool spu_HasAlreadyExpired (vlc_tick_t start, vlc_tick_t stop, vlc_tick_t system_now)
static void spu_channel_EarlyRemoveLate (spu_private_t *sys, struct spu_channel *channel, vlc_tick_t system_now)
static struct spu_channelspu_GetChannel (spu_t *spu, size_t channel_id, size_t *index)
static ssize_t spu_GetFreeChannelId (spu_t *spu, enum vlc_vout_order *order)
static int spu_get_attachments (filter_t *filter, input_attachment_t ***attachment_ptr, int *attachment_count)
static filter_tSpuRenderCreateAndLoadText (spu_t *spu)
static filter_tSpuRenderCreateAndLoadScale (vlc_object_t *object, vlc_fourcc_t src_chroma, vlc_fourcc_t dst_chroma, bool require_resize)
static void region_FixFmt (subpicture_region_t *region)
static subpicture_region_tSpuRenderText (spu_t *spu, const subpicture_region_t *region, unsigned output_width, unsigned output_height, const vlc_fourcc_t *chroma_list)
static spu_scale_t spu_scale_create (unsigned w, unsigned h)
static spu_scale_t spu_scale_unit (void)
static spu_scale_t spu_scale_createq (uint64_t wn, uint64_t wd, uint64_t hn, uint64_t hd)
static int spu_scale_w (int v, const spu_scale_t s)
static int spu_scale_h (int v, const spu_scale_t s)
static int spu_invscale_w (int v, const spu_scale_t s)
static int spu_invscale_h (int v, const spu_scale_t s)
static spu_area_t spu_area_create (int x, int y, int w, int h, spu_scale_t s)
static spu_area_t spu_area_scaled (spu_area_t a)
static spu_area_t spu_area_unscaled (spu_area_t a, spu_scale_t s)
static bool spu_area_overlap (spu_area_t a, spu_area_t b)
static void SpuAreaFixOverlap (spu_area_t *dst, const spu_area_t *sub_array, size_t sub_count, int align)
 Avoid area overlapping.
static void SpuAreaMoveInside (spu_area_t *area, const unsigned boundary_width, const unsigned boundary_height)
static void subtitles_positions_StartUpdate (subtitles_positions_vector *subs)
static void subtitles_positions_FinishUpdate (subtitles_positions_vector *subs)
static struct subtitle_position_cachesubtitles_positions_FindRelativeRegion (const subtitles_positions_vector *subs, const subpicture_region_t *region)
static void subtitles_positions_AddRelativeRegion (subtitles_positions_vector *subs, const subpicture_region_t *region, const spu_area_t *area, struct subtitle_position_cache *write)
static void SpuRegionPlace (int *x, int *y, const subpicture_t *subpic, const subpicture_region_t *region, int i_align)
 Place a region.
static int IntegerCmp (int64_t i0, int64_t i1)
 This function compares two 64 bits integers.
static int SSizeCmp (ssize_t i0, ssize_t i1)
static int SpuRenderCmp (const void *s0, const void *s1)
 This function compares 2 subpictures using the following properties (ordered by priority).
static size_t spu_channel_UpdateDates (struct spu_channel *channel, vlc_tick_t system_now)
static bool spu_render_entry_IsSelected (spu_render_entry_t *render_entry, size_t channel_id, vlc_tick_t render_date, bool ignore_osd)
static spu_render_entry_tspu_SelectSubpictures (spu_t *spu, vlc_tick_t system_now, vlc_tick_t render_subtitle_date, bool ignore_osd, size_t *subpicture_count)
static struct subpicture_region_renderedSpuRenderRegion (spu_t *spu, spu_area_t *dst_area, subpicture_t *subpic, enum vlc_vout_order channel_order, subpicture_region_t *region, const spu_scale_t scale_size, bool apply_scale, const vlc_fourcc_t *chroma_list, const unsigned output_x, const unsigned output_y, const unsigned output_width, const unsigned output_height, const spu_area_t *subtitle_area, size_t subtitle_area_count, vlc_tick_t render_date)
 It will transform the provided region into another region suitable for rendering.
static void spu_UpdateOriginalSize (spu_t *spu, subpicture_t *subpic, const video_format_t *fmtsrc)
static vlc_render_subpictureSpuRenderSubpictures (spu_t *spu, size_t i_subpicture, const spu_render_entry_t *p_entries, const vlc_fourcc_t *chroma_list, const video_format_t *fmt_dst, const video_format_t *fmt_src, bool spu_in_full_window, const vout_display_place_t *video_position, vlc_tick_t system_now, vlc_tick_t render_subtitle_date, bool external_scale)
 This function renders all sub picture units in the list.
static void SetHighlights (spu_t *spu, const vlc_spu_highlight_t *hl)
static subpicture_tsub_new_buffer (filter_t *filter)
static int SubSourceInit (filter_t *filter, void *data)
static int SubSourceClean (filter_t *filter, void *data)
static int RestartSubFilterCallback (vlc_object_t *obj, char const *psz_var, vlc_value_t oldval, vlc_value_t newval, void *p_data)
static int SubFilterAddProxyCallbacks (filter_t *filter, void *opaque)
static int SubFilterDelProxyCallbacks (filter_t *filter, void *opaque)
static int RestartSubSourceCallback (vlc_object_t *obj, char const *psz_var, vlc_value_t oldval, vlc_value_t newval, void *p_data)
static int SubSourceAddProxyCallbacks (filter_t *filter, void *opaque)
static int SubSourceDelProxyCallbacks (filter_t *filter, void *opaque)
static void spu_PrerenderWake (spu_private_t *sys, const video_format_t *fmt_dst, const video_format_t *fmt_src, bool spu_in_full_window, const vout_display_place_t *video_position, const vlc_fourcc_t *chroma_list)
static void spu_PrerenderEnqueue (spu_private_t *sys, subpicture_t *p_subpic)
static void spu_PrerenderPause (spu_private_t *sys)
static void spu_PrerenderSync (spu_private_t *sys, const subpicture_t *p_subpic)
static void spu_PrerenderText (spu_t *spu, subpicture_t *p_subpic, const vlc_fourcc_t *chroma_list)
static void * spu_PrerenderThread (void *priv)
static void spu_Cleanup (spu_t *spu)
void spu_Destroy (spu_t *spu)
 Destroy the subpicture unit.
spu_tspu_Create (vlc_object_t *object, vout_thread_t *vout)
 Creates the subpicture unit.
void spu_Attach (spu_t *spu, input_thread_t *input)
 Attach the SPU to an input.
void spu_Detach (spu_t *spu)
 Detach the SPU from its attached input.
void spu_SetClockDelay (spu_t *spu, size_t channel_id, vlc_tick_t delay)
void spu_SetClockRate (spu_t *spu, size_t channel_id, float rate)
static int SubFilter (filter_t *p_filter, void *opaque)
void spu_PutSubpicture (spu_t *spu, subpicture_t *subpic)
 Display a subpicture.
static int SubSourceGenerate (filter_t *p_filter, void *opaque)
 Generate subpictures from a chain of subpicture source "filters".
vlc_render_subpicturespu_Render (spu_t *spu, const vlc_fourcc_t *chroma_list, const video_format_t *fmt_dst, const video_format_t *fmt_src, bool spu_in_full_window, const vout_display_place_t *video_position, vlc_tick_t system_now, vlc_tick_t render_subtitle_date, bool ignore_osd)
ssize_t spu_RegisterChannelInternal (spu_t *spu, vlc_clock_t *clock, enum vlc_vout_order *order)
ssize_t spu_RegisterChannel (spu_t *spu)
 It registers a new SPU channel.
void spu_ClearChannel (spu_t *spu, size_t channel_id)
 It clears all subpictures associated to a SPU channel.
void spu_UnregisterChannel (spu_t *spu, size_t channel_id)
void spu_ChangeSources (spu_t *spu, const char *filters)
 It changes the sub sources list.
void spu_ChangeFilters (spu_t *spu, const char *filters)
 It changes the sub filters list.
void spu_ChangeChannelOrderMargin (spu_t *spu, enum vlc_vout_order order, int margin)
void spu_SetHighlight (spu_t *spu, const vlc_spu_highlight_t *hl)

Variables

static const struct filter_subpicture_callbacks sub_cbs

Macro Definition Documentation

◆ SCALE_UNIT

#define SCALE_UNIT   (10000)

◆ SPU_CHROMALIST_COUNT

#define SPU_CHROMALIST_COUNT   10

Typedef Documentation

◆ spu_private_t

typedef struct spu_private_t spu_private_t

Function Documentation

◆ IntegerCmp()

int IntegerCmp ( int64_t i0,
int64_t i1 )
static

This function compares two 64 bits integers.

It can be used by qsort.

Referenced by SpuRenderCmp().

◆ region_FixFmt()

◆ RestartSubFilterCallback()

int RestartSubFilterCallback ( vlc_object_t * obj,
char const * psz_var,
vlc_value_t oldval,
vlc_value_t newval,
void * p_data )
static

◆ RestartSubSourceCallback()

int RestartSubSourceCallback ( vlc_object_t * obj,
char const * psz_var,
vlc_value_t oldval,
vlc_value_t newval,
void * p_data )
static

◆ SetHighlights()

◆ spu_area_create()

spu_area_t spu_area_create ( int x,
int y,
int w,
int h,
spu_scale_t s )
static

Referenced by SpuRenderRegion().

◆ spu_area_overlap()

bool spu_area_overlap ( spu_area_t a,
spu_area_t b )
static

◆ spu_area_scaled()

◆ spu_area_unscaled()

◆ spu_Attach()

◆ spu_ChangeChannelOrderMargin()

◆ spu_channel_Clean()

void spu_channel_Clean ( spu_private_t * sys,
struct spu_channel * channel )
static

◆ spu_Channel_CleanEntry()

void spu_Channel_CleanEntry ( spu_private_t * sys,
spu_render_entry_t * entry )
static

◆ spu_channel_EarlyRemoveLate()

◆ spu_channel_Init()

void spu_channel_Init ( struct spu_channel * channel,
size_t id,
enum vlc_vout_order order,
vlc_clock_t * clock )
static

◆ spu_channel_Push()

int spu_channel_Push ( struct spu_channel * channel,
subpicture_t * subpic,
vlc_tick_t orgstart,
vlc_tick_t orgstop )
static

◆ spu_channel_UpdateDates()

◆ spu_Cleanup()

◆ spu_Detach()

void spu_Detach ( spu_t * spu)

Detach the SPU from its attached input.

References container_of, spu_private_t::input, spu_private_t::lock, spu_PrerenderPause(), vlc_mutex_lock(), and vlc_mutex_unlock().

Referenced by vout_ReleaseDisplay().

◆ spu_get_attachments()

int spu_get_attachments ( filter_t * filter,
input_attachment_t *** attachment_ptr,
int * attachment_count )
static

◆ spu_GetChannel()

◆ spu_GetFreeChannelId()

◆ spu_HasAlreadyExpired()

bool spu_HasAlreadyExpired ( vlc_tick_t start,
vlc_tick_t stop,
vlc_tick_t system_now )
static

◆ spu_invscale_h()

int spu_invscale_h ( int v,
const spu_scale_t s )
static

References spu_scale_t::h, and SCALE_UNIT.

Referenced by spu_area_unscaled(), and SpuRenderRegion().

◆ spu_invscale_w()

int spu_invscale_w ( int v,
const spu_scale_t s )
static

References SCALE_UNIT, and spu_scale_t::w.

Referenced by spu_area_unscaled(), and SpuRenderRegion().

◆ spu_PrerenderCancel()

◆ spu_PrerenderEnqueue()

◆ spu_PrerenderPause()

◆ spu_PrerenderSync()

◆ spu_PrerenderText()

◆ spu_PrerenderThread()

◆ spu_PrerenderWake()

◆ spu_RegisterChannelInternal()

◆ spu_Render()

◆ spu_render_entry_IsSelected()

bool spu_render_entry_IsSelected ( spu_render_entry_t * render_entry,
size_t channel_id,
vlc_tick_t render_date,
bool ignore_osd )
static

◆ spu_scale_create()

spu_scale_t spu_scale_create ( unsigned w,
unsigned h )
static

◆ spu_scale_createq()

spu_scale_t spu_scale_createq ( uint64_t wn,
uint64_t wd,
uint64_t hn,
uint64_t hd )
static

References SCALE_UNIT, and spu_scale_create().

Referenced by SpuRenderSubpictures().

◆ spu_scale_h()

int spu_scale_h ( int v,
const spu_scale_t s )
static

References spu_scale_t::h, and SCALE_UNIT.

Referenced by spu_area_scaled(), and SpuRenderRegion().

◆ spu_scale_unit()

spu_scale_t spu_scale_unit ( void )
static

References SCALE_UNIT, and spu_scale_create().

Referenced by spu_area_scaled(), and SpuRenderRegion().

◆ spu_scale_w()

int spu_scale_w ( int v,
const spu_scale_t s )
static

References SCALE_UNIT, and spu_scale_t::w.

Referenced by spu_area_scaled(), and SpuRenderRegion().

◆ spu_SelectSubpictures()

◆ spu_SetClockDelay()

◆ spu_SetClockRate()

void spu_SetClockRate ( spu_t * spu,
size_t channel_id,
float rate )

◆ spu_SetHighlight()

void spu_SetHighlight ( spu_t * spu,
const vlc_spu_highlight_t * hl )

◆ spu_UpdateOriginalSize()

◆ SpuAreaFixOverlap()

void SpuAreaFixOverlap ( spu_area_t * dst,
const spu_area_t * sub_array,
size_t sub_count,
int align )
static

◆ SpuAreaMoveInside()

void SpuAreaMoveInside ( spu_area_t * area,
const unsigned boundary_width,
const unsigned boundary_height )
static

◆ SpuRegionPlace()

◆ SpuRenderCmp()

int SpuRenderCmp ( const void * s0,
const void * s1 )
static

This function compares 2 subpictures using the following properties (ordered by priority).

  1. start time (display time)
  2. creation order (per channel)

It can be used by qsort.

XXX spu_RenderSubpictures depends heavily on this order.

References subpicture_t::i_channel, subpicture_t::i_order, subpicture_t::i_start, IntegerCmp(), SSizeCmp(), and spu_render_entry_t::subpic.

Referenced by spu_Render().

◆ SpuRenderCreateAndLoadScale()

◆ SpuRenderCreateAndLoadText()

◆ SpuRenderRegion()

struct subpicture_region_rendered * SpuRenderRegion ( spu_t * spu,
spu_area_t * dst_area,
subpicture_t * subpic,
enum vlc_vout_order channel_order,
subpicture_region_t * region,
const spu_scale_t scale_size,
bool apply_scale,
const vlc_fourcc_t * chroma_list,
const unsigned output_x,
const unsigned output_y,
const unsigned output_width,
const unsigned output_height,
const spu_area_t * subtitle_area,
size_t subtitle_area_count,
vlc_tick_t render_date )
static

It will transform the provided region into another region suitable for rendering.

References subpicture_region_t::b_absolute, subpicture_t::b_fade, subpicture_t::b_subtitle, channel_order, container_of, spu_private_t::crop, spu_private_t::crop_highlight, vlc_filter_operations::filter_video, subpicture_region_t::fmt, filter_t::fmt_in, filter_t::fmt_out, picture_t::format, spu_scale_t::h, spu_private_t::height, vout_display_place_t::height, subpicture_region_t::i_align, subpicture_region_rendered::i_alpha, subpicture_region_t::i_alpha, subpicture_t::i_alpha, video_format_t::i_chroma, es_format_t::i_codec, video_palette_t::i_entries, video_format_t::i_height, subpicture_region_t::i_max_height, subpicture_region_t::i_max_width, subpicture_t::i_start, subpicture_t::i_stop, video_format_t::i_visible_height, video_format_t::i_visible_width, video_format_t::i_width, video_format_t::i_x_offset, video_format_t::i_y_offset, spu_private_t::margin, msg_Err, msg_Warn, filter_t::ops, video_format_t::p_palette, subpicture_region_rendered::p_picture, subpicture_region_t::p_picture, spu_private_t::palette, video_palette_t::palette, picture_Clone(), picture_HasChainedPics(), picture_Hold(), picture_Release(), subpicture_region_rendered::place, spu_area_t::scale, spu_private_t::scale, SCALE_UNIT, spu_private_t::scale_yuvp, spu_private_t::secondary_alignment, spu_private_t::secondary_margin, spu_area_create(), spu_invscale_h(), spu_invscale_w(), spu_scale_h(), spu_scale_unit(), spu_scale_w(), SpuAreaFixOverlap(), SpuAreaMoveInside(), SpuRegionPlace(), subpicture_region_cache_Assign(), subpicture_region_cache_GetFormat(), subpicture_region_cache_GetPicture(), subpicture_region_cache_Invalidate(), subpicture_region_cache_IsValid(), subpicture_region_IsText, unlikely, es_format_t::video, VLC_CODEC_YUVP, VLC_SUCCESS, VLC_TICK_INVALID, VLC_VOUT_ORDER_SECONDARY, spu_scale_t::w, spu_private_t::width, vout_display_place_t::width, spu_area_t::x, spu_private_t::x, vout_display_place_t::x, spu_area_t::y, spu_private_t::y, and vout_display_place_t::y.

Referenced by SpuRenderSubpictures().

◆ SpuRenderSubpictures()

vlc_render_subpicture * SpuRenderSubpictures ( spu_t * spu,
size_t i_subpicture,
const spu_render_entry_t * p_entries,
const vlc_fourcc_t * chroma_list,
const video_format_t * fmt_dst,
const video_format_t * fmt_src,
bool spu_in_full_window,
const vout_display_place_t * video_position,
vlc_tick_t system_now,
vlc_tick_t render_subtitle_date,
bool external_scale )
static

This function renders all sub picture units in the list.

References ARRAY_SIZE, subpicture_region_t::b_absolute, subpicture_region_t::b_in_window, subpicture_t::b_subtitle, container_of, count, vlc_rational_t::den, subpicture_region_t::fmt, spu_scale_t::h, vout_display_place_t::height, subpicture_region_t::i_align, subpicture_t::i_order, vlc_render_subpicture::i_order, subpicture_t::i_original_picture_height, subpicture_t::i_original_picture_width, video_format_t::i_sar_den, video_format_t::i_sar_num, video_format_t::i_visible_height, video_format_t::i_visible_width, subpicture_region_t::i_x, video_format_t::i_x_offset, subpicture_region_t::i_y, video_format_t::i_y_offset, likely, subpicture_region_t::node, vlc_rational_t::num, subpicture_region_rendered::place, region_FixFmt(), subpicture_t::regions, vlc_render_subpicture::regions, spu_area_unscaled(), spu_scale_createq(), spu_UpdateOriginalSize(), SpuRenderRegion(), SpuRenderText(), spu_render_entry_t::subpic, SUBPICTURE_ALIGN_LEFT, SUBPICTURE_ALIGN_TOP, subpicture_region_Delete(), subpicture_region_IsText, spu_private_t::subs_pos, subtitles_positions_AddRelativeRegion(), subtitles_positions_FindRelativeRegion(), subtitles_positions_FinishUpdate(), subtitles_positions_StartUpdate(), unlikely, vlc_list_replace(), vlc_render_subpicture_New(), vlc_spu_regions_foreach, vlc_spu_regions_foreach_const, vlc_spu_regions_is_empty, vlc_ureduce(), vlc_vector_push, spu_scale_t::w, vout_display_place_t::width, spu_area_t::x, subtitle_position_cache::x, vout_display_place_t::x, spu_area_t::y, subtitle_position_cache::y, and vout_display_place_t::y.

Referenced by spu_Render().

◆ SpuRenderText()

◆ SSizeCmp()

int SSizeCmp ( ssize_t i0,
ssize_t i1 )
static

Referenced by SpuRenderCmp().

◆ sub_new_buffer()

subpicture_t * sub_new_buffer ( filter_t * filter)
static

◆ SubFilter()

int SubFilter ( filter_t * p_filter,
void * opaque )
static

◆ SubFilterAddProxyCallbacks()

int SubFilterAddProxyCallbacks ( filter_t * filter,
void * opaque )
static

◆ SubFilterDelProxyCallbacks()

int SubFilterDelProxyCallbacks ( filter_t * filter,
void * opaque )
static

◆ SubSourceAddProxyCallbacks()

int SubSourceAddProxyCallbacks ( filter_t * filter,
void * opaque )
static

◆ SubSourceClean()

int SubSourceClean ( filter_t * filter,
void * data )
static

◆ SubSourceDelProxyCallbacks()

int SubSourceDelProxyCallbacks ( filter_t * filter,
void * opaque )
static

◆ SubSourceGenerate()

int SubSourceGenerate ( filter_t * p_filter,
void * opaque )
static

Generate subpictures from a chain of subpicture source "filters".

References sub_source::display_date, filter_t::ops, vlc_filter_operations::source_sub, sub_source::spu, spu_PutSubpicture(), and VLC_SUCCESS.

Referenced by spu_Render().

◆ SubSourceInit()

int SubSourceInit ( filter_t * filter,
void * data )
static

◆ subtitles_positions_AddRelativeRegion()

◆ subtitles_positions_FindRelativeRegion()

struct subtitle_position_cache * subtitles_positions_FindRelativeRegion ( const subtitles_positions_vector * subs,
const subpicture_region_t * region )
static

◆ subtitles_positions_FinishUpdate()

◆ subtitles_positions_StartUpdate()

void subtitles_positions_StartUpdate ( subtitles_positions_vector * subs)
static

Variable Documentation

◆ sub_cbs

const struct filter_subpicture_callbacks sub_cbs
static
Initial value:
= {
}
static subpicture_t * sub_new_buffer(filter_t *filter)
Definition vout_subpictures.c:1568

Referenced by SubSourceInit().