Browse code

avfilter/vf_histogram: set foreground alpha if possible in destination format

Signed-off-by: Paul B Mahol <onemda@gmail.com>

Paul B Mahol authored on 2016/09/10 07:28:28
Showing 1 changed files
... ...
@@ -35,6 +35,7 @@ typedef struct HistogramContext {
35 35
     int            histogram_size;
36 36
     int            mult;
37 37
     int            ncomp;
38
+    int            dncomp;
38 39
     uint8_t        bg_color[4];
39 40
     uint8_t        fg_color[4];
40 41
     int            level_height;
... ...
@@ -236,6 +237,7 @@ static int config_output(AVFilterLink *outlink)
236 236
     outlink->h = (h->level_height + h->scale_height) * FFMAX(ncomp * h->display_mode, 1);
237 237
 
238 238
     h->odesc = av_pix_fmt_desc_get(outlink->format);
239
+    h->dncomp = h->odesc->nb_components;
239 240
     outlink->sample_aspect_ratio = (AVRational){1,1};
240 241
 
241 242
     return 0;
... ...
@@ -319,7 +321,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
319 319
             if (h->histogram_size <= 256) {
320 320
                 for (j = h->level_height - 1; j >= col_height; j--) {
321 321
                     if (h->display_mode) {
322
-                        for (l = 0; l < h->ncomp; l++)
322
+                        for (l = 0; l < h->dncomp; l++)
323 323
                             out->data[l][(j + start) * out->linesize[l] + i] = h->fg_color[l];
324 324
                     } else {
325 325
                         out->data[p][(j + start) * out->linesize[p] + i] = 255;
... ...
@@ -332,7 +334,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
332 332
 
333 333
                 for (j = h->level_height - 1; j >= col_height; j--) {
334 334
                     if (h->display_mode) {
335
-                        for (l = 0; l < h->ncomp; l++)
335
+                        for (l = 0; l < h->dncomp; l++)
336 336
                             AV_WN16(out->data[l] + (j + start) * out->linesize[l] + i * 2, h->fg_color[l] * mult);
337 337
                     } else {
338 338
                         AV_WN16(out->data[p] + (j + start) * out->linesize[p] + i * 2, 255 * mult);