* keep a cache of low-res snapshots.
* The snapshot structure is defined in include/snapshot.h
* In order to access the current snapshot cache, object variables are used:
- * snapshot-list-pointer : the pointer on the first element in the list
- * snapshot-datasize : size of a snapshot
+ * vout-snapshot-list-pointer : the pointer on the first element in the list
+ * vout-snapshot-datasize : size of a snapshot
* (also available in snapshot_t->i_datasize)
- * snapshot-cache-size : size of the cache list
+ * vout-snapshot-cache-size : size of the cache list
*
* It is used for the moment by the CORBA module and a specialized
* python-vlc binding.
set_subcategory( SUBCAT_VIDEO_VOUT )
set_capability( "video output", 1 )
- add_integer( "snapshot-width", 320, NULL, WIDTH_TEXT, WIDTH_LONGTEXT, false )
- add_integer( "snapshot-height", 200, NULL, HEIGHT_TEXT, HEIGHT_LONGTEXT, false )
- add_string( "snapshot-chroma", "RV32", NULL, CHROMA_TEXT, CHROMA_LONGTEXT, true )
- add_integer( "snapshot-cache-size", 50, NULL, CACHE_TEXT, CACHE_LONGTEXT, true )
+ add_integer( "vout-snapshot-width", 320, NULL, WIDTH_TEXT, WIDTH_LONGTEXT, false )
+ add_integer( "vout-snapshot-height", 200, NULL, HEIGHT_TEXT, HEIGHT_LONGTEXT, false )
+ add_string( "vout-snapshot-chroma", "RV32", NULL, CHROMA_TEXT, CHROMA_LONGTEXT, true )
+ add_deprecated_alias( "snapshot-chroma" )
+ add_integer( "vout-snapshot-cache-size", 50, NULL, CACHE_TEXT, CACHE_LONGTEXT, true )
+ add_deprecated_alias( "snapshot-cache-size" )
set_callbacks( Create, Destroy )
vlc_module_end ()
if( ! p_vout->p_sys )
return VLC_ENOMEM;
- var_Create( p_vout, "snapshot-width", VLC_VAR_INTEGER );
- var_Create( p_vout, "snapshot-height", VLC_VAR_INTEGER );
- var_Create( p_vout, "snapshot-datasize", VLC_VAR_INTEGER );
- var_Create( p_vout, "snapshot-cache-size", VLC_VAR_INTEGER );
- var_Create( p_vout, "snapshot-list-pointer", VLC_VAR_ADDRESS );
+ var_Create( p_vout, "vout-snapshot-width", VLC_VAR_INTEGER );
+ var_Create( p_vout, "vout-snapshot-height", VLC_VAR_INTEGER );
+ var_Create( p_vout, "vout-snapshot-datasize", VLC_VAR_INTEGER );
+ var_Create( p_vout, "vout-snapshot-cache-size", VLC_VAR_INTEGER );
+ var_Create( p_vout, "vout-snapshot-list-pointer", VLC_VAR_ADDRESS );
p_vout->pf_init = Init;
p_vout->pf_end = End;
picture_t *p_pic;
vlc_value_t val;
char* psz_chroma;
- int i_chroma;
+ vlc_fourcc_t i_chroma;
int i_width;
int i_height;
int i_datasize;
- i_width = config_GetInt( p_vout, "snapshot-width" );
- i_height = config_GetInt( p_vout, "snapshot-height" );
+ i_width = config_GetInt( p_vout, "vout-snapshot-width" );
+ i_height = config_GetInt( p_vout, "vout-snapshot-height" );
- psz_chroma = config_GetPsz( p_vout, "snapshot-chroma" );
- if( !psz_chroma )
+ psz_chroma = config_GetPsz( p_vout, "vout-snapshot-chroma" );
+ if( psz_chroma )
{
- msg_Err( p_vout, "Cannot find chroma information." );
- return VLC_EGENERIC;
+ if( strlen( psz_chroma ) < 4 )
+ {
+ msg_Err( p_vout, "vout-snapshot-chroma should be 4 characters long" );
+ return VLC_EGENERIC;
+ }
+ i_chroma = VLC_FOURCC( psz_chroma[0], psz_chroma[1],
+ psz_chroma[2], psz_chroma[3] );
+ free( psz_chroma );
}
- else
+
+ i_chroma = vlc_fourcc_GetCodecFromString( VIDEO_ES, psz_chroma );
+ free( psz_chroma );
+
+ if( !i_chroma )
{
- msg_Err( p_vout, "Cannot find chroma information." );
+ msg_Err( p_vout, "snapshot-chroma should be 4 characters long" );
return VLC_EGENERIC;
}
/* Define the bitmasks */
switch( i_chroma )
{
- case VLC_FOURCC( 'R','V','1','5' ):
+ case VLC_CODEC_RGB15:
p_vout->output.i_rmask = 0x001f;
p_vout->output.i_gmask = 0x03e0;
p_vout->output.i_bmask = 0x7c00;
break;
- case VLC_FOURCC( 'R','V','1','6' ):
+ case VLC_CODEC_RGB16:
p_vout->output.i_rmask = 0x001f;
p_vout->output.i_gmask = 0x07e0;
p_vout->output.i_bmask = 0xf800;
break;
- case VLC_FOURCC( 'R','V','2','4' ):
+ case VLC_CODEC_RGB24:
p_vout->output.i_rmask = 0xff0000;
p_vout->output.i_gmask = 0x00ff00;
p_vout->output.i_bmask = 0x0000ff;
break;
- case VLC_FOURCC( 'R','V','3','2' ):
+ case VLC_CODEC_RGB32:
p_vout->output.i_rmask = 0xff0000;
p_vout->output.i_gmask = 0x00ff00;
p_vout->output.i_bmask = 0x0000ff;
p_vout->p_sys->i_datasize = i_datasize;
p_vout->p_sys->i_index = 0;
- p_vout->p_sys->i_size = config_GetInt( p_vout, "snapshot-cache-size" );
+ p_vout->p_sys->i_size = config_GetInt( p_vout, "vout-snapshot-cache-size" );
if( p_vout->p_sys->i_size < 2 )
{
- msg_Err( p_vout, "snapshot-cache-size must be at least 1." );
+ msg_Err( p_vout, "vout-snapshot-cache-size must be at least 1." );
return VLC_EGENERIC;
}
}
val.i_int = i_width;
- var_Set( p_vout, "snapshot-width", val );
+ var_Set( p_vout, "vout-snapshot-width", val );
val.i_int = i_height;
- var_Set( p_vout, "snapshot-height", val );
+ var_Set( p_vout, "vout-snapshot-height", val );
val.i_int = i_datasize;
- var_Set( p_vout, "snapshot-datasize", val );
+ var_Set( p_vout, "vout-snapshot-datasize", val );
val.i_int = p_vout->p_sys->i_size;
- var_Set( p_vout, "snapshot-cache-size", val );
+ var_Set( p_vout, "vout-snapshot-cache-size", val );
val.p_address = p_vout->p_sys->p_list;
- var_Set( p_vout, "snapshot-list-pointer", val );
+ var_Set( p_vout, "vout-snapshot-list-pointer", val );
/* Get the p_input pointer (to access video times) */
p_vout->p_sys->p_input = vlc_object_find( p_vout, VLC_OBJECT_INPUT,
if( !p_vout->p_sys->p_input )
return VLC_ENOOBJ;
- if( var_Create( p_vout->p_sys->p_input, "snapshot-id", VLC_VAR_INTEGER ) )
+ if( var_Create( p_vout->p_sys->p_input, "vout-snapshot-id", VLC_VAR_INTEGER ) )
{
- msg_Err( p_vout, "Cannot create snapshot-id variable in p_input(%p).",
+ msg_Err( p_vout, "Cannot create vout-snapshot-id variable in p_input(%p).",
p_vout->p_sys->p_input );
return VLC_EGENERIC;
}
/* Register the snapshot vout module at the input level */
val.p_address = p_vout;
- if( var_Set( p_vout->p_sys->p_input, "snapshot-id", val ) )
+ if( var_Set( p_vout->p_sys->p_input, "vout-snapshot-id", val ) )
{
- msg_Err( p_vout, "Cannot register snapshot-id in p_input(%p).",
+ msg_Err( p_vout, "Cannot register vout-snapshot-id in p_input(%p).",
p_vout->p_sys->p_input );
return VLC_EGENERIC;
}
vout_thread_t *p_vout = ( vout_thread_t * )p_this;
int i_index;
- var_Destroy( p_vout->p_sys->p_input, "snapshot-id" );
+ var_Destroy( p_vout->p_sys->p_input, "vout-snapshot-id" );
vlc_object_release( p_vout->p_sys->p_input );
- var_Destroy( p_this, "snapshot-width" );
- var_Destroy( p_this, "snapshot-height" );
- var_Destroy( p_this, "snapshot-datasize" );
+ var_Destroy( p_this, "vout-snapshot-width" );
+ var_Destroy( p_this, "vout-snapshot-height" );
+ var_Destroy( p_this, "vout-snapshot-datasize" );
for( i_index = 0 ; i_index < p_vout->p_sys->i_size ; i_index++ )
{
p_vout->fmt_out.i_aspect );
p_tmp_pic->i_type = MEMORY_PICTURE;
p_tmp_pic->i_status = RESERVED_PICTURE;
- /* some modules (such as blend) needs to know the extra information in picture heap */
- p_tmp_pic->p_heap = &p_vout->output;
}
/* Convert image to the first direct buffer */
i_width_aligned = (i_width + 15) >> 4 << 4;
i_height_aligned = (i_height + 15) >> 4 << 4;
- if( vout_InitPicture( p_this, p_pic, i_chroma,
- i_width, i_height, i_aspect ) != VLC_SUCCESS )
+ if( picture_Setup( p_pic, i_chroma,
+ i_width, i_height, i_aspect ) != VLC_SUCCESS )
{
p_pic->i_planes = 0;
return VLC_EGENERIC;
return VLC_SUCCESS;
}
-/**
- * Initialise the video format fields given chroma/size.
- *
- * This function initializes all the video_frame_format_t fields given the
- * static properties of a picture (chroma and size).
- * \param p_format Pointer to the format structure to initialize
- * \param i_chroma Chroma to set
- * \param i_width Width to set
- * \param i_height Height to set
- * \param i_aspect Aspect ratio
- */
-void vout_InitFormat( video_frame_format_t *p_format, vlc_fourcc_t i_chroma,
- int i_width, int i_height, int i_aspect )
-{
- p_format->i_chroma = i_chroma;
- p_format->i_width = p_format->i_visible_width = i_width;
- p_format->i_height = p_format->i_visible_height = i_height;
- p_format->i_x_offset = p_format->i_y_offset = 0;
- p_format->i_aspect = i_aspect;
-
-#if 0
- /* Assume we have square pixels */
- if( i_width && i_height )
- p_format->i_aspect = i_width * VOUT_ASPECT_FACTOR / i_height;
- else
- p_format->i_aspect = 0;
-#endif
-
- switch( i_chroma )
- {
- case FOURCC_YUVA:
- p_format->i_bits_per_pixel = 32;
- break;
- case FOURCC_I444:
- case FOURCC_J444:
- p_format->i_bits_per_pixel = 24;
- break;
- case FOURCC_I422:
- case FOURCC_YUY2:
- case FOURCC_UYVY:
- case FOURCC_J422:
- p_format->i_bits_per_pixel = 16;
- break;
- case FOURCC_I440:
- case FOURCC_J440:
- p_format->i_bits_per_pixel = 16;
- break;
- case FOURCC_I411:
- case FOURCC_YV12:
- case FOURCC_I420:
- case FOURCC_J420:
- case FOURCC_IYUV:
- p_format->i_bits_per_pixel = 12;
- break;
- case FOURCC_I410:
- case FOURCC_YVU9:
- p_format->i_bits_per_pixel = 9;
- break;
- case FOURCC_Y211:
- p_format->i_bits_per_pixel = 8;
- break;
- case FOURCC_YUVP:
- p_format->i_bits_per_pixel = 8;
- break;
-
- case FOURCC_RV32:
- case FOURCC_RGBA:
- p_format->i_bits_per_pixel = 32;
- break;
- case FOURCC_RV24:
- p_format->i_bits_per_pixel = 24;
- break;
- case FOURCC_RV15:
- case FOURCC_RV16:
- p_format->i_bits_per_pixel = 16;
- break;
- case FOURCC_RGB2:
- p_format->i_bits_per_pixel = 8;
- break;
-
- case FOURCC_GREY:
- case FOURCC_Y800:
- case FOURCC_Y8:
- case FOURCC_RGBP:
- p_format->i_bits_per_pixel = 8;
- break;
-
- default:
- p_format->i_bits_per_pixel = 0;
- break;
- }
-}
-
-/**
- * Initialise the picture_t fields given chroma/size.
- *
- * This function initializes most of the picture_t fields given a chroma and
- * size. It makes the assumption that stride == width.
- * \param p_this The calling object
- * \param p_pic Pointer to the picture to initialize
- * \param i_chroma The chroma fourcc to set
- * \param i_width The width of the picture
- * \param i_height The height of the picture
- * \param i_aspect The aspect ratio of the picture
- */
-int __vout_InitPicture( vlc_object_t *p_this, picture_t *p_pic,
- vlc_fourcc_t i_chroma,
- int i_width, int i_height, int i_aspect )
-{
- int i_index, i_width_aligned, i_height_aligned;
-
- /* Store default values */
- for( i_index = 0; i_index < VOUT_MAX_PLANES; i_index++ )
- {
- p_pic->p[i_index].p_pixels = NULL;
- p_pic->p[i_index].i_pixel_pitch = 1;
- }
-
- p_pic->pf_release = NULL;
- p_pic->pf_lock = NULL;
- p_pic->pf_unlock = NULL;
- p_pic->i_refcount = 0;
-
- p_pic->i_qtype = QTYPE_NONE;
- p_pic->i_qstride = 0;
- p_pic->p_q = NULL;
-
- vout_InitFormat( &p_pic->format, i_chroma, i_width, i_height, i_aspect );
-
- /* Make sure the real dimensions are a multiple of 16 */
- i_width_aligned = (i_width + 15) >> 4 << 4;
- i_height_aligned = (i_height + 15) >> 4 << 4;
-
- /* Calculate coordinates */
- switch( i_chroma )
- {
- case FOURCC_I411:
- p_pic->p[ Y_PLANE ].i_lines = i_height_aligned;
- p_pic->p[ Y_PLANE ].i_visible_lines = i_height;
- p_pic->p[ Y_PLANE ].i_pitch = i_width_aligned;
- p_pic->p[ Y_PLANE ].i_visible_pitch = i_width;
- p_pic->p[ U_PLANE ].i_lines = i_height_aligned;
- p_pic->p[ U_PLANE ].i_visible_lines = i_height;
- p_pic->p[ U_PLANE ].i_pitch = i_width_aligned / 4;
- p_pic->p[ U_PLANE ].i_visible_pitch = i_width / 4;
- p_pic->p[ V_PLANE ].i_lines = i_height_aligned;
- p_pic->p[ V_PLANE ].i_visible_lines = i_height;
- p_pic->p[ V_PLANE ].i_pitch = i_width_aligned / 4;
- p_pic->p[ V_PLANE ].i_visible_pitch = i_width / 4;
- p_pic->i_planes = 3;
- break;
-
- case FOURCC_I410:
- case FOURCC_YVU9:
- p_pic->p[ Y_PLANE ].i_lines = i_height_aligned;
- p_pic->p[ Y_PLANE ].i_visible_lines = i_height;
- p_pic->p[ Y_PLANE ].i_pitch = i_width_aligned;
- p_pic->p[ Y_PLANE ].i_visible_pitch = i_width;
- p_pic->p[ U_PLANE ].i_lines = i_height_aligned / 4;
- p_pic->p[ U_PLANE ].i_visible_lines = i_height / 4;
- p_pic->p[ U_PLANE ].i_pitch = i_width_aligned / 4;
- p_pic->p[ U_PLANE ].i_visible_pitch = i_width / 4;
- p_pic->p[ V_PLANE ].i_lines = i_height_aligned / 4;
- p_pic->p[ V_PLANE ].i_visible_lines = i_height / 4;
- p_pic->p[ V_PLANE ].i_pitch = i_width_aligned / 4;
- p_pic->p[ V_PLANE ].i_visible_pitch = i_width / 4;
- p_pic->i_planes = 3;
- break;
-
- case FOURCC_YV12:
- case FOURCC_I420:
- case FOURCC_IYUV:
- case FOURCC_J420:
- p_pic->p[ Y_PLANE ].i_lines = i_height_aligned;
- p_pic->p[ Y_PLANE ].i_visible_lines = i_height;
- p_pic->p[ Y_PLANE ].i_pitch = i_width_aligned;
- p_pic->p[ Y_PLANE ].i_visible_pitch = i_width;
- p_pic->p[ U_PLANE ].i_lines = i_height_aligned / 2;
- p_pic->p[ U_PLANE ].i_visible_lines = i_height / 2;
- p_pic->p[ U_PLANE ].i_pitch = i_width_aligned / 2;
- p_pic->p[ U_PLANE ].i_visible_pitch = i_width / 2;
- p_pic->p[ V_PLANE ].i_lines = i_height_aligned / 2;
- p_pic->p[ V_PLANE ].i_visible_lines = i_height / 2;
- p_pic->p[ V_PLANE ].i_pitch = i_width_aligned / 2;
- p_pic->p[ V_PLANE ].i_visible_pitch = i_width / 2;
- p_pic->i_planes = 3;
- break;
-
- case FOURCC_I422:
- case FOURCC_J422:
- p_pic->p[ Y_PLANE ].i_lines = i_height_aligned;
- p_pic->p[ Y_PLANE ].i_visible_lines = i_height;
- p_pic->p[ Y_PLANE ].i_pitch = i_width_aligned;
- p_pic->p[ Y_PLANE ].i_visible_pitch = i_width;
- p_pic->p[ U_PLANE ].i_lines = i_height_aligned;
- p_pic->p[ U_PLANE ].i_visible_lines = i_height;
- p_pic->p[ U_PLANE ].i_pitch = i_width_aligned / 2;
- p_pic->p[ U_PLANE ].i_visible_pitch = i_width / 2;
- p_pic->p[ V_PLANE ].i_lines = i_height_aligned;
- p_pic->p[ V_PLANE ].i_visible_lines = i_height;
- p_pic->p[ V_PLANE ].i_pitch = i_width_aligned / 2;
- p_pic->p[ V_PLANE ].i_visible_pitch = i_width / 2;
- p_pic->i_planes = 3;
- break;
-
- case FOURCC_I440:
- case FOURCC_J440:
- p_pic->p[ Y_PLANE ].i_lines = i_height_aligned;
- p_pic->p[ Y_PLANE ].i_visible_lines = i_height;
- p_pic->p[ Y_PLANE ].i_pitch = i_width_aligned;
- p_pic->p[ Y_PLANE ].i_visible_pitch = i_width;
- p_pic->p[ U_PLANE ].i_lines = i_height_aligned / 2;
- p_pic->p[ U_PLANE ].i_visible_lines = i_height / 2;
- p_pic->p[ U_PLANE ].i_pitch = i_width_aligned;
- p_pic->p[ U_PLANE ].i_visible_pitch = i_width;
- p_pic->p[ V_PLANE ].i_lines = i_height_aligned / 2;
- p_pic->p[ V_PLANE ].i_visible_lines = i_height / 2;
- p_pic->p[ V_PLANE ].i_pitch = i_width_aligned;
- p_pic->p[ V_PLANE ].i_visible_pitch = i_width;
- p_pic->i_planes = 3;
- break;
-
- case FOURCC_I444:
- case FOURCC_J444:
- p_pic->p[ Y_PLANE ].i_lines = i_height_aligned;
- p_pic->p[ Y_PLANE ].i_visible_lines = i_height;
- p_pic->p[ Y_PLANE ].i_pitch = i_width_aligned;
- p_pic->p[ Y_PLANE ].i_visible_pitch = i_width;
- p_pic->p[ U_PLANE ].i_lines = i_height_aligned;
- p_pic->p[ U_PLANE ].i_visible_lines = i_height;
- p_pic->p[ U_PLANE ].i_pitch = i_width_aligned;
- p_pic->p[ U_PLANE ].i_visible_pitch = i_width;
- p_pic->p[ V_PLANE ].i_lines = i_height_aligned;
- p_pic->p[ V_PLANE ].i_visible_lines = i_height;
- p_pic->p[ V_PLANE ].i_pitch = i_width_aligned;
- p_pic->p[ V_PLANE ].i_visible_pitch = i_width;
- p_pic->i_planes = 3;
- break;
-
- case FOURCC_YUVA:
- p_pic->p[ Y_PLANE ].i_lines = i_height_aligned;
- p_pic->p[ Y_PLANE ].i_visible_lines = i_height;
- p_pic->p[ Y_PLANE ].i_pitch = i_width_aligned;
- p_pic->p[ Y_PLANE ].i_visible_pitch = i_width;
- p_pic->p[ U_PLANE ].i_lines = i_height_aligned;
- p_pic->p[ U_PLANE ].i_visible_lines = i_height;
- p_pic->p[ U_PLANE ].i_pitch = i_width_aligned;
- p_pic->p[ U_PLANE ].i_visible_pitch = i_width;
- p_pic->p[ V_PLANE ].i_lines = i_height_aligned;
- p_pic->p[ V_PLANE ].i_visible_lines = i_height;
- p_pic->p[ V_PLANE ].i_pitch = i_width_aligned;
- p_pic->p[ V_PLANE ].i_visible_pitch = i_width;
- p_pic->p[ A_PLANE ].i_lines = i_height_aligned;
- p_pic->p[ A_PLANE ].i_visible_lines = i_height;
- p_pic->p[ A_PLANE ].i_pitch = i_width_aligned;
- p_pic->p[ A_PLANE ].i_visible_pitch = i_width;
- p_pic->i_planes = 4;
- break;
-
- case FOURCC_YUVP:
- p_pic->p->i_lines = i_height_aligned;
- p_pic->p->i_visible_lines = i_height;
- p_pic->p->i_pitch = i_width_aligned;
- p_pic->p->i_visible_pitch = i_width;
- p_pic->p->i_pixel_pitch = 8;
- p_pic->i_planes = 1;
- break;
-
- case FOURCC_Y211:
- p_pic->p->i_lines = i_height_aligned;
- p_pic->p->i_visible_lines = i_height;
- p_pic->p->i_pitch = i_width_aligned;
- p_pic->p->i_visible_pitch = i_width;
- p_pic->p->i_pixel_pitch = 4;
- p_pic->i_planes = 1;
- break;
-
- case FOURCC_UYVY:
- case FOURCC_YUY2:
- p_pic->p->i_lines = i_height_aligned;
- p_pic->p->i_visible_lines = i_height;
- p_pic->p->i_pitch = i_width_aligned * 2;
- p_pic->p->i_visible_pitch = i_width * 2;
- p_pic->p->i_pixel_pitch = 4;
- p_pic->i_planes = 1;
- break;
-
- case FOURCC_RGB2:
- p_pic->p->i_lines = i_height_aligned;
- p_pic->p->i_visible_lines = i_height;
- p_pic->p->i_pitch = i_width_aligned;
- p_pic->p->i_visible_pitch = i_width;
- p_pic->p->i_pixel_pitch = 1;
- p_pic->i_planes = 1;
- break;
-
- case FOURCC_RV15:
- p_pic->p->i_lines = i_height_aligned;
- p_pic->p->i_visible_lines = i_height;
- p_pic->p->i_pitch = i_width_aligned * 2;
- p_pic->p->i_visible_pitch = i_width * 2;
- p_pic->p->i_pixel_pitch = 2;
- p_pic->i_planes = 1;
- break;
-
- case FOURCC_RV16:
- p_pic->p->i_lines = i_height_aligned;
- p_pic->p->i_visible_lines = i_height;
- p_pic->p->i_pitch = i_width_aligned * 2;
- p_pic->p->i_visible_pitch = i_width * 2;
- p_pic->p->i_pixel_pitch = 2;
- p_pic->i_planes = 1;
- break;
-
- case FOURCC_RV24:
- p_pic->p->i_lines = i_height_aligned;
- p_pic->p->i_visible_lines = i_height;
- p_pic->p->i_pitch = i_width_aligned * 3;
- p_pic->p->i_visible_pitch = i_width * 3;
- p_pic->p->i_pixel_pitch = 3;
- p_pic->i_planes = 1;
- break;
-
- case FOURCC_RV32:
- case FOURCC_RGBA:
- p_pic->p->i_lines = i_height_aligned;
- p_pic->p->i_visible_lines = i_height;
- p_pic->p->i_pitch = i_width_aligned * 4;
- p_pic->p->i_visible_pitch = i_width * 4;
- p_pic->p->i_pixel_pitch = 4;
- p_pic->i_planes = 1;
- break;
-
- case FOURCC_GREY:
- case FOURCC_Y800:
- case FOURCC_Y8:
- case FOURCC_RGBP:
- p_pic->p->i_lines = i_height_aligned;
- p_pic->p->i_visible_lines = i_height;
- p_pic->p->i_pitch = i_width_aligned;
- p_pic->p->i_visible_pitch = i_width;
- p_pic->p->i_pixel_pitch = 1;
- p_pic->i_planes = 1;
- break;
-
- default:
- if( p_this )
- msg_Err( p_this, "unknown chroma type 0x%.8x (%4.4s)",
- i_chroma, (char*)&i_chroma );
- p_pic->i_planes = 0;
- return VLC_EGENERIC;
- }
-
- return VLC_SUCCESS;
-}
-
/**
* Compare two chroma values
*
int vout_ChromaCmp( vlc_fourcc_t i_chroma, vlc_fourcc_t i_amorhc )
{
static const vlc_fourcc_t p_I420[] = {
- FOURCC_I420, FOURCC_IYUV, FOURCC_YV12, FOURCC_J420, 0
+ VLC_CODEC_I420, VLC_CODEC_YV12, VLC_CODEC_J420, 0
};
static const vlc_fourcc_t p_I422[] = {
- FOURCC_I422, FOURCC_J422, 0
+ VLC_CODEC_I422, VLC_CODEC_J422, 0
};
static const vlc_fourcc_t p_I440[] = {
- FOURCC_I440, FOURCC_J440, 0
+ VLC_CODEC_I440, VLC_CODEC_J440, 0
};
static const vlc_fourcc_t p_I444[] = {
- FOURCC_I444, FOURCC_J444, 0
- };
- static const vlc_fourcc_t p_UYVY[] = {
- FOURCC_UYVY, FOURCC_UYNV, FOURCC_Y422, 0
- };
- static const vlc_fourcc_t p_YUYV[] = {
- FOURCC_YUY2, FOURCC_YUNV, 0
- };
- static const vlc_fourcc_t p_GREY[] = {
- FOURCC_GREY, FOURCC_Y800, FOURCC_Y8, 0
+ VLC_CODEC_I444, VLC_CODEC_J444, 0
};
static const vlc_fourcc_t *pp_fcc[] = {
- p_I420, p_I422, p_I440, p_I444, p_UYVY, p_YUYV, p_GREY, NULL
+ p_I420, p_I422, p_I440, p_I444, NULL
};
+ /* */
+ i_chroma = vlc_fourcc_GetCodec( VIDEO_ES, i_chroma );
+ i_amorhc = vlc_fourcc_GetCodec( VIDEO_ES, i_amorhc );
+
/* If they are the same, they are the same ! */
if( i_chroma == i_amorhc )
return 1;
return;
picture_Delete( p_picture );
}
+
+/*****************************************************************************
+ *
+ *****************************************************************************/
+int picture_Setup( picture_t *p_picture, vlc_fourcc_t i_chroma, int i_width, int i_height, int i_aspect )
+{
+ int i_index, i_width_aligned, i_height_aligned;
+
+ /* Store default values */
+ for( i_index = 0; i_index < VOUT_MAX_PLANES; i_index++ )
+ {
+ p_picture->p[i_index].p_pixels = NULL;
+ p_picture->p[i_index].i_pixel_pitch = 1;
+ }
+
+ p_picture->pf_release = NULL;
+ p_picture->p_release_sys = NULL;
+ p_picture->pf_lock = NULL;
+ p_picture->pf_unlock = NULL;
+ p_picture->i_refcount = 0;
+
+ p_picture->i_qtype = QTYPE_NONE;
+ p_picture->i_qstride = 0;
+ p_picture->p_q = NULL;
+
+ video_format_Setup( &p_picture->format, i_chroma, i_width, i_height, i_aspect );
+
+ /* Make sure the real dimensions are a multiple of 16 */
+ i_width_aligned = (i_width + 15) >> 4 << 4;
+ i_height_aligned = (i_height + 15) >> 4 << 4;
+
+ /* Calculate coordinates */
+ switch( vlc_fourcc_GetCodec( VIDEO_ES, i_chroma ) )
+ {
+ case VLC_CODEC_I411:
+ p_picture->p[ Y_PLANE ].i_lines = i_height_aligned;
+ p_picture->p[ Y_PLANE ].i_visible_lines = i_height;
+ p_picture->p[ Y_PLANE ].i_pitch = i_width_aligned;
+ p_picture->p[ Y_PLANE ].i_visible_pitch = i_width;
+ p_picture->p[ U_PLANE ].i_lines = i_height_aligned;
+ p_picture->p[ U_PLANE ].i_visible_lines = i_height;
+ p_picture->p[ U_PLANE ].i_pitch = i_width_aligned / 4;
+ p_picture->p[ U_PLANE ].i_visible_pitch = i_width / 4;
+ p_picture->p[ V_PLANE ].i_lines = i_height_aligned;
+ p_picture->p[ V_PLANE ].i_visible_lines = i_height;
+ p_picture->p[ V_PLANE ].i_pitch = i_width_aligned / 4;
+ p_picture->p[ V_PLANE ].i_visible_pitch = i_width / 4;
+ p_picture->i_planes = 3;
+ break;
+
+ case VLC_CODEC_I410:
+ p_picture->p[ Y_PLANE ].i_lines = i_height_aligned;
+ p_picture->p[ Y_PLANE ].i_visible_lines = i_height;
+ p_picture->p[ Y_PLANE ].i_pitch = i_width_aligned;
+ p_picture->p[ Y_PLANE ].i_visible_pitch = i_width;
+ p_picture->p[ U_PLANE ].i_lines = i_height_aligned / 4;
+ p_picture->p[ U_PLANE ].i_visible_lines = i_height / 4;
+ p_picture->p[ U_PLANE ].i_pitch = i_width_aligned / 4;
+ p_picture->p[ U_PLANE ].i_visible_pitch = i_width / 4;
+ p_picture->p[ V_PLANE ].i_lines = i_height_aligned / 4;
+ p_picture->p[ V_PLANE ].i_visible_lines = i_height / 4;
+ p_picture->p[ V_PLANE ].i_pitch = i_width_aligned / 4;
+ p_picture->p[ V_PLANE ].i_visible_pitch = i_width / 4;
+ p_picture->i_planes = 3;
+ break;
+
+ case VLC_CODEC_YV12:
+ case VLC_CODEC_I420:
+ case VLC_CODEC_J420:
+ p_picture->p[ Y_PLANE ].i_lines = i_height_aligned;
+ p_picture->p[ Y_PLANE ].i_visible_lines = i_height;
+ p_picture->p[ Y_PLANE ].i_pitch = i_width_aligned;
+ p_picture->p[ Y_PLANE ].i_visible_pitch = i_width;
+ p_picture->p[ U_PLANE ].i_lines = i_height_aligned / 2;
+ p_picture->p[ U_PLANE ].i_visible_lines = i_height / 2;
+ p_picture->p[ U_PLANE ].i_pitch = i_width_aligned / 2;
+ p_picture->p[ U_PLANE ].i_visible_pitch = i_width / 2;
+ p_picture->p[ V_PLANE ].i_lines = i_height_aligned / 2;
+ p_picture->p[ V_PLANE ].i_visible_lines = i_height / 2;
+ p_picture->p[ V_PLANE ].i_pitch = i_width_aligned / 2;
+ p_picture->p[ V_PLANE ].i_visible_pitch = i_width / 2;
+ p_picture->i_planes = 3;
+ break;
+
+ case VLC_CODEC_I422:
+ case VLC_CODEC_J422:
+ p_picture->p[ Y_PLANE ].i_lines = i_height_aligned;
+ p_picture->p[ Y_PLANE ].i_visible_lines = i_height;
+ p_picture->p[ Y_PLANE ].i_pitch = i_width_aligned;
+ p_picture->p[ Y_PLANE ].i_visible_pitch = i_width;
+ p_picture->p[ U_PLANE ].i_lines = i_height_aligned;
+ p_picture->p[ U_PLANE ].i_visible_lines = i_height;
+ p_picture->p[ U_PLANE ].i_pitch = i_width_aligned / 2;
+ p_picture->p[ U_PLANE ].i_visible_pitch = i_width / 2;
+ p_picture->p[ V_PLANE ].i_lines = i_height_aligned;
+ p_picture->p[ V_PLANE ].i_visible_lines = i_height;
+ p_picture->p[ V_PLANE ].i_pitch = i_width_aligned / 2;
+ p_picture->p[ V_PLANE ].i_visible_pitch = i_width / 2;
+ p_picture->i_planes = 3;
+ break;
+
+ case VLC_CODEC_I440:
+ case VLC_CODEC_J440:
+ p_picture->p[ Y_PLANE ].i_lines = i_height_aligned;
+ p_picture->p[ Y_PLANE ].i_visible_lines = i_height;
+ p_picture->p[ Y_PLANE ].i_pitch = i_width_aligned;
+ p_picture->p[ Y_PLANE ].i_visible_pitch = i_width;
+ p_picture->p[ U_PLANE ].i_lines = i_height_aligned / 2;
+ p_picture->p[ U_PLANE ].i_visible_lines = i_height / 2;
+ p_picture->p[ U_PLANE ].i_pitch = i_width_aligned;
+ p_picture->p[ U_PLANE ].i_visible_pitch = i_width;
+ p_picture->p[ V_PLANE ].i_lines = i_height_aligned / 2;
+ p_picture->p[ V_PLANE ].i_visible_lines = i_height / 2;
+ p_picture->p[ V_PLANE ].i_pitch = i_width_aligned;
+ p_picture->p[ V_PLANE ].i_visible_pitch = i_width;
+ p_picture->i_planes = 3;
+ break;
+
+ case VLC_CODEC_I444:
+ case VLC_CODEC_J444:
+ p_picture->p[ Y_PLANE ].i_lines = i_height_aligned;
+ p_picture->p[ Y_PLANE ].i_visible_lines = i_height;
+ p_picture->p[ Y_PLANE ].i_pitch = i_width_aligned;
+ p_picture->p[ Y_PLANE ].i_visible_pitch = i_width;
+ p_picture->p[ U_PLANE ].i_lines = i_height_aligned;
+ p_picture->p[ U_PLANE ].i_visible_lines = i_height;
+ p_picture->p[ U_PLANE ].i_pitch = i_width_aligned;
+ p_picture->p[ U_PLANE ].i_visible_pitch = i_width;
+ p_picture->p[ V_PLANE ].i_lines = i_height_aligned;
+ p_picture->p[ V_PLANE ].i_visible_lines = i_height;
+ p_picture->p[ V_PLANE ].i_pitch = i_width_aligned;
+ p_picture->p[ V_PLANE ].i_visible_pitch = i_width;
+ p_picture->i_planes = 3;
+ break;
+
+ case VLC_CODEC_YUVA:
+ p_picture->p[ Y_PLANE ].i_lines = i_height_aligned;
+ p_picture->p[ Y_PLANE ].i_visible_lines = i_height;
+ p_picture->p[ Y_PLANE ].i_pitch = i_width_aligned;
+ p_picture->p[ Y_PLANE ].i_visible_pitch = i_width;
+ p_picture->p[ U_PLANE ].i_lines = i_height_aligned;
+ p_picture->p[ U_PLANE ].i_visible_lines = i_height;
+ p_picture->p[ U_PLANE ].i_pitch = i_width_aligned;
+ p_picture->p[ U_PLANE ].i_visible_pitch = i_width;
+ p_picture->p[ V_PLANE ].i_lines = i_height_aligned;
+ p_picture->p[ V_PLANE ].i_visible_lines = i_height;
+ p_picture->p[ V_PLANE ].i_pitch = i_width_aligned;
+ p_picture->p[ V_PLANE ].i_visible_pitch = i_width;
+ p_picture->p[ A_PLANE ].i_lines = i_height_aligned;
+ p_picture->p[ A_PLANE ].i_visible_lines = i_height;
+ p_picture->p[ A_PLANE ].i_pitch = i_width_aligned;
+ p_picture->p[ A_PLANE ].i_visible_pitch = i_width;
+ p_picture->i_planes = 4;
+ break;
+
+ case VLC_CODEC_YUVP:
+ p_picture->p->i_lines = i_height_aligned;
+ p_picture->p->i_visible_lines = i_height;
+ p_picture->p->i_pitch = i_width_aligned;
+ p_picture->p->i_visible_pitch = i_width;
+ p_picture->p->i_pixel_pitch = 8;
+ p_picture->i_planes = 1;
+ break;
+
+ case VLC_CODEC_Y211:
+ p_picture->p->i_lines = i_height_aligned;
+ p_picture->p->i_visible_lines = i_height;
+ p_picture->p->i_pitch = i_width_aligned;
+ p_picture->p->i_visible_pitch = i_width;
+ p_picture->p->i_pixel_pitch = 4;
+ p_picture->i_planes = 1;
+ break;
+
+ case VLC_CODEC_UYVY:
+ case VLC_CODEC_VYUY:
+ case VLC_CODEC_YUYV:
+ case VLC_CODEC_YVYU:
+ p_picture->p->i_lines = i_height_aligned;
+ p_picture->p->i_visible_lines = i_height;
+ p_picture->p->i_pitch = i_width_aligned * 2;
+ p_picture->p->i_visible_pitch = i_width * 2;
+ p_picture->p->i_pixel_pitch = 4;
+ p_picture->i_planes = 1;
+ break;
+
+ case VLC_CODEC_RGB8:
+ p_picture->p->i_lines = i_height_aligned;
+ p_picture->p->i_visible_lines = i_height;
+ p_picture->p->i_pitch = i_width_aligned;
+ p_picture->p->i_visible_pitch = i_width;
+ p_picture->p->i_pixel_pitch = 1;
+ p_picture->i_planes = 1;
+ break;
+
+ case VLC_CODEC_RGB15:
+ p_picture->p->i_lines = i_height_aligned;
+ p_picture->p->i_visible_lines = i_height;
+ p_picture->p->i_pitch = i_width_aligned * 2;
+ p_picture->p->i_visible_pitch = i_width * 2;
+ p_picture->p->i_pixel_pitch = 2;
+ p_picture->i_planes = 1;
+ break;
+
+ case VLC_CODEC_RGB16:
+ p_picture->p->i_lines = i_height_aligned;
+ p_picture->p->i_visible_lines = i_height;
+ p_picture->p->i_pitch = i_width_aligned * 2;
+ p_picture->p->i_visible_pitch = i_width * 2;
+ p_picture->p->i_pixel_pitch = 2;
+ p_picture->i_planes = 1;
+ break;
+
+ case VLC_CODEC_RGB24:
+ p_picture->p->i_lines = i_height_aligned;
+ p_picture->p->i_visible_lines = i_height;
+ p_picture->p->i_pitch = i_width_aligned * 3;
+ p_picture->p->i_visible_pitch = i_width * 3;
+ p_picture->p->i_pixel_pitch = 3;
+ p_picture->i_planes = 1;
+ break;
+
+ case VLC_CODEC_RGB32:
+ case VLC_CODEC_RGBA:
+ p_picture->p->i_lines = i_height_aligned;
+ p_picture->p->i_visible_lines = i_height;
+ p_picture->p->i_pitch = i_width_aligned * 4;
+ p_picture->p->i_visible_pitch = i_width * 4;
+ p_picture->p->i_pixel_pitch = 4;
+ p_picture->i_planes = 1;
+ break;
+
+ case VLC_CODEC_GREY:
+ case VLC_CODEC_RGBP:
+ p_picture->p->i_lines = i_height_aligned;
+ p_picture->p->i_visible_lines = i_height;
+ p_picture->p->i_pitch = i_width_aligned;
+ p_picture->p->i_visible_pitch = i_width;
+ p_picture->p->i_pixel_pitch = 1;
+ p_picture->i_planes = 1;
+ break;
+
+ default:
+ p_picture->i_planes = 0;
+ return VLC_EGENERIC;
+ }
+
+ return VLC_SUCCESS;
+}
+
/*****************************************************************************
*
*****************************************************************************/
void picture_Delete( picture_t *p_picture )
{
assert( p_picture && p_picture->i_refcount == 0 );
+ assert( p_picture->p_release_sys == NULL );
free( p_picture->p_q );
free( p_picture->p_data_orig );
fmt_out.i_sar_num =
fmt_out.i_sar_den = 1;
fmt_out.i_chroma = i_format;
- fmt_out.i_width = i_override_width;
- fmt_out.i_height = i_override_height;
- if( fmt_out.i_height == 0 && fmt_out.i_width > 0 )
+ /* compute original width/height */
+ unsigned int i_original_width;
+ unsigned int i_original_height;
+ if( fmt_in.i_sar_num >= fmt_in.i_sar_den )
{
- fmt_out.i_height = fmt_in.i_height * fmt_out.i_width / fmt_in.i_width;
- const int i_height = fmt_out.i_height * fmt_in.i_sar_den / fmt_in.i_sar_num;
- if( i_height > 0 )
- fmt_out.i_height = i_height;
+ i_original_width = fmt_in.i_width * fmt_in.i_sar_num / fmt_in.i_sar_den;
+ i_original_height = fmt_in.i_height;
}
else
{
- if( fmt_out.i_width == 0 && fmt_out.i_height > 0 )
- {
- fmt_out.i_width = fmt_in.i_width * fmt_out.i_height / fmt_in.i_height;
- }
- else
- {
- fmt_out.i_width = fmt_in.i_width;
- fmt_out.i_height = fmt_in.i_height;
- }
- const int i_width = fmt_out.i_width * fmt_in.i_sar_num / fmt_in.i_sar_den;
- if( i_width > 0 )
- fmt_out.i_width = i_width;
+ i_original_width = fmt_in.i_width;
+ i_original_height = fmt_in.i_height * fmt_in.i_sar_den / fmt_in.i_sar_num;
+ }
+
+ /* */
+ fmt_out.i_width = ( i_override_width < 0 ) ?
+ i_original_width : i_override_width;
+ fmt_out.i_height = ( i_override_height < 0 ) ?
+ i_original_height : i_override_height;
+
+ /* scale if only one direction is provided */
+ if( fmt_out.i_height == 0 && fmt_out.i_width > 0 )
+ {
+ fmt_out.i_height = fmt_in.i_height * fmt_out.i_width
+ * fmt_in.i_sar_den / fmt_in.i_width / fmt_in.i_sar_num;
+ }
+ else if( fmt_out.i_width == 0 && fmt_out.i_height > 0 )
+ {
+ fmt_out.i_width = fmt_in.i_width * fmt_out.i_height
+ * fmt_in.i_sar_num / fmt_in.i_height / fmt_in.i_sar_den;
}
image_handler_t *p_image = image_HandlerCreate( p_obj );
/*****************************************************************************
*
*****************************************************************************/
-