[FFmpeg-devel] [PATCH 2/4] avfilter/vf_histogram: take log2 chroma shift into account when clearing buffer
Marton Balint
cus at passwd.hu
Tue Oct 1 21:53:58 CEST 2013
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 c5d5b31..f513a25 100644
--- a/libavfilter/vf_histogram.c
+++ b/libavfilter/vf_histogram.c
@@ -204,6 +204,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;
@@ -217,9 +218,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 = FF_CEIL_RSHIFT(outlink->h, (is_chroma ? desc->log2_chroma_h : 0));
+ int dst_w = FF_CEIL_RSHIFT(outlink->w, (is_chroma ? desc->log2_chroma_w : 0));
+ for (i = 0; i < dst_h ; i++)
+ memset(out->data[desc->comp[k].plane] + i * out->linesize[desc->comp[k].plane], h->bg_color[k], dst_w);
+ }
switch (h->mode) {
case MODE_LEVELS:
--
1.8.1.4
More information about the ffmpeg-devel
mailing list