summaryrefslogtreecommitdiff
path: root/libavfilter
diff options
context:
space:
mode:
authorVittorio Giovara <vittorio.giovara@gmail.com>2016-01-21 17:47:04 -0500
committerVittorio Giovara <vittorio.giovara@gmail.com>2016-01-25 12:09:48 -0500
commit4709f72115e4028a1cb43e916925678bfceef870 (patch)
tree3959683cdc265f20a167601ef7094fc2e0ded8b4 /libavfilter
parente80307140f736f593ee643affa015333d7c5e27f (diff)
lavfi: Use AV_CEIL_RSHIFT where needed
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/vf_gradfun.c4
-rw-r--r--libavfilter/vf_interlace.c6
-rw-r--r--libavfilter/vf_unsharp.c9
3 files changed, 9 insertions, 10 deletions
diff --git a/libavfilter/vf_gradfun.c b/libavfilter/vf_gradfun.c
index f7c4372dd3..ce79329b61 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 939fabc843..ac435d768a 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 d0d59e24ff..dbe3874455 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) {