[Cin] Real fix for 16-bit pngs

Andrew Randrianasulu randrianasulu at gmail.com
Tue Mar 24 18:43:12 CET 2020


В сообщении от Tuesday 24 March 2020 20:35:55 Phyllis Smith написал(а):
> Andrew,
> GG writes here:  This is weird.  I have looked into this and Little Endian
> / png / swapping in ffmpeg, libpng.
> see libpng16-src pnginfo.h, no endian or swap or relevant order params.
> see ffmpeg-4.2 libavcodec/pngdec.c:618 decode_idat_chunk, only 16be formats.

Well, _on BE machine_, it seems, there will be no need to call this.
But I'm on little x86.

> Little Endian format is not supported in ffmpg.  It is not in any png.h
> header data.  It only seems to be a user specified transform option.   In
> other words, you have to tell it not to use the default of big endian
> (network byte order).  Since this only generates the possibility of a fail,
> I think that the best idea is to remove it as a possibility.   Perhaps you
> should investigate why it is the default on the machine you are using.  I
> do not see any way it could be normally generated using libpng16 source
> (the current version used by all os vendors).

I take this code from gimp-2.10 git sources, this works for me.
ORDER of calls is important.


https://github.com/GNOME/gimp/blob/mainline/plug-ins/common/file-png.c

around lines 1823-1828:


    if (text)
      png_set_text (pp, info, text, 1);
  

    png_write_info (pp, info);
    if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
      png_set_swap (pp);

Try to save 16 bpp PNG with current git, and with this fix. See the difference :/



> 
> 
> On Tue, Mar 24, 2020 at 6:13 AM Andrew Randrianasulu <
> randrianasulu at gmail.com> wrote:
> 
> > Sorry, I apparently send wrong patch - 16 bit pngs were still broken.
> >
> > I scratched my head a lot (because it was working!)
> > and realized I swapped order of calls!
> >
> > diff relative to commit 8c43913b9f18a3856bbff826aef96587a32f0470
> >
> > diff --git a/cinelerra-5.1/cinelerra/filepng.C
> > b/cinelerra-5.1/cinelerra/filepng.C
> > index 4df95f1e..c2e1cf6c 100644
> > --- a/cinelerra-5.1/cinelerra/filepng.C
> > +++ b/cinelerra-5.1/cinelerra/filepng.C
> > @@ -229,9 +229,9 @@ int FilePNG::write_frame(VFrame *frame, VFrame *data,
> > FrameWriterUnit *unit)
> >                                 asset->png_use_alpha ?
> > PNG_COLOR_TYPE_RGB_ALPHA : PNG_COLOR_TYPE_RGB,
> >                                 PNG_INTERLACE_NONE,
> > PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
> >  // does not work (gg 2020/03/17 libpng16 fc31)
> > +                       png_write_info(png_ptr, info_ptr);
> >                         if( asset->png_depth == 16 &&
> > BC_Resources::little_endian )
> >                                 png_set_swap(png_ptr);
> > -                       png_write_info(png_ptr, info_ptr);
> >                         png_write_image(png_ptr, output_frame->get_rows());
> >                         png_write_end(png_ptr, info_ptr);
> >                         result = 0;
> >
> > this way it SHOULD work .... Tested!
> >
> > Also, hint for ccache:
> > in .ccache/ccache.conf set for maximum compression
> >
> > compression = true
> > compression_level = 8
> > --
> > Cin mailing list
> > Cin at lists.cinelerra-gg.org
> > https://lists.cinelerra-gg.org/mailman/listinfo/cin
> >
> 




More information about the Cin mailing list