Commit d5df26b5 for libheif

commit d5df26b5d2deb000f6743d61e2fd13ee4844774b
Author: John Preston <johnprestonmail@gmail.com>
Date:   Fri Sep 25 17:35:33 2026 +0400

    FFmpeg decoder: support planar GBR output

    FFmpeg's HEVC decoder returns GBRP/GBRP10/GBRP12 instead of YUV 4:4:4
    for streams signaling matrix_coefficients 0. Map the G, B, R planes
    onto Y, Cb, Cr, which is how libheif stores the identity matrix.

diff --git a/libheif/plugins/decoder_ffmpeg.cc b/libheif/plugins/decoder_ffmpeg.cc
index 27fcac48..3af918c1 100644
--- a/libheif/plugins/decoder_ffmpeg.cc
+++ b/libheif/plugins/decoder_ffmpeg.cc
@@ -382,6 +382,14 @@ static heif_chroma ffmpeg_get_chroma_format(AVPixelFormat pix_fmt) {
     case AV_PIX_FMT_YUV444P16:
       return heif_chroma_444;

+    // FFmpeg's HEVC decoder outputs planar GBR for 4:4:4 streams signaling
+    // matrix_coefficients 0. Its G, B, R planes map onto Y, Cb, Cr, which is
+    // exactly how libheif stores images with the identity matrix.
+    case AV_PIX_FMT_GBRP:
+    case AV_PIX_FMT_GBRP10:
+    case AV_PIX_FMT_GBRP12:
+      return heif_chroma_444;
+
     default:
       // Unsupported pix_fmt
       return heif_chroma_undefined;
@@ -428,16 +436,19 @@ static int get_ffmpeg_format_bpp(AVPixelFormat pix_fmt)
     case AV_PIX_FMT_YUVJ420P:
     case AV_PIX_FMT_YUV422P:
     case AV_PIX_FMT_YUV444P:
+    case AV_PIX_FMT_GBRP:
       return 8;
     case AV_PIX_FMT_GRAY10:
     case AV_PIX_FMT_YUV420P10:
     case AV_PIX_FMT_YUV422P10:
     case AV_PIX_FMT_YUV444P10:
+    case AV_PIX_FMT_GBRP10:
       return 10;
     case AV_PIX_FMT_GRAY12:
     case AV_PIX_FMT_YUV420P12:
     case AV_PIX_FMT_YUV422P12:
     case AV_PIX_FMT_YUV444P12:
+    case AV_PIX_FMT_GBRP12:
       return 12;
     case AV_PIX_FMT_GRAY14:
     case AV_PIX_FMT_YUV420P14: