[08/12] avfilter/vf_framepack: Check and update frame_rate

Message ID 1445977054-15625-9-git-send-email-stebbins@jetheaddev.com
State New
Headers show

Commit Message

John Stebbins Oct. 27, 2015, 8:17 p.m.
From: Michael Niedermayer <michaelni@gmx.at>

The frame_rate update was missing leaving the output frame rate
wrong.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit a46a23d30fea9c8a5570e07ec4d9c9b4eaa6eb4f)
---
 libavfilter/vf_framepack.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Comments

Vittorio Giovara Oct. 28, 2015, 1:58 a.m. | #1
On Tue, Oct 27, 2015 at 9:17 PM, John Stebbins <stebbins@jetheaddev.com> wrote:
> From: Michael Niedermayer <michaelni@gmx.at>
>
> The frame_rate update was missing leaving the output frame rate
> wrong.
>
> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> (cherry picked from commit a46a23d30fea9c8a5570e07ec4d9c9b4eaa6eb4f)
> ---
>  libavfilter/vf_framepack.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/libavfilter/vf_framepack.c b/libavfilter/vf_framepack.c
> index e9806ba..10c4add 100644
> --- a/libavfilter/vf_framepack.c
> +++ b/libavfilter/vf_framepack.c
> @@ -82,6 +82,7 @@ static int config_output(AVFilterLink *outlink)
>      int width            = ctx->inputs[LEFT]->w;
>      int height           = ctx->inputs[LEFT]->h;
>      AVRational time_base = ctx->inputs[LEFT]->time_base;
> +    AVRational frame_rate = ctx->inputs[LEFT]->frame_rate;
>
>      // check size and fps match on the other input
>      if (width  != ctx->inputs[RIGHT]->w ||
> @@ -93,11 +94,18 @@ static int config_output(AVFilterLink *outlink)
>          return AVERROR_INVALIDDATA;
>      } else if (av_cmp_q(time_base, ctx->inputs[RIGHT]->time_base) != 0) {
>          av_log(ctx, AV_LOG_ERROR,
> -               "Left and right framerates differ (%d/%d vs %d/%d).\n",
> +               "Left and right time bases differ (%d/%d vs %d/%d).\n",
>                 time_base.num, time_base.den,
>                 ctx->inputs[RIGHT]->time_base.num,
>                 ctx->inputs[RIGHT]->time_base.den);
>          return AVERROR_INVALIDDATA;
> +    } else if (av_cmp_q(frame_rate, ctx->inputs[RIGHT]->frame_rate) != 0) {
> +        av_log(ctx, AV_LOG_ERROR,
> +               "Left and right framerates differ (%d/%d vs %d/%d).\n",
> +               frame_rate.num, frame_rate.den,
> +               ctx->inputs[RIGHT]->frame_rate.num,
> +               ctx->inputs[RIGHT]->frame_rate.den);
> +        return AVERROR_INVALIDDATA;
>      }

ok, i wonder if i should drop the time_base checks in a separate patch...

Patch

diff --git a/libavfilter/vf_framepack.c b/libavfilter/vf_framepack.c
index e9806ba..10c4add 100644
--- a/libavfilter/vf_framepack.c
+++ b/libavfilter/vf_framepack.c
@@ -82,6 +82,7 @@  static int config_output(AVFilterLink *outlink)
     int width            = ctx->inputs[LEFT]->w;
     int height           = ctx->inputs[LEFT]->h;
     AVRational time_base = ctx->inputs[LEFT]->time_base;
+    AVRational frame_rate = ctx->inputs[LEFT]->frame_rate;
 
     // check size and fps match on the other input
     if (width  != ctx->inputs[RIGHT]->w ||
@@ -93,11 +94,18 @@  static int config_output(AVFilterLink *outlink)
         return AVERROR_INVALIDDATA;
     } else if (av_cmp_q(time_base, ctx->inputs[RIGHT]->time_base) != 0) {
         av_log(ctx, AV_LOG_ERROR,
-               "Left and right framerates differ (%d/%d vs %d/%d).\n",
+               "Left and right time bases differ (%d/%d vs %d/%d).\n",
                time_base.num, time_base.den,
                ctx->inputs[RIGHT]->time_base.num,
                ctx->inputs[RIGHT]->time_base.den);
         return AVERROR_INVALIDDATA;
+    } else if (av_cmp_q(frame_rate, ctx->inputs[RIGHT]->frame_rate) != 0) {
+        av_log(ctx, AV_LOG_ERROR,
+               "Left and right framerates differ (%d/%d vs %d/%d).\n",
+               frame_rate.num, frame_rate.den,
+               ctx->inputs[RIGHT]->frame_rate.num,
+               ctx->inputs[RIGHT]->frame_rate.den);
+        return AVERROR_INVALIDDATA;
     }
 
     s->pix_desc = av_pix_fmt_desc_get(outlink->format);
@@ -108,6 +116,8 @@  static int config_output(AVFilterLink *outlink)
     switch (s->format) {
     case AV_STEREO3D_FRAMESEQUENCE:
         time_base.den *= 2;
+        frame_rate.num *= 2;
+
         s->double_pts = AV_NOPTS_VALUE;
         break;
     case AV_STEREO3D_COLUMNS:
@@ -126,6 +136,7 @@  static int config_output(AVFilterLink *outlink)
     outlink->w         = width;
     outlink->h         = height;
     outlink->time_base = time_base;
+    outlink->frame_rate= frame_rate;
 
     return 0;
 }