#include <vlc_vout.h>
#include <vlc_osd.h>
#include <vlc_filter.h>
+#include <vlc_image.h>
+#include <vlc_block.h>
+
#include "vout_pictures.h"
#include "vout_internal.h"
msg_Err( p_vout, "picture to display %p has invalid status %d",
p_pic, p_pic->i_status );
}
+ p_vout->p->i_picture_qtype = p_pic->i_qtype;
vlc_mutex_unlock( &p_vout->picture_lock );
}
* 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 );
*/
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
+ };
+ static const vlc_fourcc_t p_I422[] = {
+ FOURCC_I422, FOURCC_J422, 0
+ };
+ static const vlc_fourcc_t p_I440[] = {
+ FOURCC_I440, FOURCC_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
+ };
+ static const vlc_fourcc_t *pp_fcc[] = {
+ p_I420, p_I422, p_I440, p_I444, p_UYVY, p_YUYV, p_GREY, NULL
+ };
+
/* If they are the same, they are the same ! */
if( i_chroma == i_amorhc )
- {
return 1;
- }
/* Check for equivalence classes */
- switch( i_chroma )
+ for( int i = 0; pp_fcc[i] != NULL; i++ )
{
- case FOURCC_I420:
- case FOURCC_IYUV:
- case FOURCC_YV12:
- switch( i_amorhc )
- {
- case FOURCC_I420:
- case FOURCC_IYUV:
- case FOURCC_YV12:
- return 1;
-
- default:
- return 0;
- }
-
- case FOURCC_UYVY:
- case FOURCC_UYNV:
- case FOURCC_Y422:
- switch( i_amorhc )
- {
- case FOURCC_UYVY:
- case FOURCC_UYNV:
- case FOURCC_Y422:
- return 1;
-
- default:
- return 0;
- }
-
- case FOURCC_YUY2:
- case FOURCC_YUNV:
- switch( i_amorhc )
- {
- case FOURCC_YUY2:
- case FOURCC_YUNV:
- return 1;
-
- default:
- return 0;
- }
-
- case FOURCC_GREY:
- case FOURCC_Y800:
- case FOURCC_Y8:
- switch( i_amorhc )
- {
- case FOURCC_GREY:
- case FOURCC_Y800:
- case FOURCC_Y8:
- return 1;
-
- default:
- return 0;
- }
-
- default:
- return 0;
+ bool b_fcc1 = false;
+ bool b_fcc2 = false;
+ for( int j = 0; pp_fcc[i][j] != 0; j++ )
+ {
+ if( i_chroma == pp_fcc[i][j] )
+ b_fcc1 = true;
+ if( i_amorhc == pp_fcc[i][j] )
+ b_fcc2 = true;
+ }
+ if( b_fcc1 && b_fcc2 )
+ return 1;
}
+ return 0;
}
/*****************************************************************************
/*****************************************************************************
*
*****************************************************************************/
+int picture_Export( vlc_object_t *p_obj,
+ block_t **pp_image,
+ video_format_t *p_fmt,
+ picture_t *p_picture,
+ vlc_fourcc_t i_format,
+ int i_override_width, int i_override_height )
+{
+ /* */
+ video_format_t fmt_in = p_picture->format;
+ if( fmt_in.i_sar_num <= 0 || fmt_in.i_sar_den <= 0 )
+ {
+ fmt_in.i_sar_num =
+ fmt_in.i_sar_den = 1;
+ }
+
+ /* */
+ video_format_t fmt_out;
+ memset( &fmt_out, 0, sizeof(fmt_out) );
+ 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 )
+ {
+ 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;
+ }
+ 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;
+ }
+
+ image_handler_t *p_image = image_HandlerCreate( p_obj );
+
+ block_t *p_block = image_Write( p_image, p_picture, &fmt_in, &fmt_out );
+
+ image_HandlerDelete( p_image );
+
+ if( !p_block )
+ return VLC_EGENERIC;
+
+ p_block->i_pts =
+ p_block->i_dts = p_picture->date;
+
+ if( p_fmt )
+ *p_fmt = fmt_out;
+ *pp_image = p_block;
+
+ return VLC_SUCCESS;
+}
+
+/*****************************************************************************
+ *
+ *****************************************************************************/