diff options
author | Paul B Mahol <onemda@gmail.com> | 2013-09-30 13:15:15 +0400 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2013-09-30 17:08:55 +0400 |
commit | 2a6a3d4317e6d911c09012b94f68da974d5e7e9e (patch) | |
tree | cfe42f7eec98cdcbd0fe802fef97bb16fcb5314b /libavfilter/vf_hflip.c | |
parent | 862773907a74b7dda3230b70b8e850d50da3c058 (diff) |
avfilter/vf_hflip: refactor plane dimensions calculation
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavfilter/vf_hflip.c')
-rw-r--r-- | libavfilter/vf_hflip.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/libavfilter/vf_hflip.c b/libavfilter/vf_hflip.c index ec94e35063..ecdf17ffc0 100644 --- a/libavfilter/vf_hflip.c +++ b/libavfilter/vf_hflip.c @@ -37,7 +37,8 @@ typedef struct { int max_step[4]; ///< max pixel step for each plane, expressed as a number of bytes - int hsub, vsub; ///< chroma subsampling + int planewidth[4]; ///< width of each plane + int planeheight[4]; ///< height of each plane } FlipContext; static int query_formats(AVFilterContext *ctx) @@ -62,10 +63,14 @@ static int config_props(AVFilterLink *inlink) { FlipContext *s = inlink->dst->priv; const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format); + const int hsub = pix_desc->log2_chroma_w; + const int vsub = pix_desc->log2_chroma_h; av_image_fill_max_pixsteps(s->max_step, NULL, pix_desc); - s->hsub = pix_desc->log2_chroma_w; - s->vsub = pix_desc->log2_chroma_h; + s->planewidth[0] = s->planewidth[3] = inlink->w; + s->planewidth[1] = s->planewidth[2] = FF_CEIL_RSHIFT(inlink->w, hsub); + s->planeheight[0] = s->planeheight[3] = inlink->h; + s->planeheight[1] = s->planeheight[2] = FF_CEIL_RSHIFT(inlink->h, vsub); return 0; } @@ -91,8 +96,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) memcpy(out->data[1], in->data[1], AVPALETTE_SIZE); for (plane = 0; plane < 4 && in->data[plane] && in->linesize[plane]; plane++) { - const int width = (plane == 1 || plane == 2) ? FF_CEIL_RSHIFT(inlink->w, s->hsub) : inlink->w; - const int height = (plane == 1 || plane == 2) ? FF_CEIL_RSHIFT(inlink->h, s->vsub) : inlink->h; + const int width = s->planewidth[plane]; + const int height = s->planeheight[plane]; step = s->max_step[plane]; outrow = out->data[plane]; |