]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vf_framepack.c
vf_drawtext: Move static keyword to beginning of variable declaration
[ffmpeg] / libavfilter / vf_framepack.c
index e9806ba1ccec1515cd95ae7a266cfe6cde07d816..fd0c1897d55631f29af526b2c443a7dc8f56c168 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <string.h>
 
+#include "libavutil/common.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
@@ -76,12 +77,13 @@ static av_cold void framepack_uninit(AVFilterContext *ctx)
 
 static int config_output(AVFilterLink *outlink)
 {
-    AVFilterContext *ctx = outlink->src;
-    FramepackContext *s  = outlink->src->priv;
+    AVFilterContext *ctx  = outlink->src;
+    FramepackContext *s   = outlink->src->priv;
 
-    int width            = ctx->inputs[LEFT]->w;
-    int height           = ctx->inputs[LEFT]->h;
-    AVRational time_base = ctx->inputs[LEFT]->time_base;
+    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 +95,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);
@@ -107,7 +116,9 @@ static int config_output(AVFilterLink *outlink)
     // modify output properties as needed
     switch (s->format) {
     case AV_STEREO3D_FRAMESEQUENCE:
-        time_base.den *= 2;
+        time_base.den  *= 2;
+        frame_rate.num *= 2;
+
         s->double_pts = AV_NOPTS_VALUE;
         break;
     case AV_STEREO3D_COLUMNS:
@@ -123,9 +134,10 @@ static int config_output(AVFilterLink *outlink)
         return AVERROR_INVALIDDATA;
     }
 
-    outlink->w         = width;
-    outlink->h         = height;
-    outlink->time_base = time_base;
+    outlink->w          = width;
+    outlink->h          = height;
+    outlink->time_base  = time_base;
+    outlink->frame_rate = frame_rate;
 
     return 0;
 }
@@ -147,8 +159,8 @@ static void horizontal_frame_pack(AVFilterLink *outlink,
 
         for (plane = 0; plane < s->pix_desc->nb_components; plane++) {
             if (plane == 1 || plane == 2) {
-                length = -(-(out->width / 2) >> s->pix_desc->log2_chroma_w);
-                lines  = -(-(out->height)    >> s->pix_desc->log2_chroma_h);
+                length = AV_CEIL_RSHIFT(out->width / 2, s->pix_desc->log2_chroma_w);
+                lines  = AV_CEIL_RSHIFT(out->height,    s->pix_desc->log2_chroma_h);
             }
             for (i = 0; i < lines; i++) {
                 int j;