+/*****************************************************************************
+ * Flags used to describe picture format - see http://www.webartz.com/fourcc/
+ *****************************************************************************/
+
+/* Packed RGB formats */
+#define FOURCC_BI_RGB 0x00000000 /* RGB for 8bpp */
+#define FOURCC_RGB 0x32424752 /* alias for BI_RGB */
+#define FOURCC_BI_BITFIELDS 0x00000003 /* RGB, for 16, 24, 32bpp */
+#define FOURCC_RV15 0x35315652 /* RGB 15bpp, 0x1f, 0x7e0, 0xf800 */
+#define FOURCC_RV16 0x36315652 /* RGB 16bpp, 0x1f, 0x3e0, 0x7c00 */
+
+/* Planar YUV formats */
+#define FOURCC_I420 0x30323449 /* Planar 4:2:0, Y:U:V */
+#define FOURCC_IYUV 0x56555949 /* alias for I420 */
+#define FOURCC_YV12 0x32315659 /* Planar 4:2:0, Y:V:U */
+
+/* Packed YUV formats */
+#define FOURCC_IUYV 0x56595549 /* Packed 4:2:2, U:Y:V:Y, interlaced */
+#define FOURCC_UYVY 0x59565955 /* Packed 4:2:2, U:Y:V:Y */
+#define FOURCC_UYNV 0x564e5955 /* alias for UYVY */
+#define FOURCC_Y422 0x32323459 /* alias for UYVY */
+#define FOURCC_cyuv 0x76757963 /* Packed 4:2:2, U:Y:V:Y, reverted */
+#define FOURCC_YUY2 0x32595559 /* Packed 4:2:2, Y:U:Y:V */
+#define FOURCC_YUNV 0x564e5559 /* alias for YUY2 */
+#define FOURCC_YVYU 0x55585659 /* Packed 4:2:2, Y:V:Y:U */
+#define FOURCC_Y211 0x31313259 /* Packed 2:1:1, Y:U:Y:V */
+
+/* Custom formats which we use but which don't exist in the fourcc database */
+#define FOURCC_I422 0x32323449 /* Planar 4:2:2, Y:U:V */
+#define FOURCC_I444 0x34343449 /* Planar 4:4:4, Y:U:V */
+
+/* Plane indices */
+#define Y_PLANE 0
+#define U_PLANE 1
+#define V_PLANE 2
+
+/* Shortcuts */
+#define Y_PIXELS p[Y_PLANE].p_pixels
+#define U_PIXELS p[U_PLANE].p_pixels
+#define V_PIXELS p[V_PLANE].p_pixels
+
+/*****************************************************************************
+ * vout_CopyPicture: copy a picture to another one
+ *****************************************************************************
+ * This function takes advantage of the image format, and reduces the
+ * number of calls to memcpy() to the minimum. Source and destination
+ * images must have same width, height, and chroma.
+ *****************************************************************************/
+static __inline__ void vout_CopyPicture( picture_t *p_src, picture_t *p_dest )
+{
+ int i;
+
+ for( i = 0; i < p_src->i_planes ; i++ )
+ {
+ if( p_src->p[i].i_pitch == p_dest->p[i].i_pitch )
+ {
+ if( p_src->p[i].b_margin )
+ {
+ /* If p_src->b_margin is set, p_dest->b_margin must be set */
+ if( p_dest->p[i].b_hidden )
+ {
+ /* There are margins, but they are hidden : perfect ! */
+ FAST_MEMCPY( p_dest->p[i].p_pixels, p_src->p[i].p_pixels,
+ p_src->p[i].i_pitch * p_src->p[i].i_lines );
+ continue;
+ }
+ else
+ {
+ /* We can't directly copy the margin. Too bad. */
+ }
+ }
+ else
+ {
+ /* Same pitch, no margins : perfect ! */
+ FAST_MEMCPY( p_dest->p[i].p_pixels, p_src->p[i].p_pixels,
+ p_src->p[i].i_pitch * p_src->p[i].i_lines );
+ continue;
+ }
+ }
+ else
+ {
+ /* Pitch values are different */
+ }
+
+ /* We need to proceed line by line */
+ {
+ u8 *p_in = p_src->p[i].p_pixels, *p_out = p_dest->p[i].p_pixels;
+ int i_line;
+
+ for( i_line = p_src->p[i].i_lines; i_line--; )
+ {
+ FAST_MEMCPY( p_out, p_in, p_src->p[i].i_visible_bytes );
+ p_in += p_src->p[i].i_pitch;
+ p_out += p_dest->p[i].i_pitch;
+ }
+ }
+ }
+}