mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH 1/2] ffmpeg: enable filters and swscale
@ 2025-11-14 14:20 Sven Püschel
  2025-11-14 14:20 ` [ptxdist] [PATCH 2/2] gst-libav1: fix avvideocompare element Sven Püschel
  0 siblings, 1 reply; 4+ messages in thread
From: Sven Püschel @ 2025-11-14 14:20 UTC (permalink / raw)
  To: ptxdist; +Cc: Sven Püschel

Enable the filters and swscale, as they are required by the GStreamer
avvideocompare element. This uses the ssim or psnr filter to compare
two video inputs. Internally this also expects swscale to be available
to potentially scale the inputs to the same size.

The change increases the libavfilter.so file size from 148.0K to 4.3M.
The remaining shared libraries from libav keep their size.

Signed-off-by: Sven Püschel <s.pueschel@pengutronix.de>
---
 rules/ffmpeg.make | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/rules/ffmpeg.make b/rules/ffmpeg.make
index 3f177021b..f1b304fc4 100644
--- a/rules/ffmpeg.make
+++ b/rules/ffmpeg.make
@@ -75,7 +75,7 @@ FFMPEG_CONF_OPT		:= \
 	--enable-avcodec \
 	--enable-avformat \
 	--enable-swresample \
-	--disable-swscale \
+	--enable-swscale \
 	--enable-avfilter \
 	\
 	--enable-pthreads \
@@ -98,7 +98,7 @@ FFMPEG_CONF_OPT		:= \
 	--disable-indevs \
 	--disable-outdevs \
 	--disable-devices \
-	--disable-filters \
+	--enable-filters \
 	\
 	--disable-alsa \
 	--disable-appkit \
-- 
2.47.3




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

* [ptxdist] [PATCH 2/2] gst-libav1: fix avvideocompare element
  2025-11-14 14:20 [ptxdist] [PATCH 1/2] ffmpeg: enable filters and swscale Sven Püschel
@ 2025-11-14 14:20 ` Sven Püschel
  2025-11-27 10:51   ` Michael Olbrich
  0 siblings, 1 reply; 4+ messages in thread
From: Sven Püschel @ 2025-11-14 14:20 UTC (permalink / raw)
  To: ptxdist; +Cc: Sven Püschel

With the update to FFmpeg 8.0 the avvideocompare element from GStreamer
doesn't emit statistics anymore. Add a patch to fix the underlying
issue of missing colorimetry information.

Fixes: 254f9c65f4dd ("ffmpeg: version bump 7.1.1 -> 8.0")
Signed-off-by: Sven Püschel <s.pueschel@pengutronix.de>
---
 ...-avvidcmp-set-colorimetry-on-AVFrame.patch | 75 +++++++++++++++++++
 patches/gst-libav-1.26.0/series               |  4 +
 2 files changed, 79 insertions(+)
 create mode 100644 patches/gst-libav-1.26.0/0001-gst-libav-avvidcmp-set-colorimetry-on-AVFrame.patch
 create mode 100644 patches/gst-libav-1.26.0/series

diff --git a/patches/gst-libav-1.26.0/0001-gst-libav-avvidcmp-set-colorimetry-on-AVFrame.patch b/patches/gst-libav-1.26.0/0001-gst-libav-avvidcmp-set-colorimetry-on-AVFrame.patch
new file mode 100644
index 000000000..1a499537d
--- /dev/null
+++ b/patches/gst-libav-1.26.0/0001-gst-libav-avvidcmp-set-colorimetry-on-AVFrame.patch
@@ -0,0 +1,75 @@
+From: =?UTF-8?q?Sven=20P=C3=BCschel?= <s.pueschel@pengutronix.de>
+Date: Fri, 14 Nov 2025 10:50:51 +0100
+Subject: [PATCH] gst-libav: avvidcmp: set colorimetry on AVFrame
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Set the colorimetry on AVFrame based on the GstVideoFrame values.
+This properly maps potential colorimetry information to libav.
+
+Furthermore this fixes the avvideocompare element when used with
+FFmpeg 8.0. When comparing video frames FFmpeg also uses the scale
+filter. This has been reworked to use a new API [1], which checks
+that the color primaries and transfer characteristics are not set
+to RESERVED, which is the default 0 value. This causes the ff_test_fmt
+function to fail which in turn causes the avvideocompare element to fail.
+
+The implementation is copied from gst_ffmpeg_videoinfo_to_context, but
+the color range has been adopted to also map the unknown range to
+unspecified, similar to how gst_ffmpeg_videoinfo_to_context maps
+AVCOL_RANGE_UNSPECIFIED to GST_VIDEO_COLOR_RANGE_UNKNOWN.
+
+This was tested with FFmpeg 8.0 and the following sample pipeline:
+
+  gst-launch-1.0 videotestsrc num-buffers=100          \
+    ! video/x-raw,format=NV12                          \
+    ! videobalance brightness=0.005 hue=0.005          \
+    ! avvideocompare method=psnr stats-file=- name=cmp \
+    ! fakesink videotestsrc ! video/x-raw,format=NV12  \
+    ! cmp.
+
+Without the patch it doesn't generate any stats output and when called
+with GST_DEBUG=3 it shows the following errors for each frame:
+
+  Unsupported input (Operation not supported):
+  fmt:nv12 csp:gbr prim:reserved trc:reserved -> fmt:yuv420p csp:unknown prim:reserved trc:reserved
+
+[1] https://github.com/FFmpeg/FFmpeg/commit/04ce01df0bb2d66e143bcfcea439afc2a1b8d96e
+
+Upstream-Status: Submitted [https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/10090]
+Signed-off-by: Sven Püschel <s.pueschel@pengutronix.de>
+---
+ ext/libav/gstavvidcmp.c | 19 +++++++++++++++++++
+ 1 file changed, 19 insertions(+)
+
+diff --git a/ext/libav/gstavvidcmp.c b/ext/libav/gstavvidcmp.c
+index 9fab0238935e..a5375e081a48 100644
+--- a/ext/libav/gstavvidcmp.c
++++ b/ext/libav/gstavvidcmp.c
+@@ -619,6 +619,25 @@ _fill_avpicture (GstFFMpegVidCmp * self, AVFrame * picture,
+   picture->width = GST_VIDEO_FRAME_WIDTH (vframe);
+   picture->height = GST_VIDEO_FRAME_HEIGHT (vframe);
+   picture->format = self->pixfmt;
++
++  picture->color_primaries =
++      gst_video_color_primaries_to_iso (vframe->info.colorimetry.primaries);
++  picture->color_trc =
++      gst_video_transfer_function_to_iso (vframe->info.colorimetry.transfer);
++  picture->colorspace =
++      gst_video_color_matrix_to_iso (vframe->info.colorimetry.matrix);
++
++  switch (vframe->info.colorimetry.range) {
++    case GST_VIDEO_COLOR_RANGE_0_255:
++      picture->color_range = AVCOL_RANGE_JPEG;
++      break;
++    case GST_VIDEO_COLOR_RANGE_16_235:
++      picture->color_range = AVCOL_RANGE_MPEG;
++      break;
++    case GST_VIDEO_COLOR_RANGE_UNKNOWN:
++      picture->color_range = AVCOL_RANGE_UNSPECIFIED;
++      break;
++  }
+ }
+ 
+ static GstFlowReturn
diff --git a/patches/gst-libav-1.26.0/series b/patches/gst-libav-1.26.0/series
new file mode 100644
index 000000000..93a96c141
--- /dev/null
+++ b/patches/gst-libav-1.26.0/series
@@ -0,0 +1,4 @@
+# generated by git-ptx-patches
+#tag:base --start-number 1
+0001-gst-libav-avvidcmp-set-colorimetry-on-AVFrame.patch
+# 4a2c6890c0534fedb7f6c1a8e71acbd7  - git-ptx-patches magic
-- 
2.47.3




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

* Re: [ptxdist] [PATCH 2/2] gst-libav1: fix avvideocompare element
  2025-11-14 14:20 ` [ptxdist] [PATCH 2/2] gst-libav1: fix avvideocompare element Sven Püschel
@ 2025-11-27 10:51   ` Michael Olbrich
  2025-11-27 11:10     ` Michael Olbrich
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Olbrich @ 2025-11-27 10:51 UTC (permalink / raw)
  To: Sven Püschel; +Cc: ptxdist

On Fri, Nov 14, 2025 at 03:20:22PM +0100, Sven Püschel wrote:
> With the update to FFmpeg 8.0 the avvideocompare element from GStreamer
> doesn't emit statistics anymore. Add a patch to fix the underlying
> issue of missing colorimetry information.
> 
> Fixes: 254f9c65f4dd ("ffmpeg: version bump 7.1.1 -> 8.0")
> Signed-off-by: Sven Püschel <s.pueschel@pengutronix.de>
> ---
>  ...-avvidcmp-set-colorimetry-on-AVFrame.patch | 75 +++++++++++++++++++
>  patches/gst-libav-1.26.0/series               |  4 +
>  2 files changed, 79 insertions(+)
>  create mode 100644 patches/gst-libav-1.26.0/0001-gst-libav-avvidcmp-set-colorimetry-on-AVFrame.patch
>  create mode 100644 patches/gst-libav-1.26.0/series

The current version in ptxdist 1.26.7 and I have a pending update to
1.26.8.

Michael

> 
> diff --git a/patches/gst-libav-1.26.0/0001-gst-libav-avvidcmp-set-colorimetry-on-AVFrame.patch b/patches/gst-libav-1.26.0/0001-gst-libav-avvidcmp-set-colorimetry-on-AVFrame.patch
> new file mode 100644
> index 000000000..1a499537d
> --- /dev/null
> +++ b/patches/gst-libav-1.26.0/0001-gst-libav-avvidcmp-set-colorimetry-on-AVFrame.patch
> @@ -0,0 +1,75 @@
> +From: =?UTF-8?q?Sven=20P=C3=BCschel?= <s.pueschel@pengutronix.de>
> +Date: Fri, 14 Nov 2025 10:50:51 +0100
> +Subject: [PATCH] gst-libav: avvidcmp: set colorimetry on AVFrame
> +MIME-Version: 1.0
> +Content-Type: text/plain; charset=UTF-8
> +Content-Transfer-Encoding: 8bit
> +
> +Set the colorimetry on AVFrame based on the GstVideoFrame values.
> +This properly maps potential colorimetry information to libav.
> +
> +Furthermore this fixes the avvideocompare element when used with
> +FFmpeg 8.0. When comparing video frames FFmpeg also uses the scale
> +filter. This has been reworked to use a new API [1], which checks
> +that the color primaries and transfer characteristics are not set
> +to RESERVED, which is the default 0 value. This causes the ff_test_fmt
> +function to fail which in turn causes the avvideocompare element to fail.
> +
> +The implementation is copied from gst_ffmpeg_videoinfo_to_context, but
> +the color range has been adopted to also map the unknown range to
> +unspecified, similar to how gst_ffmpeg_videoinfo_to_context maps
> +AVCOL_RANGE_UNSPECIFIED to GST_VIDEO_COLOR_RANGE_UNKNOWN.
> +
> +This was tested with FFmpeg 8.0 and the following sample pipeline:
> +
> +  gst-launch-1.0 videotestsrc num-buffers=100          \
> +    ! video/x-raw,format=NV12                          \
> +    ! videobalance brightness=0.005 hue=0.005          \
> +    ! avvideocompare method=psnr stats-file=- name=cmp \
> +    ! fakesink videotestsrc ! video/x-raw,format=NV12  \
> +    ! cmp.
> +
> +Without the patch it doesn't generate any stats output and when called
> +with GST_DEBUG=3 it shows the following errors for each frame:
> +
> +  Unsupported input (Operation not supported):
> +  fmt:nv12 csp:gbr prim:reserved trc:reserved -> fmt:yuv420p csp:unknown prim:reserved trc:reserved
> +
> +[1] https://github.com/FFmpeg/FFmpeg/commit/04ce01df0bb2d66e143bcfcea439afc2a1b8d96e
> +
> +Upstream-Status: Submitted [https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/10090]
> +Signed-off-by: Sven Püschel <s.pueschel@pengutronix.de>
> +---
> + ext/libav/gstavvidcmp.c | 19 +++++++++++++++++++
> + 1 file changed, 19 insertions(+)
> +
> +diff --git a/ext/libav/gstavvidcmp.c b/ext/libav/gstavvidcmp.c
> +index 9fab0238935e..a5375e081a48 100644
> +--- a/ext/libav/gstavvidcmp.c
> ++++ b/ext/libav/gstavvidcmp.c
> +@@ -619,6 +619,25 @@ _fill_avpicture (GstFFMpegVidCmp * self, AVFrame * picture,
> +   picture->width = GST_VIDEO_FRAME_WIDTH (vframe);
> +   picture->height = GST_VIDEO_FRAME_HEIGHT (vframe);
> +   picture->format = self->pixfmt;
> ++
> ++  picture->color_primaries =
> ++      gst_video_color_primaries_to_iso (vframe->info.colorimetry.primaries);
> ++  picture->color_trc =
> ++      gst_video_transfer_function_to_iso (vframe->info.colorimetry.transfer);
> ++  picture->colorspace =
> ++      gst_video_color_matrix_to_iso (vframe->info.colorimetry.matrix);
> ++
> ++  switch (vframe->info.colorimetry.range) {
> ++    case GST_VIDEO_COLOR_RANGE_0_255:
> ++      picture->color_range = AVCOL_RANGE_JPEG;
> ++      break;
> ++    case GST_VIDEO_COLOR_RANGE_16_235:
> ++      picture->color_range = AVCOL_RANGE_MPEG;
> ++      break;
> ++    case GST_VIDEO_COLOR_RANGE_UNKNOWN:
> ++      picture->color_range = AVCOL_RANGE_UNSPECIFIED;
> ++      break;
> ++  }
> + }
> + 
> + static GstFlowReturn
> diff --git a/patches/gst-libav-1.26.0/series b/patches/gst-libav-1.26.0/series
> new file mode 100644
> index 000000000..93a96c141
> --- /dev/null
> +++ b/patches/gst-libav-1.26.0/series
> @@ -0,0 +1,4 @@
> +# generated by git-ptx-patches
> +#tag:base --start-number 1
> +0001-gst-libav-avvidcmp-set-colorimetry-on-AVFrame.patch
> +# 4a2c6890c0534fedb7f6c1a8e71acbd7  - git-ptx-patches magic
> -- 
> 2.47.3
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

* Re: [ptxdist] [PATCH 2/2] gst-libav1: fix avvideocompare element
  2025-11-27 10:51   ` Michael Olbrich
@ 2025-11-27 11:10     ` Michael Olbrich
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Olbrich @ 2025-11-27 11:10 UTC (permalink / raw)
  To: Sven Püschel; +Cc: ptxdist

On Thu, Nov 27, 2025 at 11:51:03AM +0100, Michael Olbrich wrote:
> On Fri, Nov 14, 2025 at 03:20:22PM +0100, Sven Püschel wrote:
> > With the update to FFmpeg 8.0 the avvideocompare element from GStreamer
> > doesn't emit statistics anymore. Add a patch to fix the underlying
> > issue of missing colorimetry information.
> > 
> > Fixes: 254f9c65f4dd ("ffmpeg: version bump 7.1.1 -> 8.0")
> > Signed-off-by: Sven Püschel <s.pueschel@pengutronix.de>
> > ---
> >  ...-avvidcmp-set-colorimetry-on-AVFrame.patch | 75 +++++++++++++++++++
> >  patches/gst-libav-1.26.0/series               |  4 +
> >  2 files changed, 79 insertions(+)
> >  create mode 100644 patches/gst-libav-1.26.0/0001-gst-libav-avvidcmp-set-colorimetry-on-AVFrame.patch
> >  create mode 100644 patches/gst-libav-1.26.0/series
> 
> The current version in ptxdist 1.26.7 and I have a pending update to
> 1.26.8.

Ignore this. I didn't see the v2 when I wrote this.

Michael

> > 
> > diff --git a/patches/gst-libav-1.26.0/0001-gst-libav-avvidcmp-set-colorimetry-on-AVFrame.patch b/patches/gst-libav-1.26.0/0001-gst-libav-avvidcmp-set-colorimetry-on-AVFrame.patch
> > new file mode 100644
> > index 000000000..1a499537d
> > --- /dev/null
> > +++ b/patches/gst-libav-1.26.0/0001-gst-libav-avvidcmp-set-colorimetry-on-AVFrame.patch
> > @@ -0,0 +1,75 @@
> > +From: =?UTF-8?q?Sven=20P=C3=BCschel?= <s.pueschel@pengutronix.de>
> > +Date: Fri, 14 Nov 2025 10:50:51 +0100
> > +Subject: [PATCH] gst-libav: avvidcmp: set colorimetry on AVFrame
> > +MIME-Version: 1.0
> > +Content-Type: text/plain; charset=UTF-8
> > +Content-Transfer-Encoding: 8bit
> > +
> > +Set the colorimetry on AVFrame based on the GstVideoFrame values.
> > +This properly maps potential colorimetry information to libav.
> > +
> > +Furthermore this fixes the avvideocompare element when used with
> > +FFmpeg 8.0. When comparing video frames FFmpeg also uses the scale
> > +filter. This has been reworked to use a new API [1], which checks
> > +that the color primaries and transfer characteristics are not set
> > +to RESERVED, which is the default 0 value. This causes the ff_test_fmt
> > +function to fail which in turn causes the avvideocompare element to fail.
> > +
> > +The implementation is copied from gst_ffmpeg_videoinfo_to_context, but
> > +the color range has been adopted to also map the unknown range to
> > +unspecified, similar to how gst_ffmpeg_videoinfo_to_context maps
> > +AVCOL_RANGE_UNSPECIFIED to GST_VIDEO_COLOR_RANGE_UNKNOWN.
> > +
> > +This was tested with FFmpeg 8.0 and the following sample pipeline:
> > +
> > +  gst-launch-1.0 videotestsrc num-buffers=100          \
> > +    ! video/x-raw,format=NV12                          \
> > +    ! videobalance brightness=0.005 hue=0.005          \
> > +    ! avvideocompare method=psnr stats-file=- name=cmp \
> > +    ! fakesink videotestsrc ! video/x-raw,format=NV12  \
> > +    ! cmp.
> > +
> > +Without the patch it doesn't generate any stats output and when called
> > +with GST_DEBUG=3 it shows the following errors for each frame:
> > +
> > +  Unsupported input (Operation not supported):
> > +  fmt:nv12 csp:gbr prim:reserved trc:reserved -> fmt:yuv420p csp:unknown prim:reserved trc:reserved
> > +
> > +[1] https://github.com/FFmpeg/FFmpeg/commit/04ce01df0bb2d66e143bcfcea439afc2a1b8d96e
> > +
> > +Upstream-Status: Submitted [https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/10090]
> > +Signed-off-by: Sven Püschel <s.pueschel@pengutronix.de>
> > +---
> > + ext/libav/gstavvidcmp.c | 19 +++++++++++++++++++
> > + 1 file changed, 19 insertions(+)
> > +
> > +diff --git a/ext/libav/gstavvidcmp.c b/ext/libav/gstavvidcmp.c
> > +index 9fab0238935e..a5375e081a48 100644
> > +--- a/ext/libav/gstavvidcmp.c
> > ++++ b/ext/libav/gstavvidcmp.c
> > +@@ -619,6 +619,25 @@ _fill_avpicture (GstFFMpegVidCmp * self, AVFrame * picture,
> > +   picture->width = GST_VIDEO_FRAME_WIDTH (vframe);
> > +   picture->height = GST_VIDEO_FRAME_HEIGHT (vframe);
> > +   picture->format = self->pixfmt;
> > ++
> > ++  picture->color_primaries =
> > ++      gst_video_color_primaries_to_iso (vframe->info.colorimetry.primaries);
> > ++  picture->color_trc =
> > ++      gst_video_transfer_function_to_iso (vframe->info.colorimetry.transfer);
> > ++  picture->colorspace =
> > ++      gst_video_color_matrix_to_iso (vframe->info.colorimetry.matrix);
> > ++
> > ++  switch (vframe->info.colorimetry.range) {
> > ++    case GST_VIDEO_COLOR_RANGE_0_255:
> > ++      picture->color_range = AVCOL_RANGE_JPEG;
> > ++      break;
> > ++    case GST_VIDEO_COLOR_RANGE_16_235:
> > ++      picture->color_range = AVCOL_RANGE_MPEG;
> > ++      break;
> > ++    case GST_VIDEO_COLOR_RANGE_UNKNOWN:
> > ++      picture->color_range = AVCOL_RANGE_UNSPECIFIED;
> > ++      break;
> > ++  }
> > + }
> > + 
> > + static GstFlowReturn
> > diff --git a/patches/gst-libav-1.26.0/series b/patches/gst-libav-1.26.0/series
> > new file mode 100644
> > index 000000000..93a96c141
> > --- /dev/null
> > +++ b/patches/gst-libav-1.26.0/series
> > @@ -0,0 +1,4 @@
> > +# generated by git-ptx-patches
> > +#tag:base --start-number 1
> > +0001-gst-libav-avvidcmp-set-colorimetry-on-AVFrame.patch
> > +# 4a2c6890c0534fedb7f6c1a8e71acbd7  - git-ptx-patches magic
> > -- 
> > 2.47.3
> > 
> > 
> > 
> 
> -- 
> Pengutronix e.K.                           |                             |
> Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
> 31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

end of thread, other threads:[~2025-11-27 11:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-14 14:20 [ptxdist] [PATCH 1/2] ffmpeg: enable filters and swscale Sven Püschel
2025-11-14 14:20 ` [ptxdist] [PATCH 2/2] gst-libav1: fix avvideocompare element Sven Püschel
2025-11-27 10:51   ` Michael Olbrich
2025-11-27 11:10     ` Michael Olbrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox