summaryrefslogtreecommitdiff
path: root/libavfilter/vf_histogram.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2016-09-10 00:28:28 +0200
committerPaul B Mahol <onemda@gmail.com>2016-09-10 00:28:28 +0200
commitc784b5cfdc7ee1e26d0032d5b9593647def30688 (patch)
tree2d29ff56177d2981bf6d2ba37bfcfffba0dad0d9 /libavfilter/vf_histogram.c
parent915abab25c5b28a23767029713bb175c63be7cc7 (diff)
avfilter/vf_histogram: set foreground alpha if possible in destination format
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavfilter/vf_histogram.c')
-rw-r--r--libavfilter/vf_histogram.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libavfilter/vf_histogram.c b/libavfilter/vf_histogram.c
index c6b308a8e0..f04f5dea10 100644
--- a/libavfilter/vf_histogram.c
+++ b/libavfilter/vf_histogram.c
@@ -35,6 +35,7 @@ typedef struct HistogramContext {
int histogram_size;
int mult;
int ncomp;
+ int dncomp;
uint8_t bg_color[4];
uint8_t fg_color[4];
int level_height;
@@ -236,6 +237,7 @@ static int config_output(AVFilterLink *outlink)
outlink->h = (h->level_height + h->scale_height) * FFMAX(ncomp * h->display_mode, 1);
h->odesc = av_pix_fmt_desc_get(outlink->format);
+ h->dncomp = h->odesc->nb_components;
outlink->sample_aspect_ratio = (AVRational){1,1};
return 0;
@@ -319,7 +321,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
if (h->histogram_size <= 256) {
for (j = h->level_height - 1; j >= col_height; j--) {
if (h->display_mode) {
- for (l = 0; l < h->ncomp; l++)
+ for (l = 0; l < h->dncomp; l++)
out->data[l][(j + start) * out->linesize[l] + i] = h->fg_color[l];
} else {
out->data[p][(j + start) * out->linesize[p] + i] = 255;
@@ -332,7 +334,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
for (j = h->level_height - 1; j >= col_height; j--) {
if (h->display_mode) {
- for (l = 0; l < h->ncomp; l++)
+ for (l = 0; l < h->dncomp; l++)
AV_WN16(out->data[l] + (j + start) * out->linesize[l] + i * 2, h->fg_color[l] * mult);
} else {
AV_WN16(out->data[p] + (j + start) * out->linesize[p] + i * 2, 255 * mult);