[FFmpeg-cvslog] lavfi: Use AV_CEIL_RSHIFT where needed

Vittorio Giovara git at videolan.org
Tue Feb 16 18:01:02 CET 2016


ffmpeg | branch: master | Vittorio Giovara <vittorio.giovara at gmail.com> | Thu Jan 21 17:47:04 2016 -0500| [4709f72115e4028a1cb43e916925678bfceef870] | committer: Vittorio Giovara

lavfi: Use AV_CEIL_RSHIFT where needed

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4709f72115e4028a1cb43e916925678bfceef870
---

 libavfilter/vf_gradfun.c   |    4 ++--
 libavfilter/vf_interlace.c |    6 ++++--
 libavfilter/vf_unsharp.c   |    9 +++------
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/libavfilter/vf_gradfun.c b/libavfilter/vf_gradfun.c
index f7c4372..ce79329 100644
--- a/libavfilter/vf_gradfun.c
+++ b/libavfilter/vf_gradfun.c
@@ -172,8 +172,8 @@ static int config_input(AVFilterLink *inlink)
     if (!s->buf)
         return AVERROR(ENOMEM);
 
-    s->chroma_w = -((-inlink->w) >> hsub);
-    s->chroma_h = -((-inlink->h) >> vsub);
+    s->chroma_w = AV_CEIL_RSHIFT(inlink->w, hsub);
+    s->chroma_h = AV_CEIL_RSHIFT(inlink->h, vsub);
     s->chroma_r = av_clip(((((s->radius >> hsub) + (s->radius >> vsub)) / 2 ) + 1) & ~1, 4, 32);
 
     return 0;
diff --git a/libavfilter/vf_interlace.c b/libavfilter/vf_interlace.c
index 939fabc..ac435d7 100644
--- a/libavfilter/vf_interlace.c
+++ b/libavfilter/vf_interlace.c
@@ -138,8 +138,10 @@ static void copy_picture_field(InterlaceContext *s,
     int plane, j;
 
     for (plane = 0; plane < desc->nb_components; plane++) {
-        int cols  = (plane == 1 || plane == 2) ? -(-inlink->w) >> hsub : inlink->w;
-        int lines = (plane == 1 || plane == 2) ? -(-inlink->h) >> vsub : inlink->h;
+        int cols  = (plane == 1 || plane == 2) ? AV_CEIL_RSHIFT(inlink->w, hsub)
+                                               : inlink->w;
+        int lines = (plane == 1 || plane == 2) ? AV_CEIL_RSHIFT(inlink->h, vsub)
+                                               : inlink->h;
         uint8_t *dstp = dst_frame->data[plane];
         const uint8_t *srcp = src_frame->data[plane];
 
diff --git a/libavfilter/vf_unsharp.c b/libavfilter/vf_unsharp.c
index d0d59e2..dbe3874 100644
--- a/libavfilter/vf_unsharp.c
+++ b/libavfilter/vf_unsharp.c
@@ -48,9 +48,6 @@
 #define MIN_SIZE 3
 #define MAX_SIZE 13
 
-/* right-shift and round-up */
-#define SHIFTUP(x,shift) (-((-(x))>>(shift)))
-
 typedef struct FilterParam {
     int msize_x;                             ///< matrix width
     int msize_y;                             ///< matrix height
@@ -182,7 +179,7 @@ static int config_props(AVFilterLink *link)
     unsharp->vsub = desc->log2_chroma_h;
 
     init_filter_param(link->dst, &unsharp->luma,   "luma",   link->w);
-    init_filter_param(link->dst, &unsharp->chroma, "chroma", SHIFTUP(link->w, unsharp->hsub));
+    init_filter_param(link->dst, &unsharp->chroma, "chroma", AV_CEIL_RSHIFT(link->w, unsharp->hsub));
 
     return 0;
 }
@@ -208,8 +205,8 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
     UnsharpContext *unsharp = link->dst->priv;
     AVFilterLink *outlink   = link->dst->outputs[0];
     AVFrame *out;
-    int cw = SHIFTUP(link->w, unsharp->hsub);
-    int ch = SHIFTUP(link->h, unsharp->vsub);
+    int cw = AV_CEIL_RSHIFT(link->w, unsharp->hsub);
+    int ch = AV_CEIL_RSHIFT(link->h, unsharp->vsub);
 
     out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
     if (!out) {



More information about the ffmpeg-cvslog mailing list