Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Mark Thompson <sw@jkqxz.net>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH 2/2] lavfi/ddagrab: Fix 8-bit BGR output to not advertise an alpha component
Date: Sun, 22 Oct 2023 15:56:37 +0100
Message-ID: <efe2b22f-8e7a-45d9-a2f3-7a07776c0606@jkqxz.net> (raw)
In-Reply-To: <90f15b31-bfc5-4152-a38c-ec58d444e59b@jkqxz.net>

There is never an alpha component here, so the actual format is BGR0
rather than BGRA.  This fixes cases which maintain the alpha component
and therefore generate unexpected results.
---
E.g. fixes download and encode with PNG to make an RGB PNG as expected, rather than an RGBA PNG with nothing in the alpha channel.  (Previously this was relying on the user to realise that the alpha channel contained nothing and ignore it.)

  doc/filters.texi           | 2 +-
  libavfilter/vsrc_ddagrab.c | 6 +++---
  2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index f5032ddf74..550f9a6ecc 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -28183,7 +28183,7 @@ It accepts the following values:
  @item auto
  Passes all supported output formats to DDA and returns what DDA decides to use.
  @item 8bit
-@item bgra
+@item bgrx
  8 Bit formats always work, and DDA will convert to them if neccesary.
  @item 10bit
  @item x2bgr10
diff --git a/libavfilter/vsrc_ddagrab.c b/libavfilter/vsrc_ddagrab.c
index 9c59faf53e..8ff3c97959 100644
--- a/libavfilter/vsrc_ddagrab.c
+++ b/libavfilter/vsrc_ddagrab.c
@@ -115,14 +115,14 @@ static const AVOption ddagrab_options[] = {
      { "output_fmt", "desired output format",       OFFSET(out_fmt),    AV_OPT_TYPE_INT,        { .i64 = DXGI_FORMAT_B8G8R8A8_UNORM },    0, INT_MAX, FLAGS, "output_fmt" },
      { "auto",       "let dda pick its preferred format", 0,            AV_OPT_TYPE_CONST,      { .i64 = 0 },                             0, INT_MAX, FLAGS, "output_fmt" },
      { "8bit",       "only output default 8 Bit format",  0,            AV_OPT_TYPE_CONST,      { .i64 = DXGI_FORMAT_B8G8R8A8_UNORM },    0, INT_MAX, FLAGS, "output_fmt" },
-    { "bgra",       "only output 8 Bit BGRA",            0,            AV_OPT_TYPE_CONST,      { .i64 = DXGI_FORMAT_B8G8R8A8_UNORM },    0, INT_MAX, FLAGS, "output_fmt" },
+    { "bgrx",       "only output 8 Bit BGRX",            0,            AV_OPT_TYPE_CONST,      { .i64 = DXGI_FORMAT_B8G8R8A8_UNORM },    0, INT_MAX, FLAGS, "output_fmt" },
      { "10bit",      "only output default 10 Bit format", 0,            AV_OPT_TYPE_CONST,      { .i64 = DXGI_FORMAT_R10G10B10A2_UNORM }, 0, INT_MAX, FLAGS, "output_fmt" },
      { "x2bgr10",    "only output 10 Bit X2BGR10",        0,            AV_OPT_TYPE_CONST,      { .i64 = DXGI_FORMAT_R10G10B10A2_UNORM }, 0, INT_MAX, FLAGS, "output_fmt" },
      { "16bit",      "only output default 16 Bit format", 0,            AV_OPT_TYPE_CONST,      { .i64 = DXGI_FORMAT_R16G16B16A16_FLOAT },0, INT_MAX, FLAGS, "output_fmt" },
      { "rgbaf16",    "only output 16 Bit RGBAF16",        0,            AV_OPT_TYPE_CONST,      { .i64 = DXGI_FORMAT_R16G16B16A16_FLOAT },0, INT_MAX, FLAGS, "output_fmt" },
      { "allow_fallback", "don't error on fallback to default 8 Bit format",
                                                     OFFSET(allow_fallback), AV_OPT_TYPE_BOOL,   { .i64 = 0    },       0,       1, FLAGS },
-    { "force_fmt",  "exclude BGRA from format list (experimental, discouraged by Microsoft)",
+    { "force_fmt",  "exclude BGRX from format list (experimental, discouraged by Microsoft)",
                                                     OFFSET(force_fmt),  AV_OPT_TYPE_BOOL,       { .i64 = 0    },       0,       1, FLAGS },
      { NULL }
  };
@@ -775,7 +775,7 @@ static av_cold int init_hwframes_ctx(AVFilterContext *avctx)
      switch (dda->raw_format) {
      case DXGI_FORMAT_B8G8R8A8_UNORM:
          av_log(avctx, AV_LOG_VERBOSE, "Probed 8 bit RGB frame format\n");
-        dda->frames_ctx->sw_format = AV_PIX_FMT_BGRA;
+        dda->frames_ctx->sw_format = AV_PIX_FMT_BGR0;
          break;
      case DXGI_FORMAT_R10G10B10A2_UNORM:
          av_log(avctx, AV_LOG_VERBOSE, "Probed 10 bit RGB frame format\n");
-- 
2.39.2
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  reply	other threads:[~2023-10-22 14:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-22 14:54 [FFmpeg-devel] [PATCH 1/2] hwcontext_d3d11: Add BGR0 support Mark Thompson
2023-10-22 14:56 ` Mark Thompson [this message]
2023-11-27 13:43 ` Mark Thompson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=efe2b22f-8e7a-45d9-a2f3-7a07776c0606@jkqxz.net \
    --to=sw@jkqxz.net \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git