Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/2] swscale: fix gray -> grayf32 SIGFPE
@ 2025-03-16 12:52 Niklas Haas
  2025-03-16 12:52 ` [FFmpeg-devel] [PATCH 2/2] swscale/swscale_unscaled: avoid nv12 <-> nv21 bug Niklas Haas
  0 siblings, 1 reply; 3+ messages in thread
From: Niklas Haas @ 2025-03-16 12:52 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Niklas Haas

From: Niklas Haas <git@haasn.dev>

swscale internals don't distinguish between 16-bit and higher bit depth
output formats internally when it comes to the choice of intermediate
representation.

Clamping this value both prevents a SIGFPE and also aligns the check
with reality.
---
 libswscale/swscale.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 98f94d029f..65ed654ebd 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -586,7 +586,7 @@ static void solve_range_convert(uint16_t src_min, uint16_t src_max,
 
 static void init_range_convert_constants(SwsInternal *c)
 {
-    const int bit_depth = c->dstBpc ? c->dstBpc : 8;
+    const int bit_depth = c->dstBpc ? FFMIN(c->dstBpc, 16) : 8;
     const int src_bits = bit_depth <= 14 ? 15 : 19;
     const int src_shift = src_bits - bit_depth;
     const int mult_shift = bit_depth <= 14 ? 14 : 18;
-- 
2.48.1

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [FFmpeg-devel] [PATCH 2/2] swscale/swscale_unscaled: avoid nv12 <-> nv21 bug
  2025-03-16 12:52 [FFmpeg-devel] [PATCH 1/2] swscale: fix gray -> grayf32 SIGFPE Niklas Haas
@ 2025-03-16 12:52 ` Niklas Haas
  2025-03-16 15:02   ` James Almer
  0 siblings, 1 reply; 3+ messages in thread
From: Niklas Haas @ 2025-03-16 12:52 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Niklas Haas

From: Niklas Haas <git@haasn.dev>

This is not handled by the planar copy wrapper, so exclude it.
---
 libswscale/swscale_unscaled.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c
index 1df160daaa..4959963b18 100644
--- a/libswscale/swscale_unscaled.c
+++ b/libswscale/swscale_unscaled.c
@@ -2660,7 +2660,8 @@ void ff_get_unscaled_swscale(SwsInternal *c)
         (isPlanarYUV(srcFormat) && isPlanarYUV(dstFormat) &&
          c->chrDstHSubSample == c->chrSrcHSubSample &&
          c->chrDstVSubSample == c->chrSrcVSubSample &&
-         isSemiPlanarYUV(srcFormat) == isSemiPlanarYUV(dstFormat))))
+         isSemiPlanarYUV(srcFormat) == isSemiPlanarYUV(dstFormat) &&
+         isSwappedChroma(srcFormat) == isSwappedChroma(dstFormat))))
     {
         if (isPacked(c->opts.src_format))
             c->convert_unscaled = packedCopyWrapper;
-- 
2.48.1

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/2] swscale/swscale_unscaled: avoid nv12 <-> nv21 bug
  2025-03-16 12:52 ` [FFmpeg-devel] [PATCH 2/2] swscale/swscale_unscaled: avoid nv12 <-> nv21 bug Niklas Haas
@ 2025-03-16 15:02   ` James Almer
  0 siblings, 0 replies; 3+ messages in thread
From: James Almer @ 2025-03-16 15:02 UTC (permalink / raw)
  To: ffmpeg-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 1052 bytes --]

On 3/16/2025 9:52 AM, Niklas Haas wrote:
> From: Niklas Haas <git@haasn.dev>
> 
> This is not handled by the planar copy wrapper, so exclude it.
> ---
>   libswscale/swscale_unscaled.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c
> index 1df160daaa..4959963b18 100644
> --- a/libswscale/swscale_unscaled.c
> +++ b/libswscale/swscale_unscaled.c
> @@ -2660,7 +2660,8 @@ void ff_get_unscaled_swscale(SwsInternal *c)
>           (isPlanarYUV(srcFormat) && isPlanarYUV(dstFormat) &&
>            c->chrDstHSubSample == c->chrSrcHSubSample &&
>            c->chrDstVSubSample == c->chrSrcVSubSample &&
> -         isSemiPlanarYUV(srcFormat) == isSemiPlanarYUV(dstFormat))))
> +         isSemiPlanarYUV(srcFormat) == isSemiPlanarYUV(dstFormat) &&
> +         isSwappedChroma(srcFormat) == isSwappedChroma(dstFormat))))
>       {
>           if (isPacked(c->opts.src_format))
>               c->convert_unscaled = packedCopyWrapper;

LGTM.


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-03-16 15:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-16 12:52 [FFmpeg-devel] [PATCH 1/2] swscale: fix gray -> grayf32 SIGFPE Niklas Haas
2025-03-16 12:52 ` [FFmpeg-devel] [PATCH 2/2] swscale/swscale_unscaled: avoid nv12 <-> nv21 bug Niklas Haas
2025-03-16 15:02   ` James Almer

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