+/*****************************************************************************
+ * OutputCoords: compute the dimensions of the destination image
+ *****************************************************************************
+ * This based on some code in SetBufferPicture... , it is also in use in the
+ * the xvideo plugin. Maybe we should think about putting standard video
+ * processing functions in a common library ?
+ *****************************************************************************/
+static void OutputCoords( const picture_t *p_pic, const boolean_t scale,
+ const int win_w, const int win_h,
+ int *dx, int *dy, int *w, int *h )
+{
+ if( !scale )
+ {
+ *w = p_pic->i_width; *h = p_pic->i_height;
+ }
+ else
+ {
+ *w = win_w;
+ switch( p_pic->i_aspect_ratio )
+ {
+ case AR_3_4_PICTURE:
+ *h = win_w * 3 / 4;
+ break;
+
+ case AR_16_9_PICTURE:
+ *h = win_w * 9 / 16;
+ break;
+
+ case AR_221_1_PICTURE:
+ *h = win_w * 100 / 221;
+ break;
+
+ case AR_SQUARE_PICTURE:
+ default:
+ *h = win_w * p_pic->i_height / p_pic->i_width;
+ break;
+ }
+
+ if( *h > win_h )
+ {
+ *h = win_h;
+ switch( p_pic->i_aspect_ratio )
+ {
+ case AR_3_4_PICTURE:
+ *w = win_h * 4 / 3;
+ break;
+
+ case AR_16_9_PICTURE:
+ *w = win_h * 16 / 9;
+ break;
+
+ case AR_221_1_PICTURE:
+ *w = win_h * 221 / 100;
+ break;
+
+ case AR_SQUARE_PICTURE:
+ default:
+ *w = win_h * p_pic->i_width / p_pic->i_height;
+ break;
+ }
+ }
+ }
+
+ /* Set picture position */
+ *dx = (win_w - *w) / 2;
+ *dy = (win_h - *h) / 2;
+}