Index: libmpcodecs/vf_re3d.c
===================================================================
--- libmpcodecs/vf_re3d.c	(Revision 0)
+++ libmpcodecs/vf_re3d.c	(Revision 0)
@@ -0,0 +1,185 @@
+/*
+ * Copyright (C) 2012 Daniel Baudisch <daniel.baudisch@web.de>
+ *
+ * This file is part of MPlayer.
+ *
+ * MPlayer is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MPlayer is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with MPlayer; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "vf.h"
+#include "libvo/fastmemcpy.h"
+
+#include "m_struct.h"
+
+
+//===========================================================================//
+
+#define POLARIZED              1
+#define SIDEBYSIDE             2
+
+static struct vf_priv_s {
+    int swap;
+    int srcFormat;
+    int dstFormat;
+} const vf_priv_dflt = {
+    0, SIDEBYSIDE, POLARIZED
+};
+
+/***************************************************************************/
+
+/**
+ * Transforms the given frame from a defined 3d representation to another, e.g
+ * from side-by-side (pictures for left and right eye are side by side) to polarized
+ * (pictures for left and right eye are coded in odd, respectively even, numbered lines).
+ * Currently, the conversion requires to scale the embedded pictures, which is done
+ * using the nearest neighbor method.
+ */
+static void re3d(uint8_t *dst, uint8_t *src, int w, int h, int dstStride, int srcStride, int srcFormat, int dstFormat, int swap){
+    int x, y;
+    int s;
+
+    if(srcFormat==POLARIZED && dstFormat==SIDEBYSIDE) {
+        uint8_t *srcP1;
+        uint8_t *srcP2;
+        uint8_t *dstP1a,  *dstP1b;
+        uint8_t *dstP2a,  *dstP2b;
+        for(y=0; y < h; y+=2) {
+            srcP1 = src + srcStride * (y + 1 - swap);
+            srcP2 = src + srcStride * (y + swap);
+            dstP1a = dst + dstStride * y;
+            dstP1b = dstP1a + dstStride;
+            dstP2a = dst + dstStride * y + (w >> 1);
+            dstP2b = dstP2a + dstStride;
+            for(x=0; x < (w >> 1); x++) {
+                *dstP1a++ = (*srcP1); *dstP1b++ = (*srcP1); srcP1+=2;
+                *dstP2a++ = (*srcP2); *dstP2b++ = (*srcP2); srcP2+=2;
+            }
+        }
+    } else if(srcFormat==SIDEBYSIDE && dstFormat==POLARIZED) {
+        uint8_t *srcP;
+        uint8_t *dstP;
+        for(y=0; y < h; y++) {
+            s = swap ^ (y & 1);
+            srcP = src + srcStride * y + s * (w >> 1);
+            dstP = dst + dstStride * y;
+            for(x=0; x < (w >> 1); x++) {
+                *dstP++ = (*srcP);
+                *dstP++ = (*srcP++);
+            }
+        }
+    } else if(srcFormat==dstFormat && swap==1) {
+        uint8_t *srcP1;
+        uint8_t *srcP2;
+        uint8_t *dstP1;
+        uint8_t *dstP2;
+        if(srcFormat==SIDEBYSIDE) {
+            for(y=0; y < h; y++) {
+                srcP1 = src + srcStride * y;
+                srcP2 = src + srcStride * y + (w >> 1);
+                dstP1 = dst + dstStride * y + (w >> 1);
+                dstP2 = dst + dstStride * y;
+                for(x=0; x < (w >> 1); x++) {
+                    *dstP1++ = (*srcP1++);
+                    *dstP2++ = (*srcP2++);
+                }
+            }
+        } else if(srcFormat==POLARIZED) {
+            for(y=0; y < h; y+=2) {
+                srcP1 = src + srcStride * y;
+                srcP2 = src + srcStride * (y + 1);
+                dstP1 = dst + dstStride * (y + 1);
+                dstP2 = dst + dstStride * y;
+                for(x=0; x < w; x++) {
+                    *dstP1++ = (*srcP1++);
+                    *dstP2++ = (*srcP2++);
+                }
+            }
+        }
+    } else {
+        for(y=0; y < h; y++) {
+            fast_memcpy(dst + dstStride*y, src + srcStride*y, w);
+        }
+    }
+}
+
+static int config(struct vf_instance *vf,
+        int width, int height, int d_width, int d_height,
+    unsigned int flags, unsigned int outfmt){
+    d_width = width;
+    d_height = height;
+    return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
+}
+
+static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
+    int w;
+
+    mp_image_t *dmpi=vf_get_image(vf->next,mpi->imgfmt,
+        MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
+        mpi->w,mpi->h);
+
+    if(mpi->flags & MP_IMGFLAG_PLANAR)
+        w = mpi->w;
+    else
+        w = mpi->w * mpi->bpp/8;
+
+    re3d(dmpi->planes[0], mpi->planes[0], w, mpi->h, dmpi->stride[0], mpi->stride[0], vf->priv->srcFormat, vf->priv->dstFormat, vf->priv->swap);
+
+    if(mpi->flags&MP_IMGFLAG_PLANAR){
+        int cw= mpi->w >> mpi->chroma_x_shift;
+        int ch= mpi->h >> mpi->chroma_y_shift;
+
+        re3d(dmpi->planes[1], mpi->planes[1], cw,ch, dmpi->stride[1], mpi->stride[1], vf->priv->srcFormat, vf->priv->dstFormat, vf->priv->swap);
+        re3d(dmpi->planes[2], mpi->planes[2], cw,ch, dmpi->stride[2], mpi->stride[2], vf->priv->srcFormat, vf->priv->dstFormat, vf->priv->swap);
+    }
+
+    return vf_next_put_image(vf,dmpi, pts);
+}
+
+//===========================================================================//
+
+static int vf_open(vf_instance_t *vf, char *args){
+
+    vf->config=config;
+    vf->put_image=put_image;
+
+    return 1;
+}
+
+#undef ST_OFF
+#define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f)
+static const m_option_t vf_opts_fields[] = {
+  {"swap", ST_OFF(swap), CONF_TYPE_INT, M_OPT_MIN, 0,0, NULL},
+  {"sf", ST_OFF(srcFormat), CONF_TYPE_INT, M_OPT_RANGE, 1, 2, NULL},
+  {"df", ST_OFF(dstFormat), CONF_TYPE_INT, M_OPT_RANGE, 1, 2, NULL},
+  { NULL, NULL, 0, 0, 0, 0,  NULL }
+};
+
+static const m_struct_t vf_opts = {
+  "re3d",
+  sizeof(struct vf_priv_s),
+  &vf_priv_dflt,
+  vf_opts_fields
+};
+
+const vf_info_t vf_info_re3d = {
+    "re3d",
+    "re3d",
+    "Daniel Baudisch",
+    "",
+    vf_open,
+    &vf_opts
+};
+
+//===========================================================================//
Index: libmpcodecs/vf.c
===================================================================
--- libmpcodecs/vf.c	(Revision 34647)
+++ libmpcodecs/vf.c	(Arbeitskopie)
@@ -42,6 +42,7 @@
 #include "libvo/fastmemcpy.h"
 #include "libavutil/mem.h"
 
+extern const vf_info_t vf_info_re3d;
 extern const vf_info_t vf_info_1bpp;
 extern const vf_info_t vf_info_2xsai;
 extern const vf_info_t vf_info_ass;
@@ -123,6 +124,7 @@
 
 // list of available filters:
 static const vf_info_t* const filter_list[]={
+    &vf_info_re3d,
     &vf_info_rectangle,
 #ifdef HAVE_POSIX_SELECT
     &vf_info_bmovl,
Index: Makefile
===================================================================
--- Makefile	(Revision 34647)
+++ Makefile	(Arbeitskopie)
@@ -413,6 +413,7 @@
               libmpcodecs/vf_rgbtest.c \
               libmpcodecs/vf_rotate.c \
               libmpcodecs/vf_sab.c \
+              libmpcodecs/vf_re3d.c \
               libmpcodecs/vf_scale.c \
               libmpcodecs/vf_smartblur.c \
               libmpcodecs/vf_softpulldown.c \

-- 
 SMS schreiben mit WEB.DE FreeMail - einfach, schnell und
kostenguenstig. Jetzt gleich testen! http://f.web.de/?mc=021192
