Commit ae42e9e7 authored by Christophe Massiot's avatar Christophe Massiot

* src/video_output/vout_subpictures.c: New function spu_MakeRegion which

  reuses a given picture_t without allocating a new one.
* modules/video_output/picture.c: New --picture-height and width options
  to do the scaling in the vout thread. Misc bug corrections.
* modules/video_filter/mosaic.c: Less overhead.
* modules/codec/ffmpeg/video_filter.c: Do the scaling before the conversion
  in case the original size is bigger than the destination.
parent 60dca098
/***************************************************************************** /*****************************************************************************
* vlc_codec.h: codec related structures * vlc_filter.h: filter related structures
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2003 VideoLAN * Copyright (C) 1999-2003 VideoLAN
* $Id$ * $Id$
......
...@@ -99,6 +99,8 @@ VLC_EXPORT( void, spu_DisplaySubpicture, ( spu_t *, subpicture_t * ) ); ...@@ -99,6 +99,8 @@ VLC_EXPORT( void, spu_DisplaySubpicture, ( spu_t *, subpicture_t * ) );
#define spu_CreateRegion(a,b) __spu_CreateRegion(VLC_OBJECT(a),b) #define spu_CreateRegion(a,b) __spu_CreateRegion(VLC_OBJECT(a),b)
VLC_EXPORT( subpicture_region_t *,__spu_CreateRegion, ( vlc_object_t *, video_format_t * ) ); VLC_EXPORT( subpicture_region_t *,__spu_CreateRegion, ( vlc_object_t *, video_format_t * ) );
#define spu_MakeRegion(a,b,c) __spu_MakeRegion(VLC_OBJECT(a),b,c)
VLC_EXPORT( subpicture_region_t *,__spu_MakeRegion, ( vlc_object_t *, video_format_t *, picture_t * ) );
#define spu_DestroyRegion(a,b) __spu_DestroyRegion(VLC_OBJECT(a),b) #define spu_DestroyRegion(a,b) __spu_DestroyRegion(VLC_OBJECT(a),b)
VLC_EXPORT( void, __spu_DestroyRegion, ( vlc_object_t *, subpicture_region_t * ) ); VLC_EXPORT( void, __spu_DestroyRegion, ( vlc_object_t *, subpicture_region_t * ) );
......
...@@ -273,6 +273,8 @@ struct subpicture_t ...@@ -273,6 +273,8 @@ struct subpicture_t
/** Pointer to functions for region management */ /** Pointer to functions for region management */
subpicture_region_t * ( *pf_create_region ) ( vlc_object_t *, subpicture_region_t * ( *pf_create_region ) ( vlc_object_t *,
video_format_t * ); video_format_t * );
subpicture_region_t * ( *pf_make_region ) ( vlc_object_t *,
video_format_t *, picture_t * );
void ( *pf_destroy_region ) ( vlc_object_t *, subpicture_region_t * ); void ( *pf_destroy_region ) ( vlc_object_t *, subpicture_region_t * );
/** Private data - the subtitle plugin might want to put stuff here to /** Private data - the subtitle plugin might want to put stuff here to
......
...@@ -113,9 +113,24 @@ int E_(OpenFilter)( vlc_object_t *p_this ) ...@@ -113,9 +113,24 @@ int E_(OpenFilter)( vlc_object_t *p_this )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
avpicture_alloc( &p_sys->tmp_pic, p_sys->i_dst_ffmpeg_chroma, if( p_sys->b_resize && p_sys->b_convert )
p_filter->fmt_in.video.i_width, {
p_filter->fmt_in.video.i_height ); if ( p_filter->fmt_in.video.i_width * p_filter->fmt_in.video.i_height >
p_filter->fmt_out.video.i_width * p_filter->fmt_out.video.i_height )
{
/* Resizing then conversion */
avpicture_alloc( &p_sys->tmp_pic, p_sys->i_src_ffmpeg_chroma,
p_filter->fmt_out.video.i_width,
p_filter->fmt_out.video.i_height );
}
else
{
/* Conversion then resizing */
avpicture_alloc( &p_sys->tmp_pic, p_sys->i_dst_ffmpeg_chroma,
p_filter->fmt_in.video.i_width,
p_filter->fmt_in.video.i_height );
}
}
msg_Dbg( p_filter, "input: %ix%i %4.4s -> %ix%i %4.4s", msg_Dbg( p_filter, "input: %ix%i %4.4s -> %ix%i %4.4s",
p_filter->fmt_in.video.i_width, p_filter->fmt_in.video.i_height, p_filter->fmt_in.video.i_width, p_filter->fmt_in.video.i_height,
...@@ -191,6 +206,7 @@ static picture_t *Process( filter_t *p_filter, picture_t *p_pic ) ...@@ -191,6 +206,7 @@ static picture_t *Process( filter_t *p_filter, picture_t *p_pic )
{ {
filter_sys_t *p_sys = p_filter->p_sys; filter_sys_t *p_sys = p_filter->p_sys;
AVPicture src_pic, dest_pic, inter_pic; AVPicture src_pic, dest_pic, inter_pic;
AVPicture *p_src, *p_dst;
picture_t *p_pic_dst; picture_t *p_pic_dst;
vlc_bool_t b_resize = p_sys->b_resize; vlc_bool_t b_resize = p_sys->b_resize;
int i; int i;
...@@ -238,32 +254,42 @@ static picture_t *Process( filter_t *p_filter, picture_t *p_pic ) ...@@ -238,32 +254,42 @@ static picture_t *Process( filter_t *p_filter, picture_t *p_pic )
if( p_filter->fmt_in.video.i_bmask == 0x00ff0000 ) if( p_filter->fmt_in.video.i_bmask == 0x00ff0000 )
p_sys->i_src_ffmpeg_chroma = PIX_FMT_BGR24; p_sys->i_src_ffmpeg_chroma = PIX_FMT_BGR24;
#if 0 p_src = &src_pic;
if( p_sys->b_resize &&
p_filter->fmt_in.video.i_width * p_filter->fmt_in.video.i_height > if( b_resize && p_sys->p_rsc )
p_filter->fmt_out.video.i_width * p_filter->fmt_out.video.i_height )
{ {
img_resample( p_sys->p_rsc, &dest_pic, &p_sys->tmp_pic ); p_dst = &dest_pic;
b_resize = 0; if ( p_filter->fmt_in.video.i_width * p_filter->fmt_in.video.i_height >
p_filter->fmt_out.video.i_width * p_filter->fmt_out.video.i_height )
{
if ( p_sys->b_convert ) p_dst = &p_sys->tmp_pic;
img_resample( p_sys->p_rsc, p_dst, p_src );
b_resize = VLC_FALSE;
p_src = p_dst;
}
} }
#endif
if( p_sys->b_convert ) if( p_sys->b_convert )
{ {
if( p_sys->b_resize ) inter_pic = p_sys->tmp_pic; video_format_t *p_fmt = &p_filter->fmt_out.video;
else inter_pic = dest_pic; p_dst = &dest_pic;
if( b_resize )
{
p_dst = &p_sys->tmp_pic;
p_fmt = &p_filter->fmt_in.video;
}
img_convert( &inter_pic, p_sys->i_dst_ffmpeg_chroma, img_convert( p_dst, p_sys->i_dst_ffmpeg_chroma,
&src_pic, p_sys->i_src_ffmpeg_chroma, p_src, p_sys->i_src_ffmpeg_chroma,
p_filter->fmt_in.video.i_width, p_fmt->i_width, p_fmt->i_height );
p_filter->fmt_in.video.i_height );
src_pic = inter_pic; p_src = p_dst;
} }
if( p_sys->b_resize && p_sys->p_rsc ) if( b_resize && p_sys->p_rsc )
{ {
img_resample( p_sys->p_rsc, &dest_pic, &src_pic ); p_dst = &dest_pic;
img_resample( p_sys->p_rsc, p_dst, p_src );
} }
/* Special case for RV32 -> YUVA */ /* Special case for RV32 -> YUVA */
......
This diff is collapsed.
This diff is collapsed.
...@@ -26,16 +26,19 @@ ...@@ -26,16 +26,19 @@
#define PICTURE_VOUT_E_AVAILABLE 0 #define PICTURE_VOUT_E_AVAILABLE 0
#define PICTURE_VOUT_E_OCCUPIED 1 #define PICTURE_VOUT_E_OCCUPIED 1
struct picture_vout_e_t { typedef struct picture_vout_e_t
{
picture_t *p_picture; picture_t *p_picture;
int i_status; int i_status;
char *psz_id; char *psz_id;
}; } picture_vout_e_t;
struct picture_vout_t
typedef struct picture_vout_t
{ {
vlc_mutex_t lock;
int i_picture_num; int i_picture_num;
struct picture_vout_e_t *p_pic; picture_vout_e_t *p_pic;
}; } picture_vout_t;
#undef IMAGE_2PASSES
#endif #endif
...@@ -285,6 +285,38 @@ subpicture_region_t *__spu_CreateRegion( vlc_object_t *p_this, ...@@ -285,6 +285,38 @@ subpicture_region_t *__spu_CreateRegion( vlc_object_t *p_this,
return p_region; return p_region;
} }
/**
* Make a subpicture region from an existing picture_t
*
* \param p_this vlc_object_t
* \param p_fmt the format that this subpicture region should have
* \param p_pic a pointer to the picture creating the region (not freed)
*/
subpicture_region_t *__spu_MakeRegion( vlc_object_t *p_this,
video_format_t *p_fmt,
picture_t *p_pic )
{
subpicture_region_t *p_region = malloc( sizeof(subpicture_region_t) );
memset( p_region, 0, sizeof(subpicture_region_t) );
p_region->p_next = 0;
p_region->p_cache = 0;
p_region->fmt = *p_fmt;
p_region->psz_text = 0;
p_region->i_font_color = -1; /* default to using freetype-color -opacity */
p_region->i_font_opacity = -1;
p_region->i_font_size = -1; /* and the freetype fontsize */
if( p_fmt->i_chroma == VLC_FOURCC('Y','U','V','P') )
p_fmt->p_palette = p_region->fmt.p_palette =
malloc( sizeof(video_palette_t) );
else p_fmt->p_palette = p_region->fmt.p_palette = NULL;
memcpy( &p_region->picture, p_pic, sizeof(picture_t) );
p_region->picture.pf_release = RegionPictureRelease;
return p_region;
}
/** /**
* Destroy a subpicture region * Destroy a subpicture region
* *
...@@ -384,6 +416,7 @@ subpicture_t *spu_CreateSubpicture( spu_t *p_spu ) ...@@ -384,6 +416,7 @@ subpicture_t *spu_CreateSubpicture( spu_t *p_spu )
vlc_mutex_unlock( &p_spu->subpicture_lock ); vlc_mutex_unlock( &p_spu->subpicture_lock );
p_subpic->pf_create_region = __spu_CreateRegion; p_subpic->pf_create_region = __spu_CreateRegion;
p_subpic->pf_make_region = __spu_MakeRegion;
p_subpic->pf_destroy_region = __spu_DestroyRegion; p_subpic->pf_destroy_region = __spu_DestroyRegion;
return p_subpic; return p_subpic;
...@@ -1011,6 +1044,7 @@ static subpicture_t *spu_new_buffer( filter_t *p_filter ) ...@@ -1011,6 +1044,7 @@ static subpicture_t *spu_new_buffer( filter_t *p_filter )
p_subpic->b_absolute = VLC_TRUE; p_subpic->b_absolute = VLC_TRUE;
p_subpic->pf_create_region = __spu_CreateRegion; p_subpic->pf_create_region = __spu_CreateRegion;
p_subpic->pf_make_region = __spu_MakeRegion;
p_subpic->pf_destroy_region = __spu_DestroyRegion; p_subpic->pf_destroy_region = __spu_DestroyRegion;
return p_subpic; return p_subpic;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment