Commit 4709f721 authored by Vittorio Giovara's avatar Vittorio Giovara

lavfi: Use AV_CEIL_RSHIFT where needed

parent e8030714
...@@ -172,8 +172,8 @@ static int config_input(AVFilterLink *inlink) ...@@ -172,8 +172,8 @@ static int config_input(AVFilterLink *inlink)
if (!s->buf) if (!s->buf)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
s->chroma_w = -((-inlink->w) >> hsub); s->chroma_w = AV_CEIL_RSHIFT(inlink->w, hsub);
s->chroma_h = -((-inlink->h) >> vsub); 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); s->chroma_r = av_clip(((((s->radius >> hsub) + (s->radius >> vsub)) / 2 ) + 1) & ~1, 4, 32);
return 0; return 0;
......
...@@ -138,8 +138,10 @@ static void copy_picture_field(InterlaceContext *s, ...@@ -138,8 +138,10 @@ static void copy_picture_field(InterlaceContext *s,
int plane, j; int plane, j;
for (plane = 0; plane < desc->nb_components; plane++) { for (plane = 0; plane < desc->nb_components; plane++) {
int cols = (plane == 1 || plane == 2) ? -(-inlink->w) >> hsub : inlink->w; int cols = (plane == 1 || plane == 2) ? AV_CEIL_RSHIFT(inlink->w, hsub)
int lines = (plane == 1 || plane == 2) ? -(-inlink->h) >> vsub : inlink->h; : inlink->w;
int lines = (plane == 1 || plane == 2) ? AV_CEIL_RSHIFT(inlink->h, vsub)
: inlink->h;
uint8_t *dstp = dst_frame->data[plane]; uint8_t *dstp = dst_frame->data[plane];
const uint8_t *srcp = src_frame->data[plane]; const uint8_t *srcp = src_frame->data[plane];
......
...@@ -48,9 +48,6 @@ ...@@ -48,9 +48,6 @@
#define MIN_SIZE 3 #define MIN_SIZE 3
#define MAX_SIZE 13 #define MAX_SIZE 13
/* right-shift and round-up */
#define SHIFTUP(x,shift) (-((-(x))>>(shift)))
typedef struct FilterParam { typedef struct FilterParam {
int msize_x; ///< matrix width int msize_x; ///< matrix width
int msize_y; ///< matrix height int msize_y; ///< matrix height
...@@ -182,7 +179,7 @@ static int config_props(AVFilterLink *link) ...@@ -182,7 +179,7 @@ static int config_props(AVFilterLink *link)
unsharp->vsub = desc->log2_chroma_h; unsharp->vsub = desc->log2_chroma_h;
init_filter_param(link->dst, &unsharp->luma, "luma", link->w); 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; return 0;
} }
...@@ -208,8 +205,8 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) ...@@ -208,8 +205,8 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
UnsharpContext *unsharp = link->dst->priv; UnsharpContext *unsharp = link->dst->priv;
AVFilterLink *outlink = link->dst->outputs[0]; AVFilterLink *outlink = link->dst->outputs[0];
AVFrame *out; AVFrame *out;
int cw = SHIFTUP(link->w, unsharp->hsub); int cw = AV_CEIL_RSHIFT(link->w, unsharp->hsub);
int ch = SHIFTUP(link->h, unsharp->vsub); int ch = AV_CEIL_RSHIFT(link->h, unsharp->vsub);
out = ff_get_video_buffer(outlink, outlink->w, outlink->h); out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!out) { if (!out) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment