Opened 9 years ago

Closed 8 years ago

#4926 closed defect (fixed)

Alpha plane lost on cascaded downscaling

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

Description

Summary of the bug:
Visual artifacts while scaling PNG(rgba) -> PNG(rgba)

How to reproduce:

$ ~/ffmpeg/ffmpeg -y -v debug -i http://storage2.sportowefakty.pl.sds.o2.pl/tags/5611842b1f09f2_20295212.png -s 34x44 /tmp/tmp.png
ffmpeg version N-75978-g3da6c7e Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.8.3 (GCC) 20140911 (Red Hat 4.8.3-9)
  configuration: --prefix=/home/pszemus/ffmpeg/build --enable-pic --enable-pthreads --enable-libmp3lame --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfaac --enable-gpl --enable-nonfree --enable-libvpx --enable-libvorbis --enable-libx264 --enable-protocol=https --enable-openssl --extra-cflags=-I/opt/WP/common.libs/include --extra-ldflags='-L/opt/WP/common.libs/lib -ldl'
  libavutil      55.  3.100 / 55.  3.100
  libavcodec     57.  5.100 / 57.  5.100
  libavformat    57.  3.100 / 57.  3.100
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 11.100 /  6. 11.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.100 /  2.  0.100
  libpostproc    54.  0.100 / 54.  0.100
Splitting the commandline.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.                                                                                                                                                    
Reading option '-v' ... matched as option 'v' (set logging level) with argument 'debug'.                                                                                                                                                     
Reading option '-i' ... matched as input file with argument 'http://storage2.sportowefakty.pl.sds.o2.pl/tags/5611842b1f09f2_20295212.png'.                                                                                                   
Reading option '-s' ... matched as option 's' (set frame size (WxH or abbreviation)) with argument '34x44'.                                                                                                                                  
Reading option '/tmp/tmp.png' ... matched as output file.                                                                                                                                                                                    
Finished splitting the commandline.                                                                                                                                                                                                          
Parsing a group of options: global .                                                                                                                                                                                                         
Applying option y (overwrite output files) with argument 1.                                                                                                                                                                                  
Applying option v (set logging level) with argument debug.                                                                                                                                                                                   
Successfully parsed a group of options.
Parsing a group of options: input file http://storage2.sportowefakty.pl.sds.o2.pl/tags/5611842b1f09f2_20295212.png.
Successfully parsed a group of options.
Opening an input file: http://storage2.sportowefakty.pl.sds.o2.pl/tags/5611842b1f09f2_20295212.png.
[http @ 0x24cdc80] request: GET /tags/5611842b1f09f2_20295212.png HTTP/1.1
User-Agent: Lavf/57.3.100
Accept: */*
Range: bytes=0-
Connection: close
Host: storage2.sportowefakty.pl.sds.o2.pl
Icy-MetaData: 1


[png_pipe @ 0x24cd380] Format png_pipe probed with size=2048 and score=99
[png_pipe @ 0x24cd380] Before avformat_find_stream_info() pos: 0 bytes read:2573 seeks:0
[png_pipe @ 0x24cd380] After avformat_find_stream_info() pos: 191689 bytes read:191689 seeks:0 frames:1
Input #0, png_pipe, from 'http://storage2.sportowefakty.pl.sds.o2.pl/tags/5611842b1f09f2_20295212.png':
  Duration: N/A, bitrate: N/A
    Stream #0:0, 1, 1/25: Video: png, 1 reference frame, rgba(pc), 2200x2827 (0x0), 1/25, 25 tbr, 25 tbn, 25 tbc
Successfully opened the file.
Parsing a group of options: output file /tmp/tmp.png.
Applying option s (set frame size (WxH or abbreviation)) with argument 34x44.
Successfully parsed a group of options.
Opening an output file: /tmp/tmp.png.
Successfully opened the file.
detected 2 logical cores
[graph 0 input from stream 0:0 @ 0x24d1a40] Setting 'video_size' to value '2200x2827'
[graph 0 input from stream 0:0 @ 0x24d1a40] Setting 'pix_fmt' to value '28'
[graph 0 input from stream 0:0 @ 0x24d1a40] Setting 'time_base' to value '1/25'
[graph 0 input from stream 0:0 @ 0x24d1a40] Setting 'pixel_aspect' to value '0/1'
[graph 0 input from stream 0:0 @ 0x24d1a40] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:0 @ 0x24d1a40] Setting 'frame_rate' to value '25/1'
[graph 0 input from stream 0:0 @ 0x24d1a40] w:2200 h:2827 pixfmt:rgba tb:1/25 fr:25/1 sar:0/1 sws_param:flags=2
[scaler for output stream 0:0 @ 0x24d6c60] Setting 'w' to value '34'
[scaler for output stream 0:0 @ 0x24d6c60] Setting 'h' to value '44'
[scaler for output stream 0:0 @ 0x24d6c60] Setting 'flags' to value 'bicubic'
[scaler for output stream 0:0 @ 0x24d6c60] w:34 h:44 flags:'bicubic' interl:0
[format @ 0x24d7800] compat: called with args=[rgb24|rgba|rgb48be|rgba64be|pal8|gray|ya8|gray16be|ya16be|monob]
[format @ 0x24d7800] Setting 'pix_fmts' to value 'rgb24|rgba|rgb48be|rgba64be|pal8|gray|ya8|gray16be|ya16be|monob'
[AVFilterGraph @ 0x24d6060] query_formats: 5 queried, 4 merged, 0 already done, 0 delayed
[swscaler @ 0x24e14e0] Forcing full internal H chroma due to input having non subsampled chroma
sws: initFilter failed
[scaler for output stream 0:0 @ 0x24d6c60] w:2200 h:2827 fmt:rgba sar:0/1 -> w:34 h:44 fmt:rgba sar:0/1 flags:0x4
Output #0, image2, to '/tmp/tmp.png':
  Metadata:
    encoder         : Lavf57.3.100
    Stream #0:0, 0, 1/25: Video: png, 1 reference frame, rgba, 34x44, 1/25, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.5.100 png
Stream mapping:
  Stream #0:0 -> #0:0 (png (native) -> png (native))
Press [q] to stop, [?] for help
Cliping frame in rate conversion by 0.000008
[AVIOContext @ 0x276b9e0] Statistics: 0 seeks, 1 writeouts
[output stream 0:0 @ 0x24d7080] EOF on sink link output stream 0:0:default.
No more output streams to write to, finishing.
frame=    1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A    
video:3kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Input file #0 (http://storage2.sportowefakty.pl.sds.o2.pl/tags/5611842b1f09f2_20295212.png):
  Input stream #0:0 (video): 1 packets read (191689 bytes); 1 frames decoded; 
  Total: 1 packets (191689 bytes) demuxed
Output file #0 (/tmp/tmp.png):
  Output stream #0:0 (video): 1 frames encoded; 1 packets muxed (2577 bytes); 
  Total: 1 packets (2577 bytes) muxed
1 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x24d9400] Statistics: 191689 bytes read, 0 seeks

What's odd, scaling to 35x44 produces correct image (with alpha plane).

Attachments (2)

5611842b1f09f2_20295212.png (187.2 KB ) - added by pszemus 9 years ago.
Remote file attached
5611842b1f09f2_20295212-out.png (2.5 KB ) - added by pszemus 9 years ago.
Incorrect output image

Download all attachments as: .zip

Change History (7)

by pszemus, 9 years ago

Attachment: 5611842b1f09f2_20295212.png added

Remote file attached

comment:1 by Carl Eugen Hoyos, 9 years ago

Resolution: worksforme
Status: newclosed

I cannot reproduce the issue and the version number of your build does not exist (you are at least two commits ahead). Please rebuild current FFmpeg with ./configure && make or ./configure --enable-gpl && make and reopen if the issue is reproducible.

comment:2 by pszemus, 9 years ago

Resolution: worksforme
Status: closedreopened

I've git resetted and recompiled. Problem still occurs. I'm attaching my output image and command line:

$ ~/ffmpeg/ffmpeg -y -v debug -i http://storage2.sportowefakty.pl.sds.o2.pl/tags/5611842b1f09f2_20295212.png -s 34x44 /tmp/5611842b1f09f2_20295212-out.png
ffmpeg version N-75982-g64ceeac Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.8.3 (GCC) 20140911 (Red Hat 4.8.3-9)
  configuration: --prefix=/home/pszemus/ffmpeg/build --enable-pic --enable-pthreads --enable-libmp3lame --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfaac --enable-gpl --enable-nonfree --enable-libvpx --enable-libvorbis --enable-libx264 --enable-protocol=https --enable-openssl --extra-cflags=-I/opt/WP/common.libs/include --extra-ldflags='-L/opt/WP/common.libs/lib -ldl'
  libavutil      55.  3.100 / 55.  3.100
  libavcodec     57.  6.100 / 57.  6.100
  libavformat    57.  3.100 / 57.  3.100
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 11.100 /  6. 11.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.100 /  2.  0.100
  libpostproc    54.  0.100 / 54.  0.100
Splitting the commandline.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.                                                                                                                                                    
Reading option '-v' ... matched as option 'v' (set logging level) with argument 'debug'.                                                                                                                                                     
Reading option '-i' ... matched as input file with argument 'http://storage2.sportowefakty.pl.sds.o2.pl/tags/5611842b1f09f2_20295212.png'.                                                                                                   
Reading option '-s' ... matched as option 's' (set frame size (WxH or abbreviation)) with argument '34x44'.
Reading option '/tmp/5611842b1f09f2_20295212-out.png' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option y (overwrite output files) with argument 1.
Applying option v (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input file http://storage2.sportowefakty.pl.sds.o2.pl/tags/5611842b1f09f2_20295212.png.
Successfully parsed a group of options.
Opening an input file: http://storage2.sportowefakty.pl.sds.o2.pl/tags/5611842b1f09f2_20295212.png.
[http @ 0x2abac80] request: GET /tags/5611842b1f09f2_20295212.png HTTP/1.1
User-Agent: Lavf/57.3.100
Accept: */*
Range: bytes=0-
Connection: close
Host: storage2.sportowefakty.pl.sds.o2.pl
Icy-MetaData: 1


[png_pipe @ 0x2aba380] Format png_pipe probed with size=2048 and score=99
[png_pipe @ 0x2aba380] Before avformat_find_stream_info() pos: 0 bytes read:2575 seeks:0
[png_pipe @ 0x2aba380] After avformat_find_stream_info() pos: 191689 bytes read:191689 seeks:0 frames:1
Input #0, png_pipe, from 'http://storage2.sportowefakty.pl.sds.o2.pl/tags/5611842b1f09f2_20295212.png':
  Duration: N/A, bitrate: N/A
    Stream #0:0, 1, 1/25: Video: png, 1 reference frame, rgba(pc), 2200x2827 (0x0), 1/25, 25 tbr, 25 tbn, 25 tbc
Successfully opened the file.
Parsing a group of options: output file /tmp/5611842b1f09f2_20295212-out.png.
Applying option s (set frame size (WxH or abbreviation)) with argument 34x44.
Successfully parsed a group of options.
Opening an output file: /tmp/5611842b1f09f2_20295212-out.png.
Successfully opened the file.
detected 2 logical cores
[graph 0 input from stream 0:0 @ 0x2abea40] Setting 'video_size' to value '2200x2827'
[graph 0 input from stream 0:0 @ 0x2abea40] Setting 'pix_fmt' to value '28'
[graph 0 input from stream 0:0 @ 0x2abea40] Setting 'time_base' to value '1/25'
[graph 0 input from stream 0:0 @ 0x2abea40] Setting 'pixel_aspect' to value '0/1'
[graph 0 input from stream 0:0 @ 0x2abea40] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:0 @ 0x2abea40] Setting 'frame_rate' to value '25/1'
[graph 0 input from stream 0:0 @ 0x2abea40] w:2200 h:2827 pixfmt:rgba tb:1/25 fr:25/1 sar:0/1 sws_param:flags=2
[scaler for output stream 0:0 @ 0x2ac3c60] Setting 'w' to value '34'
[scaler for output stream 0:0 @ 0x2ac3c60] Setting 'h' to value '44'
[scaler for output stream 0:0 @ 0x2ac3c60] Setting 'flags' to value 'bicubic'
[scaler for output stream 0:0 @ 0x2ac3c60] w:34 h:44 flags:'bicubic' interl:0
[format @ 0x2ac4800] compat: called with args=[rgb24|rgba|rgb48be|rgba64be|pal8|gray|ya8|gray16be|ya16be|monob]
[format @ 0x2ac4800] Setting 'pix_fmts' to value 'rgb24|rgba|rgb48be|rgba64be|pal8|gray|ya8|gray16be|ya16be|monob'
[AVFilterGraph @ 0x2ac3060] query_formats: 5 queried, 4 merged, 0 already done, 0 delayed
[swscaler @ 0x2ace4e0] Forcing full internal H chroma due to input having non subsampled chroma
sws: initFilter failed
[scaler for output stream 0:0 @ 0x2ac3c60] w:2200 h:2827 fmt:rgba sar:0/1 -> w:34 h:44 fmt:rgba sar:0/1 flags:0x4
Output #0, image2, to '/tmp/5611842b1f09f2_20295212-out.png':
  Metadata:
    encoder         : Lavf57.3.100
    Stream #0:0, 0, 1/25: Video: png, 1 reference frame, rgba, 34x44, 1/25, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.6.100 png
Stream mapping:
  Stream #0:0 -> #0:0 (png (native) -> png (native))
Press [q] to stop, [?] for help
Cliping frame in rate conversion by 0.000008
[output stream 0:0 @ 0x2ac4080] EOF on sink link output stream 0:0:default.
No more output streams to write to, finishing.
[AVIOContext @ 0x2d589e0] Statistics: 0 seeks, 1 writeouts
frame=    1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A    
video:3kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Input file #0 (http://storage2.sportowefakty.pl.sds.o2.pl/tags/5611842b1f09f2_20295212.png):
  Input stream #0:0 (video): 1 packets read (191689 bytes); 1 frames decoded; 
  Total: 1 packets (191689 bytes) demuxed
Output file #0 (/tmp/5611842b1f09f2_20295212-out.png):
  Output stream #0:0 (video): 1 frames encoded; 1 packets muxed (2577 bytes); 
  Total: 1 packets (2577 bytes) muxed
1 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x2ac6400] Statistics: 191689 bytes read, 0 seeks

by pszemus, 9 years ago

Incorrect output image

comment:3 by Carl Eugen Hoyos, 9 years ago

Component: undeterminedswscale
Keywords: png alpha added
Reproduced by developer: set
Status: reopenedopen
Summary: Visual artifacts while scaling PNG(rgba) -> PNG(rgba)Alpha plane lost when scaling down in multiple passes
Version: unspecifiedgit-master

Not reproducible when upscaling afaict.

comment:4 by Carl Eugen Hoyos, 9 years ago

Summary: Alpha plane lost when scaling down in multiple passesAlpha plane lost on cascaded downscaling

comment:5 by Michael Niedermayer, 8 years ago

Resolution: fixed
Status: openclosed
Note: See TracTickets for help on using tickets.