Opened 13 years ago

Closed 12 years ago

#769 closed defect (fixed)

png gray8 alpha decodes incorrectly

Reported by: ami_stuff Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: gray8a alpha png
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

I get different output with ffmpeg and ffplay

C:\>ffmpeg -i basi4a08.png
ffmpeg version N-35709-g7d531e8, Copyright (c) 2000-2011 the FFmpeg developers
  built on Dec 12 2011 13:50:00 with gcc 4.6.2
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-ru
ntime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libope
ncore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --en
able-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger -
-enable-libspeex --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwben
c --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-
libxvid --enable-zlib
  libavutil    51. 32. 0 / 51. 32. 0
  libavcodec   53. 43. 0 / 53. 43. 0
  libavformat  53. 24. 0 / 53. 24. 0
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 53. 0 /  2. 53. 0
  libswscale    2.  1. 0 /  2.  1. 0
  libpostproc  51.  2. 0 / 51.  2. 0
Input #0, image2, from 'basi4a08.png':
  Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: png, gray8a, 32x32, 25 tbr, 25 tbn, 25 tbc
At least one output file must be specified

Attachments (6)

basi4a08.png (214 bytes ) - added by ami_stuff 13 years ago.
ffplay.bmp (3.6 KB ) - added by ami_stuff 13 years ago.
ffmpeg.bmp (3.1 KB ) - added by ami_stuff 13 years ago.
out_yuv420p.tif (1.8 KB ) - added by ami_stuff 13 years ago.
irfanview.bmp (3.1 KB ) - added by ami_stuff 13 years ago.
gray_alpha.png (365.5 KB ) - added by ami_stuff 13 years ago.

Download all attachments as: .zip

Change History (20)

by ami_stuff, 13 years ago

Attachment: basi4a08.png added

comment:1 by Carl Eugen Hoyos, 13 years ago

Please provide the ffmpeg command line that produces the output different from ffplay for you.

comment:2 by ami_stuff, 13 years ago

ffmpeg -i basi4a08.png out.bmp

by ami_stuff, 13 years ago

Attachment: ffplay.bmp added

by ami_stuff, 13 years ago

Attachment: ffmpeg.bmp added

comment:3 by ami_stuff, 13 years ago

C:\>ffmpeg -i basi4a08.png ffmpeg.bmp
ffmpeg version N-35709-g7d531e8, Copyright (c) 2000-2011 the FFmpeg developers
  built on Dec 12 2011 13:50:00 with gcc 4.6.2
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-ru
ntime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libope
ncore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --en
able-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger -
-enable-libspeex --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwben
c --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-
libxvid --enable-zlib
  libavutil    51. 32. 0 / 51. 32. 0
  libavcodec   53. 43. 0 / 53. 43. 0
  libavformat  53. 24. 0 / 53. 24. 0
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 53. 0 /  2. 53. 0
  libswscale    2.  1. 0 /  2.  1. 0
  libpostproc  51.  2. 0 / 51.  2. 0
Input #0, image2, from 'basi4a08.png':
  Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: png, gray8a, 32x32, 25 tbr, 25 tbn, 25 tbc
Incompatible pixel format 'gray8a' for codec 'bmp', auto-selecting format 'bgr24
'
[buffer @ 020D1700] w:32 h:32 pixfmt:gray8a tb:1/1000000 sar:0/1 sws_param:
[buffersink @ 020D1980] auto-inserting filter 'auto-inserted scale 0' between th
e filter 'src' and the filter 'out'
[scale @ 020D1D80] w:32 h:32 fmt:gray8a -> w:32 h:32 fmt:bgr24 flags:0x4
Output #0, image2, to 'ffmpeg.bmp':
  Metadata:
    encoder         : Lavf53.24.0
    Stream #0:0: Video: bmp, bgr24, 32x32, q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (png -> bmp)
Press [q] to stop, [?] for help
frame=    1 fps=  0 q=0.0 Lsize=       0kB time=00:00:00.04 bitrate=   0.0kbits/
s
video:3kB audio:0kB global headers:0kB muxing overhead -100.000000%
C:\>ffplay basi4a08.png
ffplay version N-35709-g7d531e8, Copyright (c) 2003-2011 the FFmpeg developers
  built on Dec 12 2011 13:50:00 with gcc 4.6.2
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-ru
ntime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libope
ncore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --en
able-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger -
-enable-libspeex --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwben
c --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-
libxvid --enable-zlib
  libavutil    51. 32. 0 / 51. 32. 0
  libavcodec   53. 43. 0 / 53. 43. 0
  libavformat  53. 24. 0 / 53. 24. 0
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 53. 0 /  2. 53. 0
  libswscale    2.  1. 0 /  2.  1. 0
  libpostproc  51.  2. 0 / 51.  2. 0
Input #0, image2, from 'basi4a08.png':
  Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: png, gray8a, 32x32, 25 tbr, 25 tbn, 25 tbc
[buffersink @ 020D2880] auto-inserting filter 'auto-inserted scale 0' between th
e filter 'src' and the filter 'out'
[scale @ 020D2CA0] w:32 h:32 fmt:gray8a -> w:32 h:32 fmt:yuv420p flags:0x4
   1.44 A-V:  0.000 fd=   0 aq=    0KB vq=    0KB sq=    0B f=0/0

comment:4 by Carl Eugen Hoyos, 13 years ago

Component: undeterminedswscale
Keywords: gray8a alpha added
Reproduced by developer: set
Status: newopen
Version: unspecifiedgit-master

The following commands work as expected:
ffmpeg -i basi4a08.png out.avi
ffmpeg -i basi4a08.png -pix_fmt yuv420p out.tif

in reply to:  4 comment:5 by ami_stuff, 13 years ago

Replying to cehoyos:

ffmpeg -i basi4a08.png -pix_fmt yuv420p out.tif

I can reproduce the problem with it (please see the attached output tif file), so maybe a bug in gray8a -> yuv420p conversion?

by ami_stuff, 13 years ago

Attachment: out_yuv420p.tif added

comment:6 by Carl Eugen Hoyos, 13 years ago

Afaict, the conversion from gray8a to yuv (including yuv420p) is the only one that works (for gray8a).
out_yuv420p.tif looks fine with ImageMagick.

comment:7 by ami_stuff, 13 years ago

I attache output from irfanview which I consider correct.

Now please create these files:

ffmpeg -loop 1 -t 5 -i basi4a08.png -vcodec rawvideo -pix_fmt rgba rgba.avi

ffmpeg -loop 1 -t 5 -i basi4a08.png -vcodec rawvideo -pix_fmt yuv420p yuv420p.avi

and play rgba.avi and yuv420p.avi with vlc.

rgba.avi will look more or less ok (there are still some strange black dots - something like flipped "F", but let's ignore it for now). yuv420p.avi will have vertical black lines, which is not correct.

by ami_stuff, 13 years ago

Attachment: irfanview.bmp added

by ami_stuff, 13 years ago

Attachment: gray_alpha.png added

comment:8 by ami_stuff, 13 years ago

"gray_alpha.png" -> better sample for test.

comment:9 by ami_stuff, 13 years ago

attached pngs works with this:

                } else if (s->bit_depth == 1) {
                    avctx->pix_fmt = PIX_FMT_MONOBLACK;
                } else if (s->bit_depth == 8 &&
                           s->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
-                   avctx->pix_fmt = PIX_FMT_GRAY8A;
+                   avctx->pix_fmt = PIX_FMT_GRAY16BE;
                } else {

comment:10 by Carl Eugen Hoyos, 13 years ago

Keywords: png added

gray_alpha.png was fixed by Michael, the transparency information of basi4a08.png gets lost with
ffmpeg -i basi4a08.png -pix_fmt rgba out.tif

comment:11 by Michael Niedermayer, 12 years ago

Resolution: fixed
Status: openclosed

Cant reproduce any of the mentioned issues anymore.
Also please try to keep 1 issue per bug report.

comment:12 by Carl Eugen Hoyos, 12 years ago

The transparency information of basi4a08.png gets lost with the following command:

$ ffmpeg -i basi4a08.png -pix_fmt rgba out.png
ffmpeg version N-43716-g92b8c9d Copyright (c) 2000-2012 the FFmpeg developers
  built on Aug 18 2012 18:47:44 with gcc 4.6.1 (GCC)
  configuration: --cc=/usr/local/gcc-4.6.1/bin/gcc
  libavutil      51. 70.100 / 51. 70.100
  libavcodec     54. 53.100 / 54. 53.100
  libavformat    54. 25.104 / 54. 25.104
  libavdevice    54.  2.100 / 54.  2.100
  libavfilter     3. 11.101 /  3. 11.101
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
Input #0, image2, from 'basi4a08.png':
  Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: png, gray8a, 32x32, 25 tbr, 25 tbn, 25 tbc
Output #0, image2, to 'out.png':
  Metadata:
    encoder         : Lavf54.25.104
    Stream #0:0: Video: png, rgba, 32x32, q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (png -> png)
Press [q] to stop, [?] for help
frame=    1 fps=0.0 q=0.0 Lsize=       0kB time=00:00:00.04 bitrate=   0.0kbits/s
video:0kB audio:0kB subtitle:0 global headers:0kB muxing overhead -100.000000%

comment:13 by Carl Eugen Hoyos, 12 years ago

Resolution: fixed
Status: closedreopened

comment:14 by Carl Eugen Hoyos, 12 years ago

Component: swscaleavcodec
Resolution: fixed
Status: reopenedclosed

One problem - that the decoded picture looked incorrect with ffplay - was fixed by Michael in January, I opened ticket #1702 for the remaining problem (that the transparency information of gray8a gets lost when converting to rgba).

Note: See TracTickets for help on using tickets.