[FFmpeg-devel] [PATCH 1/2] avfilter/vf_histogram: take log2 chroma shift into account when clearing buffer

Marton Balint cus at passwd.hu
Sat Sep 28 01:09:18 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 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);
+        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