]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/setpts.c
avcodec: libdav1d AV1 decoder wrapper.
[ffmpeg] / libavfilter / setpts.c
index 9fa1df5a896e98e6be6841039962f7fd35854495..1c262b73e7ddf6198db555a178a81191732241d5 100644 (file)
@@ -24,6 +24,8 @@
  * video presentation timestamp (PTS) modification filter
  */
 
+#include <inttypes.h>
+
 #include "libavutil/eval.h"
 #include "libavutil/internal.h"
 #include "libavutil/mathematics.h"
 
 static const char *const var_names[] = {
     "E",           ///< Euler number
+    "FRAME_RATE",  ///< defined only for constant frame-rate video
     "INTERLACED",  ///< tell if the current frame is interlaced
     "N",           ///< frame / sample number (starting at zero)
     "PHI",         ///< golden ratio
-    "PI",          ///< greek pi
+    "PI",          ///< Greek pi
     "PREV_INPTS",  ///< previous  input PTS
     "PREV_OUTPTS", ///< previous output PTS
     "PTS",         ///< original pts in the file of the frame
@@ -57,6 +60,7 @@ static const char *const var_names[] = {
 
 enum var_name {
     VAR_E,
+    VAR_FRAME_RATE,
     VAR_INTERLACED,
     VAR_N,
     VAR_PHI,
@@ -73,7 +77,7 @@ enum var_name {
     VAR_VARS_NB
 };
 
-typedef struct {
+typedef struct SetPTSContext {
     const AVClass *class;
     char *expr_str;
     AVExpr *expr;
@@ -113,6 +117,13 @@ static int config_input(AVFilterLink *inlink)
         setpts->var_values[VAR_SR] = inlink->sample_rate;
     }
 
+    setpts->var_values[VAR_FRAME_RATE] = inlink->frame_rate.num &&
+                                         inlink->frame_rate.den ?
+                                            av_q2d(inlink->frame_rate) : NAN;
+
+    // Indicate the output can be variable framerate.
+    inlink->frame_rate = (AVRational){1, 0};
+
     av_log(inlink->src, AV_LOG_VERBOSE, "TB:%f\n", setpts->var_values[VAR_TB]);
     return 0;
 }
@@ -141,15 +152,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
     d = av_expr_eval(setpts->expr, setpts->var_values, NULL);
     frame->pts = D2TS(d);
 
-#ifdef DEBUG
-    av_log(inlink->dst, AV_LOG_DEBUG,
-           "n:%"PRId64" interlaced:%d pts:%"PRId64" t:%f -> pts:%"PRId64" t:%f\n",
-           (int64_t)setpts->var_values[VAR_N],
-           (int)setpts->var_values[VAR_INTERLACED],
-           in_pts, in_pts * av_q2d(inlink->time_base),
-           frame->pts, frame->pts * av_q2d(inlink->time_base));
-#endif
-
+    av_log(inlink->dst, AV_LOG_TRACE,
+            "n:%"PRId64" interlaced:%d pts:%"PRId64" t:%f -> pts:%"PRId64" t:%f\n",
+            (int64_t)setpts->var_values[VAR_N],
+            (int)setpts->var_values[VAR_INTERLACED],
+            in_pts, in_pts * av_q2d(inlink->time_base),
+            frame->pts, frame->pts * av_q2d(inlink->time_base));
 
     if (inlink->type == AVMEDIA_TYPE_VIDEO) {
         setpts->var_values[VAR_N] += 1.0;
@@ -203,7 +211,7 @@ static const AVFilterPad avfilter_vf_setpts_outputs[] = {
     { NULL }
 };
 
-AVFilter avfilter_vf_setpts = {
+AVFilter ff_vf_setpts = {
     .name      = "setpts",
     .description = NULL_IF_CONFIG_SMALL("Set PTS for the output video frame."),
     .init      = init,
@@ -244,7 +252,7 @@ static const AVFilterPad asetpts_outputs[] = {
     { NULL }
 };
 
-AVFilter avfilter_af_asetpts = {
+AVFilter ff_af_asetpts = {
     .name        = "asetpts",
     .description = NULL_IF_CONFIG_SMALL("Set PTS for the output audio frame."),
     .init        = init,