* This function will be accessed by plugins. It calculates the relative
* position of the output window and the image window.
*/
-void vout_PlacePicture( vout_thread_t *p_vout,
+void vout_PlacePicture( const vout_thread_t *p_vout,
unsigned int i_width, unsigned int i_height,
- unsigned int *pi_x, unsigned int *pi_y,
- unsigned int *pi_width, unsigned int *pi_height )
+ unsigned int *restrict pi_x,
+ unsigned int *restrict pi_y,
+ unsigned int *restrict pi_width,
+ unsigned int *restrict pi_height )
{
- if( (i_width <= 0) || (i_height <=0) )
+ if( i_width <= 0 || i_height <= 0 )
{
*pi_width = *pi_height = *pi_x = *pi_y = 0;
return;
}
- if( p_vout->b_scale )
+ if( p_vout->b_autoscale )
{
*pi_width = i_width;
*pi_height = i_height;
}
else
{
- *pi_width = __MIN( i_width, p_vout->fmt_in.i_visible_width );
- *pi_height = __MIN( i_height, p_vout->fmt_in.i_visible_height );
+ int i_zoom = p_vout->i_zoom;
+ /* be realistic, scaling factor confined between .2 and 10. */
+ if( i_zoom > 10 * ZOOM_FP_FACTOR ) i_zoom = 10 * ZOOM_FP_FACTOR;
+ else if( i_zoom < ZOOM_FP_FACTOR / 5 ) i_zoom = ZOOM_FP_FACTOR / 5;
+
+ unsigned int i_original_width, i_original_height;
+
+ if( p_vout->fmt_in.i_sar_num >= p_vout->fmt_in.i_sar_den )
+ {
+ i_original_width = p_vout->fmt_in.i_visible_width *
+ p_vout->fmt_in.i_sar_num / p_vout->fmt_in.i_sar_den;
+ i_original_height = p_vout->fmt_in.i_visible_height;
+ }
+ else
+ {
+ i_original_width = p_vout->fmt_in.i_visible_width;
+ i_original_height = p_vout->fmt_in.i_visible_height *
+ p_vout->fmt_in.i_sar_den / p_vout->fmt_in.i_sar_num;
+ }
+#ifdef WIN32
+ /* On windows, inner video window exceeding container leads to black screen */
+ *pi_width = __MIN( i_width, i_original_width * i_zoom / ZOOM_FP_FACTOR );
+ *pi_height = __MIN( i_height, i_original_height * i_zoom / ZOOM_FP_FACTOR );
+#else
+ *pi_width = i_original_width * i_zoom / ZOOM_FP_FACTOR ;
+ *pi_height = i_original_height * i_zoom / ZOOM_FP_FACTOR ;
+#endif
}
- int64_t i_scaled_width = p_vout->fmt_in.i_visible_width * (int64_t)p_vout->fmt_in.i_sar_num *
+ int64_t i_scaled_width = p_vout->fmt_in.i_visible_width * (int64_t)p_vout->fmt_in.i_sar_num *
*pi_height / p_vout->fmt_in.i_visible_height / p_vout->fmt_in.i_sar_den;
- int64_t i_scaled_height = p_vout->fmt_in.i_visible_height * (int64_t)p_vout->fmt_in.i_sar_den *
+ int64_t i_scaled_height = p_vout->fmt_in.i_visible_height * (int64_t)p_vout->fmt_in.i_sar_den *
*pi_width / p_vout->fmt_in.i_visible_width / p_vout->fmt_in.i_sar_num;
if( i_scaled_width <= 0 || i_scaled_height <= 0 )
p_pic->pf_unlock = NULL;
p_pic->i_refcount = 0;
- p_pic->p_q = NULL;
+ p_pic->i_qtype = QTYPE_NONE;
p_pic->i_qstride = 0;
- p_pic->i_qtype = 0;
+ p_pic->p_q = NULL;
vout_InitFormat( &p_pic->format, i_chroma, i_width, i_height, i_aspect );
*****************************************************************************/
picture_t *picture_New( vlc_fourcc_t i_chroma, int i_width, int i_height, int i_aspect )
{
- picture_t *p_picture = malloc( sizeof(*p_picture) );
-
+ picture_t *p_picture = calloc( 1, sizeof(*p_picture) );
if( !p_picture )
return NULL;
- memset( p_picture, 0, sizeof(*p_picture) );
if( __vout_AllocatePicture( NULL, p_picture,
i_chroma, i_width, i_height, i_aspect ) )
{