Browse code

lavfi/stereo3d: Set SAR for every output frame.

Fixes ticket #6672.

Carl Eugen Hoyos authored on 2017/09/19 06:10:06
Showing 1 changed files
... ...
@@ -150,6 +150,7 @@ typedef struct Stereo3DContext {
150 150
     AVFrame *prev;
151 151
     int blanks;
152 152
     int in_off_left[4], in_off_right[4];
153
+    AVRational aspect;
153 154
     Stereo3DDSPContext dsp;
154 155
 } Stereo3DContext;
155 156
 
... ...
@@ -359,11 +360,11 @@ static int config_output(AVFilterLink *outlink)
359 359
     AVFilterContext *ctx = outlink->src;
360 360
     AVFilterLink *inlink = ctx->inputs[0];
361 361
     Stereo3DContext *s = ctx->priv;
362
-    AVRational aspect = inlink->sample_aspect_ratio;
363 362
     AVRational fps = inlink->frame_rate;
364 363
     AVRational tb = inlink->time_base;
365 364
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(outlink->format);
366 365
     int ret;
366
+    s->aspect = inlink->sample_aspect_ratio;
367 367
 
368 368
     switch (s->in.format) {
369 369
     case INTERLEAVE_COLS_LR:
... ...
@@ -404,25 +405,25 @@ static int config_output(AVFilterLink *outlink)
404 404
 
405 405
     switch (s->in.format) {
406 406
     case SIDE_BY_SIDE_2_LR:
407
-        aspect.num     *= 2;
407
+        s->aspect.num  *= 2;
408 408
     case SIDE_BY_SIDE_LR:
409 409
         s->width        = inlink->w / 2;
410 410
         s->in.off_right = s->width;
411 411
         break;
412 412
     case SIDE_BY_SIDE_2_RL:
413
-        aspect.num     *= 2;
413
+        s->aspect.num  *= 2;
414 414
     case SIDE_BY_SIDE_RL:
415 415
         s->width        = inlink->w / 2;
416 416
         s->in.off_left  = s->width;
417 417
         break;
418 418
     case ABOVE_BELOW_2_LR:
419
-        aspect.den     *= 2;
419
+        s->aspect.den  *= 2;
420 420
     case ABOVE_BELOW_LR:
421 421
         s->in.row_right =
422 422
         s->height       = inlink->h / 2;
423 423
         break;
424 424
     case ABOVE_BELOW_2_RL:
425
-        aspect.den     *= 2;
425
+        s->aspect.den  *= 2;
426 426
     case ABOVE_BELOW_RL:
427 427
         s->in.row_left  =
428 428
         s->height       = inlink->h / 2;
... ...
@@ -486,19 +487,19 @@ static int config_output(AVFilterLink *outlink)
486 486
         break;
487 487
     }
488 488
     case SIDE_BY_SIDE_2_LR:
489
-        aspect.den      *= 2;
489
+        s->aspect.den   *= 2;
490 490
     case SIDE_BY_SIDE_LR:
491 491
         s->out.width     = s->width * 2;
492 492
         s->out.off_right = s->width;
493 493
         break;
494 494
     case SIDE_BY_SIDE_2_RL:
495
-        aspect.den      *= 2;
495
+        s->aspect.den   *= 2;
496 496
     case SIDE_BY_SIDE_RL:
497 497
         s->out.width     = s->width * 2;
498 498
         s->out.off_left  = s->width;
499 499
         break;
500 500
     case ABOVE_BELOW_2_LR:
501
-        aspect.num      *= 2;
501
+        s->aspect.num   *= 2;
502 502
     case ABOVE_BELOW_LR:
503 503
         s->out.height    = s->height * 2;
504 504
         s->out.row_right = s->height;
... ...
@@ -514,7 +515,7 @@ static int config_output(AVFilterLink *outlink)
514 514
         s->out.row_right = s->height + s->blanks;
515 515
         break;
516 516
     case ABOVE_BELOW_2_RL:
517
-        aspect.num      *= 2;
517
+        s->aspect.num   *= 2;
518 518
     case ABOVE_BELOW_RL:
519 519
         s->out.height    = s->height * 2;
520 520
         s->out.row_left  = s->height;
... ...
@@ -576,7 +577,7 @@ static int config_output(AVFilterLink *outlink)
576 576
     outlink->h = s->out.height;
577 577
     outlink->frame_rate = fps;
578 578
     outlink->time_base = tb;
579
-    outlink->sample_aspect_ratio = aspect;
579
+    outlink->sample_aspect_ratio = s->aspect;
580 580
 
581 581
     if ((ret = av_image_fill_linesizes(s->linesize, outlink->format, s->width)) < 0)
582 582
         return ret;
... ...
@@ -1075,6 +1076,7 @@ copy:
1075 1075
         av_frame_free(&s->prev);
1076 1076
         av_frame_free(&inpicref);
1077 1077
     }
1078
+    out->sample_aspect_ratio = s->aspect;
1078 1079
     return ff_filter_frame(outlink, out);
1079 1080
 }
1080 1081