[MPlayer-dev-eng] [PATCH 2/x] Fix stereo3d stride align

Endre Kollár taxy443 at gmail.com
Sun Nov 14 13:33:24 CET 2010


2010/11/14 Reimar Döffinger <Reimar.Doeffinger at gmx.de>:
> On Wed, Oct 27, 2010 at 01:36:36AM +0200, Endre Kollár wrote:
>> -        vf->priv->width         = width / 2;
>> -        vf->priv->in.off_right  = vf->priv->width * 3;
>> -        vf->priv->in.stride     = vf->priv->width * 6;
>> +        vf->priv->width           = width / 2;
>> +        vf->priv->in.off_right_x  = vf->priv->width * 3;
>> +        vf->priv->in.stride       = vf->priv->width * 6;
>
> Those reindentations make it near impossible to figure out
> what changed, that's not ok.
> You can also further reduce the size by keeping the
> "off_right" name for what you here call off_right_x
> and add a row_right instead of off_right_y for example.
> (I don't really care so much about the specific names).
>

Fixed variable names.

>> -        dmpi = vf_get_image(vf->next, IMGFMT_RGB24, MP_IMGTYPE_TEMP, 0,
>> +        dmpi = vf_get_image(vf->next, IMGFMT_RGB24,
>> +                            MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
>
> This seems unrelated.

Skipped.

>
>> @@ -344,7 +360,6 @@ static int vf_open(vf_instance_t *vf, ch
>>      vf->uninit          = uninit;
>>      vf->put_image       = put_image;
>>      vf->query_format    = query_format;
>> -    vf->default_reqs    = VFCAP_ACCEPT_STRIDE;
>
> Why?

Skipped. I do not understand why it should be, if not in vf_scale.

> _______________________________________________
> MPlayer-dev-eng mailing list
> MPlayer-dev-eng at mplayerhq.hu
> https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
>
-------------- next part --------------
--- a/libmpcodecs/vf_stereo3d.c	2010-10-23 21:03:42.000000000 +0200
+++ b/libmpcodecs/vf_stereo3d.c	2010-11-14 13:03:47.000000000 +0100
@@ -64,6 +64,8 @@ typedef struct component {
     unsigned int height;
     unsigned int off_left;
     unsigned int off_right;
+    unsigned int row_left;
+    unsigned int row_right;
     unsigned int stride;
 } component;
 
@@ -140,6 +142,8 @@ static int config(struct vf_instance *vf
     vf->priv->in.height         = height;
     vf->priv->in.off_left       = 0;
     vf->priv->in.off_right      = 0;
+    vf->priv->in.row_left       = 0;
+    vf->priv->in.row_right      = 0;
     vf->priv->in.stride         = vf->priv->width * 3;
 
     //check input format
@@ -158,13 +162,13 @@ static int config(struct vf_instance *vf
         d_height               *= 2;
     case ABOVE_BELOW_LR:
         vf->priv->height        = height / 2;
-        vf->priv->in.off_right  = vf->priv->width * vf->priv->height * 3;
+        vf->priv->in.row_right  = vf->priv->height;
         break;
     case ABOVE_BELOW_2_RL:
         d_height               *= 2;
     case ABOVE_BELOW_RL:
         vf->priv->height        = height / 2;
-        vf->priv->in.off_left   = vf->priv->width * vf->priv->height * 3;
+        vf->priv->in.row_left   = vf->priv->height;
         break;
     default:
         mp_msg(MSGT_VFILTER, MSGL_WARN,
@@ -177,6 +181,8 @@ static int config(struct vf_instance *vf
     vf->priv->out.height        = vf->priv->height;
     vf->priv->out.off_left      = 0;
     vf->priv->out.off_right     = 0;
+    vf->priv->out.row_left      = 0;
+    vf->priv->out.row_right     = 0;
     vf->priv->out.stride        = vf->priv->width * 3;
 
     //check output format
@@ -208,17 +214,18 @@ static int config(struct vf_instance *vf
         d_height               /= 2;
     case ABOVE_BELOW_LR:
         vf->priv->out.height    = vf->priv->height * 2;
-        vf->priv->out.off_right = vf->priv->width * vf->priv->height * 3;
+        vf->priv->out.row_right = vf->priv->height;
         break;
     case ABOVE_BELOW_2_RL:
         d_height               /= 2;
     case ABOVE_BELOW_RL:
         vf->priv->out.height    = vf->priv->height * 2;
-        vf->priv->out.off_left  = vf->priv->width * vf->priv->height * 3;
+        vf->priv->out.row_left  = vf->priv->height;
         break;
     case MONO_R:
         //same as MONO_L only needs switching of input offsets
         vf->priv->in.off_left   = vf->priv->in.off_right;
+        vf->priv->in.row_left   = vf->priv->in.row_right;
         //nobreak;
     case MONO_L:
         //use default settings
@@ -240,13 +247,22 @@ static int config(struct vf_instance *vf
 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
 {
     mp_image_t *dmpi;
+    int in_off_left, in_off_right, out_off_left, out_off_right;
+
     if (vf->priv->in.fmt == vf->priv->out.fmt) { //nothing to do
         dmpi = mpi;
     } else {
         dmpi = vf_get_image(vf->next, IMGFMT_RGB24, MP_IMGTYPE_TEMP, 0,
                             vf->priv->out.width, vf->priv->out.height);
-        dmpi->h = vf->priv->out.height;
-        dmpi->width = vf->priv->out.width;
+        in_off_left    = vf->priv->in.row_left   * mpi->stride[0]  +
+                         vf->priv->in.off_left;
+        in_off_right   = vf->priv->in.row_right  * mpi->stride[0]  +
+                         vf->priv->in.off_right;
+        out_off_left   = vf->priv->out.row_left  * dmpi->stride[0] +
+                         vf->priv->out.off_left;
+        out_off_right  = vf->priv->out.row_right * dmpi->stride[0] +
+                         vf->priv->out.off_right;
+
         switch (vf->priv->out.fmt) {
         case SIDE_BY_SIDE_LR:
         case SIDE_BY_SIDE_RL:
@@ -254,27 +270,27 @@ static int put_image(struct vf_instance 
         case ABOVE_BELOW_RL:
         case ABOVE_BELOW_2_LR:
         case ABOVE_BELOW_2_RL:
-            memcpy_pic(dmpi->planes[0] + vf->priv->out.off_left,
-                       mpi->planes[0] + vf->priv->in.off_left,
+            memcpy_pic(dmpi->planes[0] + out_off_left,
+                       mpi->planes[0] + in_off_left,
                        3 * vf->priv->width,
                        vf->priv->height,
-                       vf->priv->out.stride,
-                       vf->priv->in.stride);
-            memcpy_pic(dmpi->planes[0] + vf->priv->out.off_right,
-                       mpi->planes[0] + vf->priv->in.off_right,
+                       dmpi->stride[0],
+                       mpi->stride[0]);
+            memcpy_pic(dmpi->planes[0] + out_off_right,
+                       mpi->planes[0] + in_off_right,
                        3 * vf->priv->width,
                        vf->priv->height,
-                       vf->priv->out.stride,
-                       vf->priv->in.stride);
+                       dmpi->stride[0],
+                       mpi->stride[0]);
             break;
         case MONO_L:
         case MONO_R:
             memcpy_pic(dmpi->planes[0],
-                       mpi->planes[0] + vf->priv->in.off_left,
+                       mpi->planes[0] + in_off_left,
                        3 * vf->priv->width,
                        vf->priv->height,
-                       vf->priv->out.stride,
-                       vf->priv->in.stride);
+                       dmpi->stride[0],
+                       mpi->stride[0]);
             break;
         case ANAGLYPH_RC_GRAY:
         case ANAGLYPH_RC_HALF:
@@ -296,11 +312,9 @@ static int put_image(struct vf_instance 
                 ana_matrix[i] = vf->priv->ana_matrix[i];
 
             for (y = 0; y < vf->priv->out.height; y++) {
-                o   = vf->priv->out.stride * y;
-                il  = vf->priv->in.off_left  + y *
-                      vf->priv->in.stride;
-                ir  = vf->priv->in.off_right + y *
-                      vf->priv->in.stride;
+                o   = dmpi->stride[0] * y;
+                il  = in_off_left  + y * mpi->stride[0];
+                ir  = in_off_right + y * mpi->stride[0];
                 for (x = 0; x < out_width; x++) {
                     dest[o    ]  = ana_convert(
                                    ana_matrix[0], source + il, source + ir); //red out


More information about the MPlayer-dev-eng mailing list