[FFmpeg-devel] [PATCH 1/2] avfilter/vf_histogram: take log2 chroma shift into account when clearing buffer
Clément Bœsch
u at pkh.me
Sat Sep 28 06:40:43 CEST 2013
On Sat, Sep 28, 2013 at 01:09:18AM +0200, Marton Balint wrote:
> Signed-off-by: Marton Balint <cus at passwd.hu>
> ---
> libavfilter/vf_histogram.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/libavfilter/vf_histogram.c b/libavfilter/vf_histogram.c
> index db52199..1dd0b2d 100644
> --- a/libavfilter/vf_histogram.c
> +++ b/libavfilter/vf_histogram.c
> @@ -169,6 +169,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
> HistogramContext *h = inlink->dst->priv;
> AVFilterContext *ctx = inlink->dst;
> AVFilterLink *outlink = ctx->outputs[0];
> + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(outlink->format);
> AVFrame *out;
> const uint8_t *src;
> uint8_t *dst;
> @@ -182,9 +183,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
>
> out->pts = in->pts;
>
> - for (k = 0; k < h->ncomp; k++)
> - for (i = 0; i < outlink->h; i++)
> - memset(out->data[k] + i * out->linesize[k], h->bg_color[k], outlink->w);
> + for (k = 0; k < h->ncomp; k++) {
> + int is_chroma = (k == 1 || k == 2);
> + int dst_h = outlink->h >> (is_chroma ? desc->log2_chroma_h : 0);
> + int dst_w = outlink->w >> (is_chroma ? desc->log2_chroma_w : 0);
You need to use FF_CEIL_RSHIFT() to deal with odd height/width.
[...]
--
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130928/7ea74755/attachment.asc>
More information about the ffmpeg-devel
mailing list