Files
FFmpeg/libavcodec
Guangyu Sun 34bff02984 avcodec/libvpxenc: fix sRGB colorspace for non-RGB pixel formats
When encoding VP9 with a YUV pixel format (e.g. yuv420p) and
AVCOL_SPC_RGB colorspace metadata, libvpxenc unconditionally set
VPX_CS_SRGB. This produced a spec-violating bitstream: Profile 0
(4:2:0) with sRGB colorspace, which is only valid for Profile 1/3
(4:4:4). The resulting file is undecodable.

Fix this by setting ctx->vpx_cs to VPX_CS_SRGB in set_pix_fmt()
for 4:4:4 YUV formats when AVCOL_SPC_RGB is set, matching the
existing GBRP path. This covers the legitimate case of RGB data in
YUV444 containers (e.g. H.264 High 4:4:4 with identity matrix).

With this change, any AVCOL_SPC_RGB that reaches the switch in
set_colorspace() is guaranteed to be a subsampled format where
sRGB is invalid. Return an error so the user can fix their
pipeline rather than silently producing incorrect output.

To reproduce:

  ffmpeg -f lavfi -i testsrc=s=64x64:d=1:r=1 \
    -c:v libvpx-vp9 -pix_fmt yuv420p -colorspace rgb bad.webm
  ffprobe bad.webm
  # -> "vp9 (Profile 0), none(pc, gbr/...), 64x64"
  ffmpeg -i bad.webm -f null -
  # -> 0 frames decoded, error

See also:
  https://issues.webmproject.org/487307225

Signed-off-by: Guangyu Sun <gsun@roblox.com>
Signed-off-by: James Zern <jzern@google.com>
2026-03-17 13:39:59 -07:00
..
2026-03-10 13:52:18 +01:00
2026-03-10 13:52:19 +01:00
2026-03-10 19:31:00 +01:00
2026-01-02 18:39:48 +01:00
2026-01-02 18:39:48 +01:00
2026-01-02 18:39:48 +01:00
2026-03-10 13:52:19 +01:00
2026-02-23 23:58:11 +01:00
2026-03-13 16:09:40 +00:00
2026-03-13 02:49:59 +01:00
2025-12-30 17:30:45 +00:00
2026-03-10 13:52:19 +01:00
2026-01-02 18:39:48 +01:00
2026-03-07 19:22:40 -03:00
2026-01-10 22:47:22 +01:00
2026-02-04 12:05:35 +08:00
2026-02-04 12:05:35 +08:00
2026-02-11 20:35:20 +00:00
2026-03-10 13:52:19 +01:00
2026-02-19 22:39:35 +00:00
2026-03-02 19:01:46 +01:00
2026-03-02 19:01:46 +01:00
2026-03-10 13:52:18 +01:00
2026-03-03 02:41:05 +01:00
2026-03-10 13:52:19 +01:00
2026-03-03 02:13:58 +00:00
2025-12-30 14:39:08 -05:00
2025-12-30 14:39:08 -05:00
2026-02-23 15:29:27 +00:00
2026-03-10 13:52:18 +01:00
2026-01-02 18:39:48 +01:00
2026-01-02 18:39:48 +01:00
2026-03-16 10:24:33 +00:00