[FFmpeg-trac] #8588(avfilter:reopened): Palettegen adds one color on transparent input

FFmpeg trac at avcodec.org
Mon Mar 30 00:45:24 EEST 2020


#8588: Palettegen adds one color on transparent input
-------------------------------------+-------------------------------------
             Reporter:  RedError     |                    Owner:
                 Type:  defect       |                   Status:  reopened
             Priority:  normal       |                Component:  avfilter
              Version:  git-master   |               Resolution:
             Keywords:  palettegen   |               Blocked By:
  alpha                              |
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
Changes (by RedError):

 * status:  closed => reopened
 * resolution:  invalid =>


Comment:

 The fact that with the "Transparent Gif with white color added" experiment
 it does recognise that there are two different whites (duplicate
 detected), meaning that the histogram didn't recognise it as the same
 color (different hashes), is an indication that there is a way to
 distinguish a color from the image and a ghost color, at least for GIF.

 It's here:
 https://github.com/FFmpeg/FFmpeg/blob/master/libavfilter/vf_palettegen.c#L459

 {{{

 const uint32_t *p = (const uint32_t *)(f->data[0] + y*f->linesize[0]);

         for (x = 0; x < f->width; x++) {
             ret = color_inc(hist, p[x]);

 }}}

 The solution is to not call color_inc if p[x]'s alpha is zero.


 Alpha is present all the way up the histogram's boxes. It's only stripped
 away at the end here:
 https://github.com/FFmpeg/FFmpeg/blob/master/libavfilter/vf_palettegen.c#L186

--
Ticket URL: <https://trac.ffmpeg.org/ticket/8588#comment:6>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list