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