Browse code

lavfi/stereo3d: fix interleave row output modes

Linesizes that did not match output width produced several artifacts.

Signed-off-by: Paul B Mahol <onemda@gmail.com>

Paul B Mahol authored on 2013/04/18 02:27:02
Showing 1 changed files
... ...
@@ -63,6 +63,7 @@ typedef struct StereoComponent {
63 63
     enum StereoCode format;
64 64
     int width, height;
65 65
     int off_left, off_right;
66
+    int off_lstep, off_rstep;
66 67
     int row_left, row_right;
67 68
 } StereoComponent;
68 69
 
... ...
@@ -229,6 +230,8 @@ static int config_output(AVFilterLink *outlink)
229 229
     s->in.height    =
230 230
     s->height       = inlink->h;
231 231
     s->row_step     = 1;
232
+    s->in.off_lstep =
233
+    s->in.off_rstep =
232 234
     s->in.off_left  =
233 235
     s->in.off_right =
234 236
     s->in.row_left  =
... ...
@@ -266,6 +269,8 @@ static int config_output(AVFilterLink *outlink)
266 266
 
267 267
     s->out.width     = s->width;
268 268
     s->out.height    = s->height;
269
+    s->out.off_lstep =
270
+    s->out.off_rstep =
269 271
     s->out.off_left  =
270 272
     s->out.off_right =
271 273
     s->out.row_left  =
... ...
@@ -315,14 +320,14 @@ static int config_output(AVFilterLink *outlink)
315 315
     case INTERLEAVE_ROWS_LR:
316 316
         s->row_step      = 2;
317 317
         s->height        = s->height / 2;
318
-        s->out.off_right = s->width * 3;
319
-        s->in.off_right += s->in.width * 3;
318
+        s->out.off_rstep =
319
+        s->in.off_rstep  = 1;
320 320
         break;
321 321
     case INTERLEAVE_ROWS_RL:
322 322
         s->row_step      = 2;
323 323
         s->height        = s->height / 2;
324
-        s->out.off_left  = s->width * 3;
325
-        s->in.off_left  += s->in.width * 3;
324
+        s->out.off_lstep =
325
+        s->in.off_lstep  = 1;
326 326
         break;
327 327
     case MONO_R:
328 328
         s->in.off_left   = s->in.off_right;
... ...
@@ -368,10 +373,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
368 368
     }
369 369
     av_frame_copy_props(out, inpicref);
370 370
 
371
-    in_off_left   = s->in.row_left  * inpicref->linesize[0] + s->in.off_left;
372
-    in_off_right  = s->in.row_right * inpicref->linesize[0] + s->in.off_right;
373
-    out_off_left  = s->out.row_left  * out->linesize[0] + s->out.off_left;
374
-    out_off_right = s->out.row_right * out->linesize[0] + s->out.off_right;
371
+    in_off_left   = (s->in.row_left   + s->in.off_lstep)  * inpicref->linesize[0] + s->in.off_left;
372
+    in_off_right  = (s->in.row_right  + s->in.off_rstep)  * inpicref->linesize[0] + s->in.off_right;
373
+    out_off_left  = (s->out.row_left  + s->out.off_lstep) * out->linesize[0] + s->out.off_left;
374
+    out_off_right = (s->out.row_right + s->out.off_rstep) * out->linesize[0] + s->out.off_right;
375 375
 
376 376
     switch (s->out.format) {
377 377
     case SIDE_BY_SIDE_LR: