]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/framesync.c
avcodec: Constify all the AVCodecParsers
[ffmpeg] / libavfilter / framesync.c
index 82d715750c4bca867a23c31d38082d777acf0b91..bc6fce81f41dd8319606630690443ae7c7d93f14 100644 (file)
@@ -53,6 +53,13 @@ static const AVClass framesync_class = {
     .parent_log_context_offset = OFFSET(parent),
 };
 
+const AVClass *ff_framesync_child_class_iterate(void **iter)
+{
+    const AVClass *c = *iter ? NULL : &framesync_class;
+    *iter = (void *)(uintptr_t)c;
+    return c;
+}
+
 enum {
     STATE_BOF,
     STATE_RUN,
@@ -61,7 +68,7 @@ enum {
 
 static int consume_from_fifos(FFFrameSync *fs);
 
-const AVClass *framesync_get_class(void)
+const AVClass *ff_framesync_get_class(void)
 {
     return &framesync_class;
 }
@@ -117,7 +124,6 @@ static void framesync_sync_level_update(FFFrameSync *fs)
 int ff_framesync_configure(FFFrameSync *fs)
 {
     unsigned i;
-    int64_t gcd, lcm;
 
     if (!fs->opt_repeatlast || fs->opt_eof_action == EOF_ACTION_PASS) {
         fs->opt_repeatlast = 0;
@@ -127,32 +133,23 @@ int ff_framesync_configure(FFFrameSync *fs)
         fs->opt_shortest = 1;
         fs->opt_eof_action = EOF_ACTION_ENDALL;
     }
-    if (fs->opt_shortest) {
-        for (i = 0; i < fs->nb_in; i++)
-            fs->in[i].after = EXT_STOP;
-    }
     if (!fs->opt_repeatlast) {
         for (i = 1; i < fs->nb_in; i++) {
             fs->in[i].after = EXT_NULL;
             fs->in[i].sync  = 0;
         }
     }
+    if (fs->opt_shortest) {
+        for (i = 0; i < fs->nb_in; i++)
+            fs->in[i].after = EXT_STOP;
+    }
 
     if (!fs->time_base.num) {
         for (i = 0; i < fs->nb_in; i++) {
             if (fs->in[i].sync) {
                 if (fs->time_base.num) {
-                    gcd = av_gcd(fs->time_base.den, fs->in[i].time_base.den);
-                    lcm = (fs->time_base.den / gcd) * fs->in[i].time_base.den;
-                    if (lcm < AV_TIME_BASE / 2) {
-                        fs->time_base.den = lcm;
-                        fs->time_base.num = av_gcd(fs->time_base.num,
-                                                   fs->in[i].time_base.num);
-                    } else {
-                        fs->time_base.num = 1;
-                        fs->time_base.den = AV_TIME_BASE;
-                        break;
-                    }
+                    fs->time_base = av_gcd_q(fs->time_base, fs->in[i].time_base,
+                                             AV_TIME_BASE / 2, AV_TIME_BASE_Q);
                 } else {
                     fs->time_base = fs->in[i].time_base;
                 }
@@ -406,7 +403,7 @@ int ff_framesync_dualinput_get_writable(FFFrameSync *fs, AVFrame **f0, AVFrame *
     ret = ff_inlink_make_frame_writable(fs->parent->inputs[0], f0);
     if (ret < 0) {
         av_frame_free(f0);
-        av_frame_free(f1);
+        *f1 = NULL;
         return ret;
     }
     return 0;