lavfi: Use AV_CEIL_RSHIFT where needed

pull/178/head
Vittorio Giovara 9 years ago
parent e80307140f
commit 4709f72115
  1. 4
      libavfilter/vf_gradfun.c
  2. 6
      libavfilter/vf_interlace.c
  3. 9
      libavfilter/vf_unsharp.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;

@ -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];

@ -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) {

Loading…
Cancel
Save