Opened 4 years ago

Closed 2 years ago

Last modified 2 years ago

#2394 closed defect (fixed)

BGRA downscaling shifts colors

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

Description

Downscaling in BGRA produce a color shift.

How to reproduce:

./ffmpeg_g -lavfi color=c=blue:s=256x256,format=bgra,scale=4:4 \
  -vframes 1 -f rawvideo - | xxd
ffmpeg version N-51202-gf8217da Copyright (c) 2000-2013 the FFmpeg developers
  built on Mar 21 2013 20:43:35 with gcc 4.7 (Debian 4.7.2-5)
  configuration: --enable-shared --disable-static --enable-gpl --enable-libx264 --enable-libass --enable-libfreetype --enable-libopus --assert-level=2
  libavutil      52. 22.100 / 52. 22.100
  libavcodec     55.  1.100 / 55.  1.100
  libavformat    55.  0.100 / 55.  0.100
  libavdevice    55.  0.100 / 55.  0.100
  libavfilter     3. 48.100 /  3. 48.100
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Output #0, rawvideo, to 'pipe:':
  Metadata:
    encoder         : Lavf55.0.100
    Stream #0:0: Video: rawvideo (BGRA / 0x41524742), bgra, 4x4 [SAR 1:1 DAR 1:1], q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
  scale -> Stream #0:0 (rawvideo)
Press [q] to stop, [?] for help
frame=    1 fps=0.0 q=0.0 Lsize=       0kB time=00:00:00.04 bitrate=  12.8kbits/s    
video:0kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.000000%

0000000: ed00 00f6 ed00 00f6 ed00 00f6 ed00 00f6  ................
0000010: e700 00f4 e700 00f4 e700 00f4 e700 00f4  ................
0000020: fd00 00ff fd00 00ff fd00 00ff fd00 00ff  ................
0000030: fd00 00ff fd00 00ff fd00 00ff fd00 00ff  ................

The same thing with RGBA instead of BGRA produces uniform 0000 fdff, which seems correct.

The phenomenon increases with the downscaling factor. The output size, OTOH, does not matter much. Only the last two lines are exempt.

Change History (6)

comment:1 Changed 4 years ago by Cigaes

Extra info: --disable-asm makes the problem go away. Config differences when asm is enabled:

+#define ARCH_X86 1
+#define ARCH_X86_64 1
+#define HAVE_AMD3DNOW 1
+#define HAVE_AMD3DNOWEXT 1
+#define HAVE_AVX 1
+#define HAVE_FMA4 1
+#define HAVE_MMX 1
+#define HAVE_MMXEXT 1
+#define HAVE_SSE 1
+#define HAVE_SSE2 1
+#define HAVE_SSE3 1
+#define HAVE_SSE4 1
+#define HAVE_SSE42 1
+#define HAVE_SSSE3 1
+#define HAVE_AMD3DNOW_EXTERNAL 1
+#define HAVE_AMD3DNOWEXT_EXTERNAL 1
+#define HAVE_AVX_EXTERNAL 1
+#define HAVE_FMA4_EXTERNAL 1
+#define HAVE_MMX_EXTERNAL 1
+#define HAVE_MMXEXT_EXTERNAL 1
+#define HAVE_SSE_EXTERNAL 1
+#define HAVE_SSE2_EXTERNAL 1
+#define HAVE_SSE3_EXTERNAL 1
+#define HAVE_SSE4_EXTERNAL 1
+#define HAVE_SSE42_EXTERNAL 1
+#define HAVE_SSSE3_EXTERNAL 1
+#define HAVE_AMD3DNOW_INLINE 1
+#define HAVE_AMD3DNOWEXT_INLINE 1
+#define HAVE_AVX_INLINE 1
+#define HAVE_FMA4_INLINE 1
+#define HAVE_MMX_INLINE 1
+#define HAVE_MMXEXT_INLINE 1
+#define HAVE_SSE_INLINE 1
+#define HAVE_SSE2_INLINE 1
+#define HAVE_SSE3_INLINE 1
+#define HAVE_SSE4_INLINE 1
+#define HAVE_SSE42_INLINE 1
+#define HAVE_SSSE3_INLINE 1
+#define HAVE_YASM 1
+#define HAVE_FAST_UNALIGNED 1
+#define HAVE_ALIGNED_STACK 1
+#define HAVE_CMOV 1
+#define HAVE_CPUNOP 1
+#define HAVE_FAST_64BIT 1
+#define HAVE_FAST_CLZ 1
+#define HAVE_FAST_CMOV 1
+#define HAVE_GNU_AS 1
+#define CONFIG_FAST_UNALIGNED 1

comment:2 follow-up: Changed 4 years ago by cehoyos

  • Reproduced by developer set
  • Status changed from new to open
  • Summary changed from BGRA downscaling shift colors to BGRA downscaling shifts colors

Also reproducible with 0.6 with the following command(s):
$ ffmpeg -lavfi color=c=blue:s=128x128,format=bgra -f rawvideo bgra.raw
$ ffmpeg -lavfi color=c=blue:s=128x128,format=rgba -f rawvideo rgba.raw

$ ffmpeg06 -f rawvideo -pix_fmt bgra -s 128x128 -i bgra.raw -s 8x8 -f rawvideo - | xxd
$ ffmpeg06 -f rawvideo -pix_fmt rgba -s 128x128 -i rgba.raw -s 8x8 -f rawvideo - | xxd

Reproducible with --disable-mmxext, not reproducible with --disable-mmx (once compilation is fixed).
-cpuflags -mmx crashes here

Version 0, edited 4 years ago by cehoyos (next)

comment:3 in reply to: ↑ 2 Changed 4 years ago by michael

Replying to cehoyos:

Reproducible with --disable-mmxext, not reproducible with --disable-mmx (-cpuflags -mmx crashes here).

-cpuflags -mmx
removes mmx but not later flags like mmx2 / sse, this combination doesnt exist in actual hardware CPUs and is thus poorly supported. If someone wants to fix all such crashes i dont mind but it has little practical use

comment:4 Changed 2 years ago by michael

  • Resolution set to worksforme
  • Status changed from open to closed

cant reproduce anymore, so i assume this has probably been fixed
please reopen if its still reproduceabel for you

comment:5 Changed 2 years ago by cehoyos

Not reproducible since a830915b78e2d96f08dc93b2d1c4330448b83ffd - see ticket #3028

comment:6 Changed 2 years ago by cehoyos

  • Resolution changed from worksforme to fixed
Note: See TracTickets for help on using tickets.