Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#9077 closed defect (fixed)

Transparency wrong for yuv420 -> rgba on altivec

Reported by: pocock Owned by:
Priority: normal Component: swscale
Version: git-master Keywords: ppc altivec
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Summary of the bug:
How to reproduce:

ffmpeg -loglevel 48 -i VID_20150419_101911.mp4 -vframes 1 -pix_fmt rgba out.png


ffmpeg version 7:4.3.1-5~bpo10+1 with patch from #5570
built on Debian 10 / ppc64le

Discussed in Blender bug tracker
https://developer.blender.org/T80912#1095862

Copy of input file:
https://dev-files.blender.org/file/data/zkoixegxcuagluo2dd33/PHID-FILE-solnqodzm6hk76h4ud2f/VID_20150419_101911.mp4

PNG / Screenshot of broken output:
https://dev-files.blender.org/file/data/2ubaxhcrkusf6udvddh6/PHID-FILE-7izlml2yionqysqn4gma/ffmpeg-out.png

Console output from the ffmpeg command above:
https://dev-files.blender.org/file/download/jhiqfzxxqxqbscaph4of/PHID-FILE-krwaflq6uba7t3qjler6/ffmpeg-test-1.txt

Change History (6)

comment:1 by pocock, 4 years ago

Summary: image not rendered, vertical bars missingimage not rendered correctly, vertical bars missing

comment:2 by Carl Eugen Hoyos, 4 years ago

Component: undeterminedswscale
Keywords: ppc added; cat removed
Priority: importantnormal
Reproduced by developer: set
Status: newopen
Summary: image not rendered correctly, vertical bars missingyuv420 -> rgb32 broken on altivec

For future tickets:
Please test current FFmpeg git head, the only version supported on this bug tracker and please always provide all information here on the bug tracker, do not use external resources except for large input files.

Workaround is to convert to rgb24.

$ ffmpeg -f lavfi -i testsrc2 -vframes 1 -pix_fmt rgba out.png
ffmpeg version N-100746-gd8a585d Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 8.3.1 (GCC) 20190304 (Advance-Toolchain-at12.0) [revision 269374]
  configuration: --enable-gpl --cc=/opt/at12.0/bin/gcc
  libavutil      56. 63.101 / 56. 63.101
  libavcodec     58.117.101 / 58.117.101
  libavformat    58. 65.101 / 58. 65.101
  libavdevice    58. 11.103 / 58. 11.103
  libavfilter     7. 96.100 /  7. 96.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
Input #0, lavfi, from 'testsrc2':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> png (native))
Press [q] to stop, [?] for help
[swscaler @ 0x2c840490] ALTIVEC: Color Space RGBA
Output #0, image2, to 'out.png':
  Metadata:
    encoder         : Lavf58.65.101
    Stream #0:0: Video: png, rgba(pc, progressive), 320x240 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 25 fps, 25 tbn
    Metadata:
      encoder         : Lavc58.117.101 png
frame=    1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A speed=0.626x    
video:10kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

Output is visually broken.
On Power6, Power7 etc. this is a regression since 8dcbfb73d58c06fa012db5ffea97647fed95a280

comment:3 by Carl Eugen Hoyos, 4 years ago

Keywords: altivec added
Summary: yuv420 -> rgb32 broken on altivecTransparency wrong for yuv420 -> rgba on altivec

The current behaviour (transparency broken) is also reproducible with 68363b6989f3355457af90f0c568ccbae9d4deb2 (the fix seems not to work correctly), the output was broken differently before, this brokenness was fixed since, likely #7124.

ffmpeg -f rawvideo -s 320x240 -i out.yuv -pix_fmt rgb32_1 -vframes 1 -y -f image2 out.sgi
FFmpeg version git-68363b6, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration: --enable-swscale --enable-gpl --cc=/opt/at12.0/bin/gcc -m32
  libavutil     49.15. 0 / 49.15. 0
  libavcodec    52.20. 0 / 52.20. 0
  libavformat   52.30. 1 / 52.30. 1
  libavdevice   52. 1. 0 / 52. 1. 0
  libswscale     0. 7. 1 /  0. 7. 1
  built on Jan 23 2021 15:48:35, gcc: 8.3.1 20190304 (Advance-Toolchain-at12.0) [revision 269374]
Input #0, rawvideo, from 'out.yuv':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0.0: Video: rawvideo, yuv420p, 320x240, 25 tbr, 25 tbn, 25 tbc
[swscaler @ 0x10be1d00]ALTIVEC: Color Space RGBA
Output #0, image2, to 'out.sgi':
    Stream #0.0: Video: sgi, rgb32_1, 320x240, q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
  Stream #0.0 -> #0.0
Press [q] to stop encoding
frame=    1 fps=  0 q=0.0 Lsize=      -0kB time=0.04 bitrate=  -4.4kbits/s    
video:66kB audio:0kB global headers:0kB muxing overhead -100.032543%
Last edited 4 years ago by Carl Eugen Hoyos (previous) (diff)

comment:4 by Carl Eugen Hoyos, 4 years ago

Feel free to test this change:

diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
index 58e480d..eb6b3d7 100644
--- a/libswscale/ppc/yuv2rgb_altivec.c
+++ b/libswscale/ppc/yuv2rgb_altivec.c
@@ -425,13 +425,13 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
 }
 
 #define out_abgr(a, b, c, ptr)                                          \
-    vec_mstrgb32(__typeof__(a), ((__typeof__(a)) { 255 }), c, b, a, ptr)
+    vec_mstrgb32(__typeof__(a), ((__typeof__(a)) { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }), c, b, a, ptr)
 #define out_bgra(a, b, c, ptr)                                          \
-    vec_mstrgb32(__typeof__(a), c, b, a, ((__typeof__(a)) { 255 }), ptr)
+    vec_mstrgb32(__typeof__(a), c, b, a, ((__typeof__(a)) { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }), ptr)
 #define out_rgba(a, b, c, ptr)                                          \
-    vec_mstrgb32(__typeof__(a), a, b, c, ((__typeof__(a)) { 255 }), ptr)
+    vec_mstrgb32(__typeof__(a), a, b, c, ((__typeof__(a)) { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }), ptr)
 #define out_argb(a, b, c, ptr)                                          \
-    vec_mstrgb32(__typeof__(a), ((__typeof__(a)) { 255 }), a, b, c, ptr)
+    vec_mstrgb32(__typeof__(a), ((__typeof__(a)) { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }), a, b, c, ptr)
 #define out_rgb24(a, b, c, ptr) vec_mstrgb24(a, b, c, ptr)
 #define out_bgr24(a, b, c, ptr) vec_mstbgr24(a, b, c, ptr)
 

comment:5 by Carl Eugen Hoyos, 4 years ago

Resolution: fixed
Status: openclosed

comment:6 by pocock, 4 years ago

I downloaded the commit as a patch, applied it on 4.3.1 and it fixed the problem for me. Thanks for fixing this so quickly.

Updated the details in the Blender bug too
https://developer.blender.org/T80912#1099699

Note: See TracTickets for help on using tickets.