[FFmpeg-devel] [PATCH 2/2] avfilter: add D2TS, TS2D, TS2T as a common macro in internal.h

lance.lmwang at gmail.com lance.lmwang at gmail.com
Fri Jun 12 17:31:57 EEST 2020


From: Limin Wang <lance.lmwang at gmail.com>

Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
---
 libavfilter/aeval.c       | 2 --
 libavfilter/af_volume.c   | 4 ----
 libavfilter/f_select.c    | 3 ---
 libavfilter/f_sendcmd.c   | 3 ---
 libavfilter/internal.h    | 4 ++++
 libavfilter/setpts.c      | 4 ----
 libavfilter/vf_delogo.c   | 1 -
 libavfilter/vf_eq.c       | 2 --
 libavfilter/vf_hue.c      | 3 ---
 libavfilter/vf_rotate.c   | 2 --
 libavfilter/vf_scale.c    | 2 --
 libavfilter/vf_vignette.c | 3 ---
 12 files changed, 4 insertions(+), 29 deletions(-)

diff --git a/libavfilter/aeval.c b/libavfilter/aeval.c
index 32cd6de..855dc00 100644
--- a/libavfilter/aeval.c
+++ b/libavfilter/aeval.c
@@ -416,8 +416,6 @@ static int aeval_config_output(AVFilterLink *outlink)
     return 0;
 }
 
-#define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)*av_q2d(tb))
-
 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 {
     EvalContext *eval     = inlink->dst->priv;
diff --git a/libavfilter/af_volume.c b/libavfilter/af_volume.c
index 213c571..5fc00d8 100644
--- a/libavfilter/af_volume.c
+++ b/libavfilter/af_volume.c
@@ -335,10 +335,6 @@ static int process_command(AVFilterContext *ctx, const char *cmd, const char *ar
     return ret;
 }
 
-#define D2TS(d)  (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d))
-#define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
-#define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)*av_q2d(tb))
-
 static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
 {
     AVFilterContext *ctx = inlink->dst;
diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c
index 755e10a..92938c3 100644
--- a/libavfilter/f_select.c
+++ b/libavfilter/f_select.c
@@ -325,9 +325,6 @@ static double get_concatdec_select(AVFrame *frame, int64_t pts)
     return NAN;
 }
 
-#define D2TS(d)  (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d))
-#define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
-
 static void select_frame(AVFilterContext *ctx, AVFrame *frame)
 {
     SelectContext *select = ctx->priv;
diff --git a/libavfilter/f_sendcmd.c b/libavfilter/f_sendcmd.c
index 0ac87e0..6b02669 100644
--- a/libavfilter/f_sendcmd.c
+++ b/libavfilter/f_sendcmd.c
@@ -475,9 +475,6 @@ static av_cold void uninit(AVFilterContext *ctx)
     av_freep(&s->intervals);
 }
 
-#define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
-#define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)*av_q2d(tb))
-
 static int filter_frame(AVFilterLink *inlink, AVFrame *ref)
 {
     AVFilterContext *ctx = inlink->dst;
diff --git a/libavfilter/internal.h b/libavfilter/internal.h
index abe7537..6cb601f 100644
--- a/libavfilter/internal.h
+++ b/libavfilter/internal.h
@@ -234,6 +234,10 @@ void ff_avfilter_link_set_out_status(AVFilterLink *link, int status, int64_t pts
 
 void ff_command_queue_pop(AVFilterContext *filter);
 
+#define D2TS(d)      (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d))
+#define TS2D(ts)     ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
+#define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts) * av_q2d(tb))
+
 /* misc trace functions */
 
 #define FF_TPRINTF_START(ctx, func) ff_tlog(NULL, "%-16s: ", #func)
diff --git a/libavfilter/setpts.c b/libavfilter/setpts.c
index c7c3836..6506653 100644
--- a/libavfilter/setpts.c
+++ b/libavfilter/setpts.c
@@ -142,10 +142,6 @@ static int config_input(AVFilterLink *inlink)
     return 0;
 }
 
-#define D2TS(d)  (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d))
-#define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
-#define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)*av_q2d(tb))
-
 #define BUF_SIZE 64
 
 static inline char *double2int64str(char *buf, double v)
diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c
index e55673d..6069c30 100644
--- a/libavfilter/vf_delogo.c
+++ b/libavfilter/vf_delogo.c
@@ -55,7 +55,6 @@ enum var_name {
     VAR_T,
     VAR_VARS_NB
 };
-#define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts) * av_q2d(tb))
 
 static int set_expr(AVExpr **pexpr, const char *expr, const char *option, void *log_ctx)
 {
diff --git a/libavfilter/vf_eq.c b/libavfilter/vf_eq.c
index c8c3d5b..114781f 100644
--- a/libavfilter/vf_eq.c
+++ b/libavfilter/vf_eq.c
@@ -249,8 +249,6 @@ static int query_formats(AVFilterContext *ctx)
     return ff_set_common_formats(ctx, fmts_list);
 }
 
-#define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts) * av_q2d(tb))
-
 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 {
     AVFilterContext *ctx = inlink->dst;
diff --git a/libavfilter/vf_hue.c b/libavfilter/vf_hue.c
index b75ef21..1499c05 100644
--- a/libavfilter/vf_hue.c
+++ b/libavfilter/vf_hue.c
@@ -363,9 +363,6 @@ static void apply_lut10(HueContext *s,
     }
 }
 
-#define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
-#define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts) * av_q2d(tb))
-
 static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
 {
     HueContext *hue = inlink->dst->priv;
diff --git a/libavfilter/vf_rotate.c b/libavfilter/vf_rotate.c
index 02f56c6..65c6cc4 100644
--- a/libavfilter/vf_rotate.c
+++ b/libavfilter/vf_rotate.c
@@ -415,8 +415,6 @@ static av_always_inline void simple_rotate(uint8_t *dst, const uint8_t *src, int
     }
 }
 
-#define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)*av_q2d(tb))
-
 static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
 {
     ThreadData *td = arg;
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index f92529e..ff69bb1 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -647,8 +647,6 @@ static int scale_slice(AVFilterLink *link, AVFrame *out_buf, AVFrame *cur_pic, s
                          out,out_stride);
 }
 
-#define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts) * av_q2d(tb))
-
 static int scale_frame(AVFilterLink *link, AVFrame *in, AVFrame **frame_out)
 {
     AVFilterContext *ctx = link->dst;
diff --git a/libavfilter/vf_vignette.c b/libavfilter/vf_vignette.c
index 47b59e5..ecb04a9 100644
--- a/libavfilter/vf_vignette.c
+++ b/libavfilter/vf_vignette.c
@@ -155,9 +155,6 @@ static double get_natural_factor(const VignetteContext *s, int x, int y)
     }
 }
 
-#define TS2D(ts)     ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
-#define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts) * av_q2d(tb))
-
 static void update_context(VignetteContext *s, AVFilterLink *inlink, AVFrame *frame)
 {
     int x, y;
-- 
1.8.3.1



More information about the ffmpeg-devel mailing list