Re: [FFmpeg-devel] [PATCH v2 0/8] ddagrab source filter, lavfi.c wrapped_avframe and dependent changes

2022-07-20 Thread Mark Himsley
On Tue, 19 Jul 2022 at 13:20, Timo Rothenpieler  wrote:

> I added an explicit configure check for that type.
> Definitely odd, IDXGIOutput5 and it are both Windows 10 APIs, so I'd
> have expected them to always exist in tandem.

Thank you - that fixed the build for me.

> You might want to update or repair your weird Windows SDK.

I thought x86_64-w64-mingw32 was quite standard.

Anyway - thanks :-)

-- 
Mark Himsley
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH v11 00/13] make QSV works with the Intel's oneVPL

2022-07-20 Thread Xiang, Haihao
From: Haihao Xiang 

The oneAPI Video Processing Library (oneVPL) is a single interface for
encode, decode and video processing[1][2]. oneVPL is a successor to Intel(R) 
Media
SDK, but removed obsolete features. Intel(R) Media SDK lifetime comes to an
end now, new features for new Intel Gen platforms will be supported in oneVPL
only[3].

It is recommended to use oneVPL for new work, even for currently available
hardwares[4]. Hence, this patchset added a new option --enable-onevpl to bring
the support for oneVPL in QSV, new features for oneVPL will be implemented in
other patchset, for example, we are implementing av1_qsv encoder
(https://github.com/intel-media-ci/ffmpeg/pull/515).

option --enble-libmfx still works with Intel(R) Media SDK.

Note user can't enable onevpl and libmfx together.

oneVPL dispatcher:
https://github.com/oneapi-src/oneVPL

oneVPL GPU runtime for new Intel Gen platforms:
https://github.com/oneapi-src/oneVPL-intel-gpu

v11:
  - make sure the loaded oneVPL implementation can supported the requested
device in VAAPI path.

[1] https://spec.oneapi.io/versions/latest/elements/oneVPL/source/index.html
[2] https://www.intel.com/content/www/us/en/developer/tools/oneapi/onevpl.html
[3] https://github.com/Intel-Media-SDK/MediaSDK/#media-sdk-support-matrix
[4] 
https://www.intel.com/content/www/us/en/develop/documentation/upgrading-from-msdk-to-onevpl/top.html

Haihao Xiang (13):
  configure: ensure --enable-libmfx uses libmfx 1.x
  configure: fix the check for MFX_CODEC_VP9
  qsv: remove mfx/ prefix from mfx headers
  qsv: load user plugin for MFX_VERSION < 2.0
  qsv: build audio related code when MFX_VERSION < 2.0
  qsvenc: support multi-frame encode when MFX_VERSION < 2.0
  qsvenc: support MFX_RATECONTROL_LA_EXT when MFX_VERSION < 2.0
  qsv: support OPAQUE memory when MFX_VERSION < 2.0
  lavu/hwcontext_qsv: add loader field to AVQSVDeviceContext
  lavu/hwcontext_qsv: make qsv hwdevice works with oneVPL
  lavc/qsv: create mfx session using oneVPL for decoding/encoding
  lavfi/qsv: create mfx session using oneVPL for qsv filters
  configure: add --enable-libvpl option

 configure|  32 +-
 doc/APIchanges   |   3 +
 libavcodec/qsv.c | 249 +++--
 libavcodec/qsv.h |   4 +-
 libavcodec/qsv_internal.h|   6 +-
 libavcodec/qsvdec.c  |  22 +-
 libavcodec/qsvenc.c  |  25 +-
 libavcodec/qsvenc.h  |   9 +-
 libavcodec/qsvenc_h264.c |   3 +-
 libavcodec/qsvenc_hevc.c |   3 +-
 libavcodec/qsvenc_jpeg.c |   3 +-
 libavcodec/qsvenc_mpeg2.c|   3 +-
 libavcodec/qsvenc_vp9.c  |   3 +-
 libavfilter/qsvvpp.c | 141 +++-
 libavfilter/qsvvpp.h |  12 +-
 libavfilter/vf_deinterlace_qsv.c |  72 ++--
 libavfilter/vf_scale_qsv.c   |  87 ++---
 libavutil/hwcontext_opencl.c |   2 +-
 libavutil/hwcontext_qsv.c| 589 ---
 libavutil/hwcontext_qsv.h|  13 +-
 libavutil/version.h  |   2 +-
 21 files changed, 1098 insertions(+), 185 deletions(-)

-- 
2.17.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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v11 01/13] configure: ensure --enable-libmfx uses libmfx 1.x

2022-07-20 Thread Xiang, Haihao
From: Haihao Xiang 

Intel's oneVPL is a successor to MediaSDK, but removed some obsolete
features of MediaSDK[1], some early versions of oneVPL still use libmfx
as library name[2]. However some of obsolete features, including OPAQUE
memory, multi-frame encode, user plugins and LA_EXT rate control mode
etc, have been enabled in QSV, so user can not use --enable-libmfx to
enable QSV if using an early version of oneVPL SDK. In order to ensure
user builds FFmpeg against a right version of libmfx, this patch added a
check for version < 2.0 and warning message about the used obsolete
features.

[1] 
https://spec.oneapi.io/versions/latest/elements/oneVPL/source/VPL_intel_media_sdk.html
[2] https://github.com/oneapi-src/oneVPL
---
 configure | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index 4888792015..98cbd7a4db 100755
--- a/configure
+++ b/configure
@@ -6580,10 +6580,12 @@ enabled liblensfun&& require_pkg_config 
liblensfun lensfun lensfun.h lf_
 # Media SDK or Intel Media Server Studio, these don't come with
 # pkg-config support.  Instead, users should make sure that the build
 # can find the libraries and headers through other means.
-enabled libmfx&& { check_pkg_config libmfx "libmfx >= 1.28" 
"mfx/mfxvideo.h" MFXInit ||
-   { require libmfx "mfx/mfxvideo.h mfx/mfxdefs.h" 
MFXInit "-llibmfx $advapi32_extralibs" &&
- { test_cpp_condition mfx/mfxdefs.h 
"MFX_VERSION >= 1028" || die "ERROR: libmfx version must be >= 1.28"; }  &&
- warn "using libmfx without pkg-config"; } }
+enabled libmfx&& { { check_pkg_config libmfx "libmfx >= 1.28 
libmfx < 2.0" "mfx/mfxvideo.h" MFXInit ||
+ { require libmfx "mfx/mfxvideo.h 
mfx/mfxdefs.h" MFXInit "-llibmfx $advapi32_extralibs" &&
+   { test_cpp_condition mfx/mfxdefs.h 
"MFX_VERSION >= 1028 && MFX_VERSION < 2000" || die "ERROR: libmfx version must 
be >= 1.28 and < 2.0"; }  &&
+   warn "using libmfx without pkg-config"; } } 
&&
+ warn "build FFmpeg against libmfx 1.x, 
obsolete features of libmfx such as OPAQUE memory,\n"\
+   "multi-frame encode, user plugins and 
LA_EXT rate control mode are enabled"; }
 
 if enabled libmfx; then
check_cc MFX_CODEC_VP9 "mfx/mfxvp9.h mfx/mfxstructures.h" "MFX_CODEC_VP9"
-- 
2.17.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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v11 02/13] configure: fix the check for MFX_CODEC_VP9

2022-07-20 Thread Xiang, Haihao
From: Haihao Xiang 

The data structures for VP9 in mfxvp9.h is wrapped by
MFX_VERSION_NEXT, which means those data structures have never been used
in a public release. Actually MFX_CODEC_VP9 and other VP9 stuffs is
added in mfxstructures.h. In addition, mfxdefs.h is included in
mfxvp9.h, so we may use the check in this patch for MFX_CODEC_VP9

This is in preparation for oneVPL support because mfxvp9.h is removed
from oneVPL [1]

[1]: https://github.com/oneapi-src/oneVPL
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 98cbd7a4db..3b9aa44a95 100755
--- a/configure
+++ b/configure
@@ -6588,7 +6588,7 @@ enabled libmfx&& { { check_pkg_config libmfx 
"libmfx >= 1.28 libmfx
"multi-frame encode, user plugins and 
LA_EXT rate control mode are enabled"; }
 
 if enabled libmfx; then
-   check_cc MFX_CODEC_VP9 "mfx/mfxvp9.h mfx/mfxstructures.h" "MFX_CODEC_VP9"
+   check_cc MFX_CODEC_VP9 "mfx/mfxdefs.h mfx/mfxstructures.h" "MFX_CODEC_VP9"
 fi
 
 enabled libmodplug&& require_pkg_config libmodplug libmodplug 
libmodplug/modplug.h ModPlug_Load
-- 
2.17.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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v11 03/13] qsv: remove mfx/ prefix from mfx headers

2022-07-20 Thread Xiang, Haihao
From: Haihao Xiang 

The following Cflags has been added to libmfx.pc, so mfx/ prefix is no
longer needed when including mfx headers in FFmpeg.
   Cflags: -I${includedir} -I${includedir}/mfx

Some old versions of libmfx have the following Cflags in libmfx.pc
   Cflags: -I${includedir}

We may add -I${includedir}/mfx to CFLAGS when running 'configure
--enable-libmfx' for old versions of libmfx, if so, mfx headers without
mfx/ prefix can be included too.

If libmfx comes without pkg-config support, we may do a small change to
the settings of the environment(e.g. set -I/opt/intel/mediasdk/include/mfx
instead of -I/opt/intel/mediasdk/include to CFLAGS), then the build can
find the mfx headers without mfx/ prefix

After applying this change, we won't need to change #include for mfx
headers when mfx headers are installed under a new directory.

This is in preparation for oneVPL support (mfx headers in oneVPL are
installed under vpl directory)
---
 configure| 19 ---
 libavcodec/qsv.c |  8 
 libavcodec/qsv.h |  2 +-
 libavcodec/qsv_internal.h|  2 +-
 libavcodec/qsvdec.c  |  2 +-
 libavcodec/qsvenc.c  |  2 +-
 libavcodec/qsvenc.h  |  2 +-
 libavcodec/qsvenc_h264.c |  2 +-
 libavcodec/qsvenc_hevc.c |  2 +-
 libavcodec/qsvenc_jpeg.c |  2 +-
 libavcodec/qsvenc_mpeg2.c|  2 +-
 libavcodec/qsvenc_vp9.c  |  2 +-
 libavfilter/qsvvpp.h |  2 +-
 libavfilter/vf_deinterlace_qsv.c |  2 +-
 libavfilter/vf_scale_qsv.c   |  2 +-
 libavutil/hwcontext_opencl.c |  2 +-
 libavutil/hwcontext_qsv.c|  2 +-
 libavutil/hwcontext_qsv.h|  2 +-
 18 files changed, 32 insertions(+), 27 deletions(-)

diff --git a/configure b/configure
index 3b9aa44a95..23ae3eaf7e 100755
--- a/configure
+++ b/configure
@@ -6580,15 +6580,20 @@ enabled liblensfun&& require_pkg_config 
liblensfun lensfun lensfun.h lf_
 # Media SDK or Intel Media Server Studio, these don't come with
 # pkg-config support.  Instead, users should make sure that the build
 # can find the libraries and headers through other means.
-enabled libmfx&& { { check_pkg_config libmfx "libmfx >= 1.28 
libmfx < 2.0" "mfx/mfxvideo.h" MFXInit ||
- { require libmfx "mfx/mfxvideo.h 
mfx/mfxdefs.h" MFXInit "-llibmfx $advapi32_extralibs" &&
-   { test_cpp_condition mfx/mfxdefs.h 
"MFX_VERSION >= 1028 && MFX_VERSION < 2000" || die "ERROR: libmfx version must 
be >= 1.28 and < 2.0"; }  &&
-   warn "using libmfx without pkg-config"; } } 
&&
- warn "build FFmpeg against libmfx 1.x, 
obsolete features of libmfx such as OPAQUE memory,\n"\
-   "multi-frame encode, user plugins and 
LA_EXT rate control mode are enabled"; }
+enabled libmfx&& { { check_pkg_config libmfx "libmfx >= 1.28 
libmfx < 2.0" "mfxvideo.h" MFXInit ||
+# Some old versions of libmfx have the following settings in libmfx.pc:
+#   includedir=/usr/include
+#   Cflags: -I${includedir}
+# So add -I${includedir}/mfx to CFLAGS
+ { check_pkg_config libmfx "libmfx >= 1.28 
libmfx < 2.0" "mfx/mfxvideo.h" MFXInit && add_cflags -I${libmfx_incdir}/mfx; } 
||
+ { require libmfx "mfxvideo.h mfxdefs.h" 
MFXInit "-llibmfx $advapi32_extralibs" &&
+   { test_cpp_condition mfxdefs.h "MFX_VERSION 
>= 1028 && MFX_VERSION < 2000" || die "ERROR: libmfx version must be >= 1.28 
and < 2.0"; }  &&
+ warn "using libmfx without pkg-config"; } 
} &&
+   warn "build FFmpeg against libmfx 1.x, obsolete 
features of libmfx such as OPAQUE memory,\n"\
+"multi-frame encode, user plugins and 
LA_EXT rate control mode are enabled"; }
 
 if enabled libmfx; then
-   check_cc MFX_CODEC_VP9 "mfx/mfxdefs.h mfx/mfxstructures.h" "MFX_CODEC_VP9"
+   check_cc MFX_CODEC_VP9 "mfxdefs.h mfxstructures.h" "MFX_CODEC_VP9"
 fi
 
 enabled libmodplug&& require_pkg_config libmodplug libmodplug 
libmodplug/modplug.h ModPlug_Load
diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 385b43bb6c..25331ccce8 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -18,9 +18,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include 
-#include 
-#include 
+#include 
+#include 
+#include 
 
 #include 
 #include 
@@ -38,7 +38,7 @@
 
 #define MFX_IMPL_VIA_MASK(impl) (0x0f00 & (impl))
 
-#include "mfx/mfxvp8.h"
+#include "mfxvp8.h"
 
 int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id)
 {
diff --git a/libavcodec/qsv.h b/libavcodec/qsv.h
index b77158ec26..04ae0d6f34 100644
--- a/libavcodec/qsv.h
+++ b/libavcodec/qsv.h
@@ -21,7 +21,7 @@
 #ifndef AVCODEC_QSV_H
 #define AVCODEC_QSV_H

[FFmpeg-devel] [PATCH v11 04/13] qsv: load user plugin for MFX_VERSION < 2.0

2022-07-20 Thread Xiang, Haihao
From: Haihao Xiang 

User plugin isn't supported for MFX_VERSION >= 2.0[1][2]. This is in
preparation for oneVPL Support

[1] 
https://spec.oneapi.io/versions/latest/elements/oneVPL/source/VPL_intel_media_sdk.html#msdk-full-name-feature-removals
[2] https://github.com/oneapi-src/oneVPL
---
 libavcodec/qsv.c  | 8 +++-
 libavcodec/qsv_internal.h | 2 ++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 25331ccce8..74fc8ff18e 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -19,7 +19,6 @@
  */
 
 #include 
-#include 
 #include 
 
 #include 
@@ -37,9 +36,14 @@
 #include "qsv_internal.h"
 
 #define MFX_IMPL_VIA_MASK(impl) (0x0f00 & (impl))
+#define QSV_HAVE_USER_PLUGIN!QSV_ONEVPL
 
 #include "mfxvp8.h"
 
+#if QSV_HAVE_USER_PLUGIN
+#include 
+#endif
+
 int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id)
 {
 switch (codec_id) {
@@ -323,6 +327,7 @@ enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type)
 static int qsv_load_plugins(mfxSession session, const char *load_plugins,
 void *logctx)
 {
+#if QSV_HAVE_USER_PLUGIN
 if (!load_plugins || !*load_plugins)
 return 0;
 
@@ -366,6 +371,7 @@ load_plugin_fail:
 if (err < 0)
 return err;
 }
+#endif
 
 return 0;
 
diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index cb1e55ae30..949955bda0 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -65,6 +65,8 @@
 ((MFX_VERSION.Major > (MAJOR)) ||   \
 (MFX_VERSION.Major == (MAJOR) && MFX_VERSION.Minor >= (MINOR)))
 
+#define QSV_ONEVPL   QSV_VERSION_ATLEAST(2, 0)
+
 typedef struct QSVMid {
 AVBufferRef *hw_frames_ref;
 mfxHDLPair *handle_pair;
-- 
2.17.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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v11 05/13] qsv: build audio related code when MFX_VERSION < 2.0

2022-07-20 Thread Xiang, Haihao
From: Haihao Xiang 

Audio isn't supported for MFX_VERSION >= 2.0[1][2]. This is in
preparation for oneVPL support

[1] 
https://spec.oneapi.io/versions/latest/elements/oneVPL/source/VPL_intel_media_sdk.html#msdk-full-name-feature-removals
[2] https://github.com/oneapi-src/oneVPL
---
 libavcodec/qsv.c | 5 +
 libavfilter/qsvvpp.c | 6 ++
 libavfilter/qsvvpp.h | 2 ++
 3 files changed, 13 insertions(+)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 74fc8ff18e..cc4b6cfd5d 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -37,6 +37,7 @@
 
 #define MFX_IMPL_VIA_MASK(impl) (0x0f00 & (impl))
 #define QSV_HAVE_USER_PLUGIN!QSV_ONEVPL
+#define QSV_HAVE_AUDIO  !QSV_ONEVPL
 
 #include "mfxvp8.h"
 
@@ -129,8 +130,10 @@ static const struct {
 { MFX_ERR_INVALID_VIDEO_PARAM,  AVERROR(EINVAL), "invalid video 
parameters" },
 { MFX_ERR_UNDEFINED_BEHAVIOR,   AVERROR_BUG, "undefined behavior"  
 },
 { MFX_ERR_DEVICE_FAILED,AVERROR(EIO),"device failed"   
 },
+#if QSV_HAVE_AUDIO
 { MFX_ERR_INCOMPATIBLE_AUDIO_PARAM, AVERROR(EINVAL), "incompatible audio 
parameters"},
 { MFX_ERR_INVALID_AUDIO_PARAM,  AVERROR(EINVAL), "invalid audio 
parameters" },
+#endif
 
 { MFX_WRN_IN_EXECUTION, 0,   "operation in 
execution"   },
 { MFX_WRN_DEVICE_BUSY,  0,   "device busy" 
 },
@@ -140,7 +143,9 @@ static const struct {
 { MFX_WRN_VALUE_NOT_CHANGED,0,   "value is saturated"  
 },
 { MFX_WRN_OUT_OF_RANGE, 0,   "value out of range"  
 },
 { MFX_WRN_FILTER_SKIPPED,   0,   "filter skipped"  
 },
+#if QSV_HAVE_AUDIO
 { MFX_WRN_INCOMPATIBLE_AUDIO_PARAM, 0,   "incompatible audio 
parameters"},
+#endif
 };
 
 /**
diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index 954f882637..3647891d13 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -38,6 +38,8 @@
 #define IS_SYSTEM_MEMORY(mode) (mode & MFX_MEMTYPE_SYSTEM_MEMORY)
 #define MFX_IMPL_VIA_MASK(impl) (0x0f00 & (impl))
 
+#define QSV_HAVE_AUDIO !QSV_ONEVPL
+
 static const AVRational default_tb = { 1, 9 };
 
 typedef struct QSVAsyncFrame {
@@ -100,8 +102,10 @@ static const struct {
 { MFX_ERR_INVALID_VIDEO_PARAM,  AVERROR(EINVAL), "invalid video 
parameters" },
 { MFX_ERR_UNDEFINED_BEHAVIOR,   AVERROR_BUG, "undefined behavior"  
 },
 { MFX_ERR_DEVICE_FAILED,AVERROR(EIO),"device failed"   
 },
+#if QSV_HAVE_AUDIO
 { MFX_ERR_INCOMPATIBLE_AUDIO_PARAM, AVERROR(EINVAL), "incompatible audio 
parameters"},
 { MFX_ERR_INVALID_AUDIO_PARAM,  AVERROR(EINVAL), "invalid audio 
parameters" },
+#endif
 
 { MFX_WRN_IN_EXECUTION, 0,   "operation in 
execution"   },
 { MFX_WRN_DEVICE_BUSY,  0,   "device busy" 
 },
@@ -111,7 +115,9 @@ static const struct {
 { MFX_WRN_VALUE_NOT_CHANGED,0,   "value is saturated"  
 },
 { MFX_WRN_OUT_OF_RANGE, 0,   "value out of range"  
 },
 { MFX_WRN_FILTER_SKIPPED,   0,   "filter skipped"  
 },
+#if QSV_HAVE_AUDIO
 { MFX_WRN_INCOMPATIBLE_AUDIO_PARAM, 0,   "incompatible audio 
parameters"},
+#endif
 };
 
 static int qsv_map_error(mfxStatus mfx_err, const char **desc)
diff --git a/libavfilter/qsvvpp.h b/libavfilter/qsvvpp.h
index 543c58a967..802abd987d 100644
--- a/libavfilter/qsvvpp.h
+++ b/libavfilter/qsvvpp.h
@@ -40,6 +40,8 @@
 ((MFX_VERSION.Major > (MAJOR)) ||   \
 (MFX_VERSION.Major == (MAJOR) && MFX_VERSION.Minor >= (MINOR)))
 
+#define QSV_ONEVPL   QSV_VERSION_ATLEAST(2, 0)
+
 typedef struct QSVFrame {
 AVFrame  *frame;
 mfxFrameSurface1 surface;
-- 
2.17.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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v11 08/13] qsv: support OPAQUE memory when MFX_VERSION < 2.0

2022-07-20 Thread Xiang, Haihao
From: Haihao Xiang 

OPAQUE memory isn't supported for MFX_VERSION >= 2.0[1][2]. This is in
preparation for oneVPL support

[1] 
https://spec.oneapi.io/versions/latest/elements/oneVPL/source/VPL_intel_media_sdk.html#msdk-full-name-feature-removals
[2] https://github.com/oneapi-src/oneVPL
---
 libavcodec/qsv.c |  4 ++
 libavcodec/qsv.h |  2 +
 libavcodec/qsv_internal.h|  1 +
 libavcodec/qsvdec.c  |  9 
 libavcodec/qsvenc.c  | 21 +
 libavcodec/qsvenc.h  |  2 +
 libavfilter/qsvvpp.c | 26 ++-
 libavfilter/qsvvpp.h |  3 ++
 libavfilter/vf_deinterlace_qsv.c | 57 +---
 libavfilter/vf_scale_qsv.c   | 74 ++--
 libavutil/hwcontext_qsv.c| 56 +---
 11 files changed, 181 insertions(+), 74 deletions(-)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index cc4b6cfd5d..432675bccf 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -81,10 +81,14 @@ static const struct {
 } qsv_iopatterns[] = {
 {MFX_IOPATTERN_IN_VIDEO_MEMORY, "input is video memory surface"
 },
 {MFX_IOPATTERN_IN_SYSTEM_MEMORY,"input is system memory surface"   
 },
+#if QSV_HAVE_OPAQUE
 {MFX_IOPATTERN_IN_OPAQUE_MEMORY,"input is opaque memory surface"   
 },
+#endif
 {MFX_IOPATTERN_OUT_VIDEO_MEMORY,"output is video memory surface"   
 },
 {MFX_IOPATTERN_OUT_SYSTEM_MEMORY,   "output is system memory surface"  
 },
+#if QSV_HAVE_OPAQUE
 {MFX_IOPATTERN_OUT_OPAQUE_MEMORY,   "output is opaque memory surface"  
 },
+#endif
 };
 
 int ff_qsv_print_iopattern(void *log_ctx, int mfx_iopattern,
diff --git a/libavcodec/qsv.h b/libavcodec/qsv.h
index 04ae0d6f34..c156b08d07 100644
--- a/libavcodec/qsv.h
+++ b/libavcodec/qsv.h
@@ -61,6 +61,8 @@ typedef struct AVQSVContext {
  * required by the encoder and the user-provided value nb_opaque_surfaces.
  * The array of the opaque surfaces will be exported to the caller through
  * the opaque_surfaces field.
+ *
+ * The caller must set this field to zero for oneVPL (MFX_VERSION >= 2.0)
  */
 int opaque_alloc;
 
diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index 949955bda0..d52f0dcd15 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -66,6 +66,7 @@
 (MFX_VERSION.Major == (MAJOR) && MFX_VERSION.Minor >= (MINOR)))
 
 #define QSV_ONEVPL   QSV_VERSION_ATLEAST(2, 0)
+#define QSV_HAVE_OPAQUE  !QSV_ONEVPL
 
 typedef struct QSVMid {
 AVBufferRef *hw_frames_ref;
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index edbe7bcdee..8b718a08ff 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -187,7 +187,11 @@ static int qsv_init_session(AVCodecContext *avctx, 
QSVContext *q, mfxSession ses
 
 ret = ff_qsv_init_session_frames(avctx, &q->internal_qs.session,
  &q->frames_ctx, q->load_plugins,
+#if QSV_HAVE_OPAQUE
  q->iopattern == 
MFX_IOPATTERN_OUT_OPAQUE_MEMORY,
+#else
+ 0,
+#endif
  q->gpu_copy);
 if (ret < 0) {
 av_buffer_unref(&q->frames_ctx.hw_frames_ctx);
@@ -300,10 +304,15 @@ static int qsv_decode_preinit(AVCodecContext *avctx, 
QSVContext *q, enum AVPixel
 AVQSVFramesContext *frames_hwctx = frames_ctx->hwctx;
 
 if (!iopattern) {
+#if QSV_HAVE_OPAQUE
 if (frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME)
 iopattern = MFX_IOPATTERN_OUT_OPAQUE_MEMORY;
 else if (frames_hwctx->frame_type & 
MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET)
 iopattern = MFX_IOPATTERN_OUT_VIDEO_MEMORY;
+#else
+if (frames_hwctx->frame_type & 
MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET)
+iopattern = MFX_IOPATTERN_OUT_VIDEO_MEMORY;
+#endif
 }
 }
 
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index d3a9a2118e..4831640868 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -1176,6 +1176,7 @@ static int qsv_retrieve_enc_params(AVCodecContext *avctx, 
QSVEncContext *q)
 return 0;
 }
 
+#if QSV_HAVE_OPAQUE
 static int qsv_init_opaque_alloc(AVCodecContext *avctx, QSVEncContext *q)
 {
 AVQSVContext *qsv = avctx->hwaccel_context;
@@ -1212,6 +1213,7 @@ static int qsv_init_opaque_alloc(AVCodecContext *avctx, 
QSVEncContext *q)
 
 return 0;
 }
+#endif
 
 static int qsvenc_init_session(AVCodecContext *avctx, QSVEncContext *q)
 {
@@ -1227,7 +1229,11 @@ static int qsvenc_init_session(AVCodecContext *avctx, 
QSVEncContext *q)
 
 ret = ff_qsv_init_session_frames(avctx, &q->internal_qs.session,
  &q->frames_ctx, q->load_plugins,
+#if QSV_HAVE_OPAQUE
  q->param.IOPattern == 
MFX_IOPATTERN_IN_OPAQUE_MEM

[FFmpeg-devel] [PATCH v11 06/13] qsvenc: support multi-frame encode when MFX_VERSION < 2.0

2022-07-20 Thread Xiang, Haihao
From: Haihao Xiang 

Multi-frame encode isn't supported for MFX_VERSION >= 2.0[1][2]. This is
in preparation for oneVPL support

[1] 
https://spec.oneapi.io/versions/latest/elements/oneVPL/source/VPL_intel_media_sdk.html#msdk-full-name-feature-removals
[2] https://github.com/oneapi-src/oneVPL
---
 libavcodec/qsvenc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index 4cadc38a59..40e2f65eff 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -44,7 +44,7 @@
 #else
 #define QSV_HAVE_AVBR   0
 #define QSV_HAVE_VCM0
-#define QSV_HAVE_MF 1
+#define QSV_HAVE_MF !QSV_ONEVPL
 #endif
 
 #define QSV_COMMON_OPTS \
-- 
2.17.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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v11 09/13] lavu/hwcontext_qsv: add loader field to AVQSVDeviceContext

2022-07-20 Thread Xiang, Haihao
From: Haihao Xiang 

In oneVPL, a valid mfxLoader handle is needed when creating mfx session
for decoding, encoding and processing[1], so add loader field to
AVQSVDeviceContext. User should fill this field before calling
av_hwdevice_ctx_init() if using oneVPL

This is in preparation for oneVPL support

[1]https://spec.oneapi.io/versions/latest/elements/oneVPL/source/programming_guide/VPL_prg_session.html#onevpl-dispatcher
---
 doc/APIchanges|  3 +++
 libavutil/hwcontext_qsv.h | 11 +++
 libavutil/version.h   |  2 +-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index b3563cd528..265361c979 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,9 @@ libavutil: 2021-04-27
 
 API changes, most recent first:
 
+2022-07-xx - xx - lavu 57.31.100 - hwcontext_qsv.h
+  Add loader field to AVQSVDeviceContext
+
 2022-07-xx - xx - lavu 57.30.100 - frame.h
   Add AVFrame.duration, deprecate AVFrame.pkt_duration.
 
diff --git a/libavutil/hwcontext_qsv.h b/libavutil/hwcontext_qsv.h
index 42e34d0dda..e2dba8ad83 100644
--- a/libavutil/hwcontext_qsv.h
+++ b/libavutil/hwcontext_qsv.h
@@ -34,6 +34,17 @@
  */
 typedef struct AVQSVDeviceContext {
 mfxSession session;
+/**
+ * The mfxLoader handle used for mfxSession creation
+ *
+ * This field is only available for oneVPL user. For non-oneVPL user, this
+ * field must be set to NULL.
+ *
+ * Filled by the user before calling av_hwdevice_ctx_init() and should be
+ * cast to mfxLoader handle. Deallocating the AVHWDeviceContext will always
+ * release this interface.
+ */
+void *loader;
 } AVQSVDeviceContext;
 
 /**
diff --git a/libavutil/version.h b/libavutil/version.h
index ee4c531b80..e9eefcdb2c 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  57
-#define LIBAVUTIL_VERSION_MINOR  30
+#define LIBAVUTIL_VERSION_MINOR  31
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
-- 
2.17.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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v11 10/13] lavu/hwcontext_qsv: make qsv hwdevice works with oneVPL

2022-07-20 Thread Xiang, Haihao
From: Haihao Xiang 

In oneVPL, MFXLoad() and MFXCreateSession() are required to create a
workable mfx session[1]

Add config filters for D3D9/D3D11 session (galinart)

The default device is changed to d3d11va for oneVPL when both d3d11va
and dxva2 are enabled on Microsoft Windows

This is in preparation for oneVPL support

[1] 
https://spec.oneapi.io/versions/latest/elements/oneVPL/source/programming_guide/VPL_prg_session.html#onevpl-dispatcher

Co-authored-by: galinart 
Signed-off-by: galinart 
Signed-off-by: Haihao Xiang 
---
 libavutil/hwcontext_qsv.c | 531 +++---
 1 file changed, 493 insertions(+), 38 deletions(-)

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 21a2a805f8..90b7988dec 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -49,6 +49,7 @@
 #include "pixdesc.h"
 #include "time.h"
 #include "imgutils.h"
+#include "avassert.h"
 
 #define QSV_VERSION_ATLEAST(MAJOR, MINOR)   \
 (MFX_VERSION_MAJOR > (MAJOR) || \
@@ -58,6 +59,12 @@
 #define QSV_ONEVPL   QSV_VERSION_ATLEAST(2, 0)
 #define QSV_HAVE_OPAQUE  !QSV_ONEVPL
 
+#if QSV_ONEVPL
+#include 
+#else
+#define MFXUnload(a) do { } while(0)
+#endif
+
 typedef struct QSVDevicePriv {
 AVBufferRef *child_device_ctx;
 } QSVDevicePriv;
@@ -619,6 +626,436 @@ static mfxStatus frame_get_hdl(mfxHDL pthis, mfxMemId 
mid, mfxHDL *hdl)
 return MFX_ERR_NONE;
 }
 
+#if QSV_ONEVPL
+
+static int qsv_d3d11_update_config(void *ctx, mfxHDL handle, mfxConfig cfg)
+{
+#if CONFIG_D3D11VA
+mfxStatus sts;
+IDXGIAdapter *pDXGIAdapter;
+DXGI_ADAPTER_DESC adapterDesc;
+IDXGIDevice *pDXGIDevice = NULL;
+HRESULT hr;
+ID3D11Device *device = handle;
+mfxVariant impl_value;
+
+hr = ID3D11Device_QueryInterface(device, &IID_IDXGIDevice, 
(void**)&pDXGIDevice);
+if (SUCCEEDED(hr)) {
+hr = IDXGIDevice_GetAdapter(pDXGIDevice, &pDXGIAdapter);
+if (FAILED(hr)) {
+av_log(ctx, AV_LOG_ERROR, "Error IDXGIDevice_GetAdapter %d\n", hr);
+goto fail;
+}
+
+hr = IDXGIAdapter_GetDesc(pDXGIAdapter, &adapterDesc);
+if (FAILED(hr)) {
+av_log(ctx, AV_LOG_ERROR, "Error IDXGIAdapter_GetDesc %d\n", hr);
+goto fail;
+}
+} else {
+av_log(ctx, AV_LOG_ERROR, "Error ID3D11Device_QueryInterface %d\n", 
hr);
+goto fail;
+}
+
+impl_value.Type = MFX_VARIANT_TYPE_U16;
+impl_value.Data.U16 = adapterDesc.DeviceId;
+sts = MFXSetConfigFilterProperty(cfg,
+ (const mfxU8 
*)"mfxExtendedDeviceId.DeviceID", impl_value);
+if (sts != MFX_ERR_NONE) {
+av_log(ctx, AV_LOG_ERROR, "Error adding a MFX configuration"
+   "DeviceID property: %d.\n", sts);
+goto fail;
+}
+
+impl_value.Type = MFX_VARIANT_TYPE_PTR;
+impl_value.Data.Ptr = &adapterDesc.AdapterLuid;
+sts = MFXSetConfigFilterProperty(cfg,
+ (const mfxU8 
*)"mfxExtendedDeviceId.DeviceLUID", impl_value);
+if (sts != MFX_ERR_NONE) {
+av_log(ctx, AV_LOG_ERROR, "Error adding a MFX configuration"
+   "DeviceLUID property: %d.\n", sts);
+goto fail;
+}
+
+impl_value.Type = MFX_VARIANT_TYPE_U32;
+impl_value.Data.U32 = 0x0001;
+sts = MFXSetConfigFilterProperty(cfg,
+ (const mfxU8 
*)"mfxExtendedDeviceId.LUIDDeviceNodeMask", impl_value);
+if (sts != MFX_ERR_NONE) {
+av_log(ctx, AV_LOG_ERROR, "Error adding a MFX configuration"
+   "LUIDDeviceNodeMask property: %d.\n", sts);
+goto fail;
+}
+
+return 0;
+
+fail:
+#endif
+return AVERROR_UNKNOWN;
+}
+
+static int qsv_d3d9_update_config(void *ctx, mfxHDL handle, mfxConfig cfg)
+{
+int ret = AVERROR_UNKNOWN;
+#if CONFIG_DXVA2
+mfxStatus sts;
+IDirect3DDeviceManager9* devmgr = handle;
+IDirect3DDevice9Ex *device = NULL;
+HANDLE device_handle = 0;
+IDirect3D9Ex *d3d9ex = NULL;
+LUID luid;
+D3DDEVICE_CREATION_PARAMETERS params;
+HRESULT hr;
+mfxVariant impl_value;
+
+hr = IDirect3DDeviceManager9_OpenDeviceHandle(devmgr, &device_handle);
+if (FAILED(hr)) {
+av_log(ctx, AV_LOG_ERROR, "Error OpenDeviceHandle %d\n", hr);
+goto fail;
+}
+
+hr = IDirect3DDeviceManager9_LockDevice(devmgr, device_handle, &device, 
TRUE);
+if (FAILED(hr)) {
+av_log(ctx, AV_LOG_ERROR, "Error LockDevice %d\n", hr);
+goto fail;
+}
+
+hr = IDirect3DDevice9Ex_GetCreationParameters(device, ¶ms);
+if (FAILED(hr)) {
+av_log(ctx, AV_LOG_ERROR, "Error 
IDirect3DDevice9_GetCreationParameters %d\n", hr);
+goto unlock;
+}
+
+hr = IDirect3DDevice9Ex_GetDirect3D(device, &d3d9ex);
+if (FAILED(hr)) {
+av_log(ctx, AV_LOG_ERROR, "Error IDirect3DDevice9Ex_GetAdapterLUID 
%d\n", hr);
+goto unlock;
+}
+
+hr = IDirect3D9Ex_GetAd

[FFmpeg-devel] [PATCH v11 11/13] lavc/qsv: create mfx session using oneVPL for decoding/encoding

2022-07-20 Thread Xiang, Haihao
From: Haihao Xiang 

If qsv hwdevice is available, use the mfxLoader handle in qsv hwdevice
to create mfx session. Otherwise create mfx session with a new mfxLoader
handle.

This is in preparation for oneVPL support
---
 libavcodec/qsv.c  | 226 +++---
 libavcodec/qsv_internal.h |   1 +
 libavcodec/qsvdec.c   |  11 ++
 libavcodec/qsvenc.h   |   3 +
 libavcodec/qsvenc_h264.c  |   1 -
 libavcodec/qsvenc_hevc.c  |   1 -
 libavcodec/qsvenc_jpeg.c  |   1 -
 libavcodec/qsvenc_mpeg2.c |   1 -
 libavcodec/qsvenc_vp9.c   |   1 -
 9 files changed, 223 insertions(+), 23 deletions(-)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 432675bccf..fe998c9649 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -45,6 +45,12 @@
 #include 
 #endif
 
+#if QSV_ONEVPL
+#include 
+#else
+#define MFXUnload(a) do { } while(0)
+#endif
+
 int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id)
 {
 switch (codec_id) {
@@ -419,6 +425,193 @@ static int ff_qsv_set_display_handle(AVCodecContext 
*avctx, QSVSession *qs)
 }
 #endif //AVCODEC_QSV_LINUX_SESSION_HANDLE
 
+#if QSV_ONEVPL
+static int qsv_new_mfx_loader(AVCodecContext *avctx,
+  mfxIMPL implementation,
+  mfxVersion *pver,
+  void **ploader)
+{
+mfxStatus sts;
+mfxLoader loader = NULL;
+mfxConfig cfg;
+mfxVariant impl_value;
+
+loader = MFXLoad();
+if (!loader) {
+av_log(avctx, AV_LOG_ERROR, "Error creating a MFX loader\n");
+goto fail;
+}
+
+/* Create configurations for implementation */
+cfg = MFXCreateConfig(loader);
+if (!cfg) {
+av_log(avctx, AV_LOG_ERROR, "Error creating a MFX configurations\n");
+goto fail;
+}
+
+impl_value.Type = MFX_VARIANT_TYPE_U32;
+impl_value.Data.U32 = (implementation == MFX_IMPL_SOFTWARE) ?
+MFX_IMPL_TYPE_SOFTWARE : MFX_IMPL_TYPE_HARDWARE;
+sts = MFXSetConfigFilterProperty(cfg,
+ (const mfxU8 *)"mfxImplDescription.Impl", 
impl_value);
+if (sts != MFX_ERR_NONE) {
+av_log(avctx, AV_LOG_ERROR, "Error adding a MFX configuration "
+   "property: %d\n", sts);
+goto fail;
+}
+
+impl_value.Type = MFX_VARIANT_TYPE_U32;
+impl_value.Data.U32 = pver->Version;
+sts = MFXSetConfigFilterProperty(cfg,
+ (const mfxU8 
*)"mfxImplDescription.ApiVersion.Version",
+ impl_value);
+if (sts != MFX_ERR_NONE) {
+av_log(avctx, AV_LOG_ERROR, "Error adding a MFX configuration "
+   "property: %d\n", sts);
+goto fail;
+}
+
+*ploader = loader;
+
+return 0;
+
+fail:
+if (loader)
+MFXUnload(loader);
+
+*ploader = NULL;
+return AVERROR_UNKNOWN;
+}
+
+static int qsv_create_mfx_session_from_loader(void *ctx, mfxLoader loader, 
mfxSession *psession)
+{
+mfxStatus sts;
+mfxSession session = NULL;
+uint32_t impl_idx = 0;
+
+while (1) {
+/* Enumerate all implementations */
+mfxImplDescription *impl_desc;
+
+sts = MFXEnumImplementations(loader, impl_idx,
+ MFX_IMPLCAPS_IMPLDESCSTRUCTURE,
+ (mfxHDL *)&impl_desc);
+/* Failed to find an available implementation */
+if (sts == MFX_ERR_NOT_FOUND)
+break;
+else if (sts != MFX_ERR_NONE) {
+impl_idx++;
+continue;
+}
+
+sts = MFXCreateSession(loader, impl_idx, &session);
+MFXDispReleaseImplDescription(loader, impl_desc);
+if (sts == MFX_ERR_NONE)
+break;
+
+impl_idx++;
+}
+
+if (sts != MFX_ERR_NONE) {
+av_log(ctx, AV_LOG_ERROR, "Error creating a MFX session: %d.\n", sts);
+goto fail;
+}
+
+*psession = session;
+
+return 0;
+
+fail:
+if (session)
+MFXClose(session);
+
+*psession = NULL;
+return AVERROR_UNKNOWN;
+}
+
+static int qsv_create_mfx_session(AVCodecContext *avctx,
+  mfxIMPL implementation,
+  mfxVersion *pver,
+  int gpu_copy,
+  mfxSession *psession,
+  void **ploader)
+{
+mfxLoader loader = NULL;
+
+/* Don't create a new MFX loader if the input loader is valid */
+if (*ploader == NULL) {
+av_log(avctx, AV_LOG_VERBOSE,
+   "Use Intel(R) oneVPL to create MFX session, the required "
+   "implementation version is %d.%d\n",
+   pver->Major, pver->Minor);
+
+if (qsv_new_mfx_loader(avctx, implementation, pver, (void **)&loader))
+goto fail;
+
+av_assert0(loader);
+} else {
+av_log(avctx, AV_LOG_VERBOSE,
+   "Use Intel(R) oneVPL to create MFX session with th

[FFmpeg-devel] [PATCH v11 12/13] lavfi/qsv: create mfx session using oneVPL for qsv filters

2022-07-20 Thread Xiang, Haihao
From: Haihao Xiang 

Use the mfxLoader handle in qsv hwdevice to create mfx session for qsv
filters.

This is in preparation for oneVPL support
---
 libavfilter/qsvvpp.c | 109 ---
 libavfilter/qsvvpp.h |   5 ++
 libavfilter/vf_deinterlace_qsv.c |  13 ++--
 libavfilter/vf_scale_qsv.c   |  11 ++--
 4 files changed, 115 insertions(+), 23 deletions(-)

diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index 3f984fd5f9..5068ce0d5a 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -23,8 +23,6 @@
 
 #include "libavutil/common.h"
 #include "libavutil/mathematics.h"
-#include "libavutil/hwcontext.h"
-#include "libavutil/hwcontext_qsv.h"
 #include "libavutil/time.h"
 #include "libavutil/pixdesc.h"
 
@@ -32,6 +30,12 @@
 #include "qsvvpp.h"
 #include "video.h"
 
+#if QSV_ONEVPL
+#include 
+#else
+#define MFXUnload(a) do { } while(0)
+#endif
+
 #define IS_VIDEO_MEMORY(mode)  (mode & 
(MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET | \
 
MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET))
 #if QSV_HAVE_OPAQUE
@@ -614,13 +618,10 @@ static int init_vpp_session(AVFilterContext *avctx, 
QSVVPPContext *s)
 }
 
 /* create a "slave" session with those same properties, to be used for vpp 
*/
-ret = MFXInit(impl, &ver, &s->session);
-if (ret < 0)
-return ff_qsvvpp_print_error(avctx, ret, "Error initializing a 
session");
-else if (ret > 0) {
-ff_qsvvpp_print_warning(avctx, ret, "Warning in session 
initialization");
-return AVERROR_UNKNOWN;
-}
+ret = ff_qsvvpp_create_mfx_session(avctx, device_hwctx->loader, impl, &ver,
+   &s->session);
+if (ret)
+return ret;
 
 if (handle) {
 ret = MFXVideoCORE_SetHandle(s->session, handle_type, handle);
@@ -906,3 +907,93 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink 
*inlink, AVFrame *picr
 
 return 0;
 }
+
+#if QSV_ONEVPL
+
+int ff_qsvvpp_create_mfx_session(void *ctx,
+ void *loader,
+ mfxIMPL implementation,
+ mfxVersion *pver,
+ mfxSession *psession)
+{
+mfxStatus sts;
+mfxSession session = NULL;
+uint32_t impl_idx = 0;
+
+av_log(ctx, AV_LOG_VERBOSE,
+   "Use Intel(R) oneVPL to create MFX session with the specified MFX 
loader\n");
+
+if (!loader) {
+av_log(ctx, AV_LOG_ERROR, "Invalid MFX Loader handle\n");
+return AVERROR(EINVAL);
+}
+
+while (1) {
+/* Enumerate all implementations */
+mfxImplDescription *impl_desc;
+
+sts = MFXEnumImplementations(loader, impl_idx,
+ MFX_IMPLCAPS_IMPLDESCSTRUCTURE,
+ (mfxHDL *)&impl_desc);
+/* Failed to find an available implementation */
+if (sts == MFX_ERR_NOT_FOUND)
+break;
+else if (sts != MFX_ERR_NONE) {
+impl_idx++;
+continue;
+}
+
+sts = MFXCreateSession(loader, impl_idx, &session);
+MFXDispReleaseImplDescription(loader, impl_desc);
+if (sts == MFX_ERR_NONE)
+break;
+
+impl_idx++;
+}
+
+if (sts < 0)
+return ff_qsvvpp_print_error(ctx, sts,
+ "Error creating a MFX session");
+else if (sts > 0) {
+ff_qsvvpp_print_warning(ctx, sts,
+"Warning in MFX session creation");
+return AVERROR_UNKNOWN;
+}
+
+*psession = session;
+
+return 0;
+}
+
+#else
+
+int ff_qsvvpp_create_mfx_session(void *ctx,
+ void *loader,
+ mfxIMPL implementation,
+ mfxVersion *pver,
+ mfxSession *psession)
+{
+mfxSession session = NULL;
+mfxStatus sts;
+
+av_log(ctx, AV_LOG_VERBOSE,
+   "Use Intel(R) Media SDK to create MFX session, API version is "
+   "%d.%d, the required implementation version is %d.%d\n",
+   MFX_VERSION_MAJOR, MFX_VERSION_MINOR, pver->Major, pver->Minor);
+
+*psession = NULL;
+sts = MFXInit(implementation, pver, &session);
+if (sts < 0)
+return ff_qsvvpp_print_error(ctx, sts,
+ "Error initializing an MFX session");
+else if (sts > 0) {
+ff_qsvvpp_print_warning(ctx, sts, "Warning in MFX session 
initialization");
+return AVERROR_UNKNOWN;
+}
+
+*psession = session;
+
+return 0;
+}
+
+#endif
diff --git a/libavfilter/qsvvpp.h b/libavfilter/qsvvpp.h
index 3e7d56021b..a8cfcc565a 100644
--- a/libavfilter/qsvvpp.h
+++ b/libavfilter/qsvvpp.h
@@ -28,6 +28,8 @@
 
 #include "avfilter.h"
 #include "libavutil/fifo.h"
+#include "libavutil/hwcontext.h"
+#include "libavutil/hwcontext_qsv.h"
 
 #define FF_INLINK

[FFmpeg-devel] [PATCH v11 07/13] qsvenc: support MFX_RATECONTROL_LA_EXT when MFX_VERSION < 2.0

2022-07-20 Thread Xiang, Haihao
From: Haihao Xiang 

MFX_RATECONTROL_LA_EXT isn't supported for MFX_VERSION >= 2.0[1][2].
This is in preparation for oneVPL support

[1] 
https://spec.oneapi.io/versions/latest/elements/oneVPL/source/VPL_intel_media_sdk.html#msdk-full-name-feature-removals
[2] https://github.com/oneapi-src/oneVPL
---
 libavcodec/qsvenc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index e772bd99b5..d3a9a2118e 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -141,7 +141,9 @@ static const struct {
 #if QSV_HAVE_VCM
 { MFX_RATECONTROL_VCM, "VCM" },
 #endif
+#if !QSV_ONEVPL
 { MFX_RATECONTROL_LA_EXT,  "LA_EXT" },
+#endif
 { MFX_RATECONTROL_LA_HRD,  "LA_HRD" },
 { MFX_RATECONTROL_QVBR,"QVBR" },
 };
-- 
2.17.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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v11 13/13] configure: add --enable-libvpl option

2022-07-20 Thread Xiang, Haihao
From: Haihao Xiang 

This allows user to build FFmpeg against Intel oneVPL. oneVPL 2.6
is the required minimum version when building Intel oneVPL code.

It will fail to run configure script if both libmfx and libvpl are
enabled.

It is recommended to use oneVPL for new work, even for currently available
hardwares [1]

Note the preferred child device type is d3d11va for libvpl on Windows.
The commands below will use d3d11va if d3d11va is available on Windows.
$ ffmpeg -hwaccel qsv -c:v h264_qsv ...
$ ffmpeg -qsv_device 0 -hwaccel qsv -c:v h264_qsv ...
$ ffmpeg -init_hw_device qsv=qsv:hw_any -hwaccel qsv -c:v h264_qsv ...
$ ffmpeg -init_hw_device qsv=qsv:hw_any,child_device=0 -hwaccel qsv -c:v 
h264_qsv ...

User may use child_device_type option to specify child device type to
dxva2 or derive a qsv device from a dxva2 device
$ ffmpeg -init_hw_device qsv=qsv:hw_any,child_device=0,child_device_type=dxva2 
-hwaccel qsv -c:v h264_qsv ...
$ ffmpeg -init_hw_device dxva2=d3d9:0 -init_hw_device qsv=qsv@d3d9 -hwaccel qsv 
-c:v h264_qsv ...

[1] 
https://www.intel.com/content/www/us/en/develop/documentation/upgrading-from-msdk-to-onevpl/top.html
---
 configure | 29 ++---
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 23ae3eaf7e..23a495f045 100755
--- a/configure
+++ b/configure
@@ -341,6 +341,7 @@ External library support:
   --disable-ffnvcodec  disable dynamically linked Nvidia code [autodetect]
   --enable-libdrm  enable DRM code (Linux) [no]
   --enable-libmfx  enable Intel MediaSDK (AKA Quick Sync Video) code 
via libmfx [no]
+  --enable-libvpl  enable Intel oneVPL code via libvpl if libmfx is 
not used [no]
   --enable-libnpp  enable Nvidia Performance Primitives-based code [no]
   --enable-mmalenable Broadcom Multi-Media Abstraction Layer 
(Raspberry Pi) via MMAL [no]
   --disable-nvdec  disable Nvidia video decoding acceleration (via 
hwaccel) [autodetect]
@@ -1921,6 +1922,7 @@ HWACCEL_LIBRARY_NONFREE_LIST="
 HWACCEL_LIBRARY_LIST="
 $HWACCEL_LIBRARY_NONFREE_LIST
 libmfx
+libvpl
 mmal
 omx
 opencl
@@ -6574,23 +6576,36 @@ enabled libjxl&& require_pkg_config libjxl 
"libjxl >= 0.7.0" jxl/dec
 enabled libklvanc && require libklvanc libklvanc/vanc.h 
klvanc_context_create -lklvanc
 enabled libkvazaar&& require_pkg_config libkvazaar "kvazaar >= 0.8.1" 
kvazaar.h kvz_api_get
 enabled liblensfun&& require_pkg_config liblensfun lensfun lensfun.h 
lf_db_new
+
+if enabled libmfx && enabled libvpl; then
+   die "ERROR: can not use libmfx and libvpl together"
 # While it may appear that require is being used as a pkg-config
 # fallback for libmfx, it is actually being used to detect a different
 # installation route altogether.  If libmfx is installed via the Intel
 # Media SDK or Intel Media Server Studio, these don't come with
 # pkg-config support.  Instead, users should make sure that the build
 # can find the libraries and headers through other means.
-enabled libmfx&& { { check_pkg_config libmfx "libmfx >= 1.28 
libmfx < 2.0" "mfxvideo.h" MFXInit ||
+elif enabled libmfx; then
+{ check_pkg_config libmfx "libmfx >= 1.28 libmfx < 2.0" "mfxvideo.h" 
MFXInit ||
 # Some old versions of libmfx have the following settings in libmfx.pc:
 #   includedir=/usr/include
 #   Cflags: -I${includedir}
 # So add -I${includedir}/mfx to CFLAGS
- { check_pkg_config libmfx "libmfx >= 1.28 
libmfx < 2.0" "mfx/mfxvideo.h" MFXInit && add_cflags -I${libmfx_incdir}/mfx; } 
||
- { require libmfx "mfxvideo.h mfxdefs.h" 
MFXInit "-llibmfx $advapi32_extralibs" &&
-   { test_cpp_condition mfxdefs.h "MFX_VERSION 
>= 1028 && MFX_VERSION < 2000" || die "ERROR: libmfx version must be >= 1.28 
and < 2.0"; }  &&
- warn "using libmfx without pkg-config"; } 
} &&
-   warn "build FFmpeg against libmfx 1.x, obsolete 
features of libmfx such as OPAQUE memory,\n"\
-"multi-frame encode, user plugins and 
LA_EXT rate control mode are enabled"; }
+  { check_pkg_config libmfx "libmfx >= 1.28 libmfx < 2.0" "mfx/mfxvideo.h" 
MFXInit && add_cflags -I${libmfx_incdir}/mfx; } ||
+  { require libmfx "mfxvideo.h mfxdefs.h" MFXInit "-llibmfx 
$advapi32_extralibs" &&
+{ test_cpp_condition mfxdefs.h "MFX_VERSION >= 1028 && MFX_VERSION < 
2000" || die "ERROR: libmfx version must be >= 1.28 and < 2.0"; }  &&
+warn "using libmfx without pkg-config"; } } &&
+warn "build FFmpeg against libmfx 1.x, obsolete features of libmfx such as 
OPAQUE memory,\n"\
+ "multi-frame encode, user plugins and LA_EXT rate control mode are 
enabled"
+elif enabled libvpl; then
+# Consider pkg-config only. The name of libmfx is still passed to 
check_pkg_config function for --

Re: [FFmpeg-devel] [PATCH v10 10/13] lavu/hwcontext_qsv: make qsv hwdevice works with oneVPL

2022-07-20 Thread Xiang, Haihao
On Tue, 2022-07-19 at 07:18 +, Xiang, Haihao wrote:
> On Mon, 2022-07-18 at 15:02 +0200, Anton Khirnov wrote:
> > Quoting Xiang, Haihao (2022-07-12 08:27:32)
> > > +static int qsv_va_update_config(void *ctx, mfxHDL handle, mfxConfig cfg)
> > > +{
> > > +#if CONFIG_VAAPI
> > > +#if VA_CHECK_VERSION(1, 5, 0)
> > > +#define LOCAL_VADISPLAYPCIID VADisplayPCIID
> > > +#else
> > > +#define LOCAL_VADISPLAYPCIID 21
> > > +#endif
> > > +mfxStatus sts;
> > > +VADisplay dpy = handle;
> > > +VAStatus vas;
> > > +VADisplayAttribute attr = {
> > > +.type = LOCAL_VADISPLAYPCIID
> > > +};
> > > +mfxVariant impl_value;
> > > +
> > > +vas = vaGetDisplayAttributes(dpy, &attr, 1);
> > > +if (vas == VA_STATUS_SUCCESS && attr.flags !=
> > > VA_DISPLAY_ATTRIB_NOT_SUPPORTED) {
> > > +impl_value.Type = MFX_VARIANT_TYPE_U16;
> > > +impl_value.Data.U16 = (attr.value & 0x);
> > > +sts = MFXSetConfigFilterProperty(cfg,
> > > + (const mfxU8
> > > *)"mfxExtendedDeviceId.DeviceID", impl_value);
> > > +if (sts != MFX_ERR_NONE) {
> > > +av_log(ctx, AV_LOG_ERROR, "Error adding a MFX configuration"
> > > +   "DeviceID property: %d.\n", sts);
> > > +goto fail;
> > > +}
> > > +} else
> > > +av_log(ctx, AV_LOG_WARNING, "Cannot get device id from the
> > > driver,
> > > the default "
> > > +   "MFX implementation will be loaded for this device. Please
> > > consider to "
> > > +   "upgrade the driver to support VAAPI 1.5.0. \n");
> > 
> > I would still prefer to fail here. The user requested a specific device,
> > disregarding that request is evil.
> 
> Thanks for the comment. There is only one available device for most users, so
> the default one and the given one from user should be the same, otherwise it
> won't work. I don't want to make them in trouble if they don't have a driver
> to
> support the new interface. However I agree with you it is a little evil to
> ignore the request. I'll update the patch to return error here. 
> 

Fixed in v11, 

Thanks
Haihao

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 1/2] avformat/argo_cvg: name unk{1, 2} fields correctly

2022-07-20 Thread Zane van Iperen




On 18/7/2022 11:45 pm, Andreas Rheinhardt wrote:


  av_log(s, AV_LOG_TRACE, "size   = %u\n", ctx->header.size);
-av_log(s, AV_LOG_TRACE, "unk= %u, %u\n", ctx->header.unk1, 
ctx->header.unk2);
+av_log(s, AV_LOG_TRACE, "loop   = %u\n", ctx->header.loop);
+av_log(s, AV_LOG_TRACE, "reverb = %u\n", ctx->header.reverb);


%u is for unsigned, yet these variables are of type uint32_t. It is not
guaranteed that these two types are the same (yet they typically are).
That's why the PRI-macros exist.


Good catch, I'll rectify that.


(Apart from that: Does this have to be three separate av_logs?)


I can probably just remove them, now that I know what the fields are.

Although, I wouldn't mind exposing them as additional metadata...
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 3/6] tools/target_dec_fuzzer: Adjust threshold for MMVIDEO

2022-07-20 Thread Peter Ross
On Tue, Jul 19, 2022 at 01:34:50PM +0200, Michael Niedermayer wrote:
> Fixes: Timeout
> Fixes: 
> 49003/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MMVIDEO_fuzzer-5550368423018496
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  tools/target_dec_fuzzer.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
> index 1587045e02..017c5cf024 100644
> --- a/tools/target_dec_fuzzer.c
> +++ b/tools/target_dec_fuzzer.c
> @@ -246,6 +246,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
> size) {
>  case AV_CODEC_ID_LOCO:maxpixels  /= 1024;  break;
>  case AV_CODEC_ID_VORBIS:  maxsamples /= 1024;  break;
>  case AV_CODEC_ID_LSCR:maxpixels  /= 16;break;
> +case AV_CODEC_ID_MMVIDEO: maxpixels  /= 256;   break;
>  case AV_CODEC_ID_MOTIONPIXELS:maxpixels  /= 256;   break;
>  case AV_CODEC_ID_MP4ALS:  maxsamples /= 65536; break;
>  case AV_CODEC_ID_MSA1:maxpixels  /= 16384; break;

please apply.

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] Make implicit void pointer cast explicit

2022-07-20 Thread Nicolas George
Amir Mazzarella (12022-07-19):
> I understand that FFmpeg does not contain accommodations, but in my
> opinion it is less of an accommodation and more for readability, avoiding
> an implicit cast. An explicit void pointer cast, like the one presented in

The arguments against useless casts have been worded a thousand times,
let us not waste everybody's energy with one more.

> my patch, is done elsewhere in FFmpeg code as well.
> See 
> https://github.com/FFmpeg/FFmpeg/blob/master/libavutil/hwcontext_qsv.c#L316

It is not the only coding style inconsistency around this line. Coding
style inconsistencies cannot be considered precedents.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH v2 0/3] hwcontext_vaapi: dlopen libva-x11 and libva-drm

2022-07-20 Thread Emil Velikov
Greetings everyone,

As you may know the libva* set of libraries share an internal ABI
between them. In a resent libva commit, the va_fool API was removed.

Thus if one is to mix different versions of libva.so and libva-x11.so
they will get an error, leading to a crash of the whole stack.

The simple solution is to dlopen() the winsys components, like libva-x11
and libva-drm. The changes are pretty minor and allow us to handle this
king of issues.

Comments and suggestions are welcome, but please me gentle it's my first
time hacking on ffmpeg :-P

Thanks
Emil

Aside:
 - Please consider backporting it to the stable branches in due time.
 - I've noticed that we leak state in the error paths, happy to send
   follow-up patches if you'd like those fixed.
 - My TODO includes reducing the massive ABI between libva* and
   backend drivers, to a single extra "registration" API entrypoint.

---

Changes in v2:
 - Add libdl dependency, to address underlinking with older glibc

Emil Velikov (3):
  hwcontext_vaapi: do not link against libva-x11.so
  hwcontext_vaapi: do not link against libva-drm.so
  hwcontext_vaapi: #if guard VAAPI_DRM specifics

 configure   |  3 +-
 libavutil/hwcontext_vaapi.c | 92 +++--
 2 files changed, 91 insertions(+), 4 deletions(-)

-- 
2.37.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH v2 1/3] hwcontext_vaapi: do not link against libva-x11.so

2022-07-20 Thread Emil Velikov
From: Emil Velikov 

There is an internal ABI between libva.so the libva-XXX.so libraries.

With a recent change, the internal va_fool API was removed breaking the
ABI. So if libva.so and libva-x11.so are from different version, the
whole stack will crash.

Instead we can dlopen() the libva-x11 library and gracefully error out.

Signed-off-by: Emil Velikov 
---
v2: add libdl dependency
---
 configure   |  3 ++-
 libavutil/hwcontext_vaapi.c | 34 +-
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 18d9b61a99..605afd58a7 100755
--- a/configure
+++ b/configure
@@ -3816,7 +3816,8 @@ swscale_suggest="libm stdatomic"
 
 avcodec_extralibs="pthreads_extralibs iconv_extralibs dxva2_extralibs"
 avfilter_extralibs="pthreads_extralibs"
-avutil_extralibs="d3d11va_extralibs nanosleep_extralibs pthreads_extralibs 
vaapi_drm_extralibs vaapi_x11_extralibs vdpau_x11_extralibs"
+avutil_deps="libdl"
+avutil_extralibs="d3d11va_extralibs nanosleep_extralibs pthreads_extralibs 
vaapi_drm_extralibs vdpau_x11_extralibs"
 
 # programs
 ffmpeg_deps="avcodec avfilter avformat"
diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index c3a98bc4b1..e44d324928 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -18,8 +18,16 @@
 
 #include "config.h"
 
+#if CONFIG_VAAPI_1
+#   define VA_ABI ".2"
+#else
+#   define VA_ABI ".1"
+#endif
+
 #if HAVE_VAAPI_X11
 #   include 
+#   include 
+#   define VA_X11_LIB "libva-x11.so" VA_ABI
 #endif
 #if HAVE_VAAPI_DRM
 #   include 
@@ -54,6 +62,7 @@
 
 typedef struct VAAPIDevicePriv {
 #if HAVE_VAAPI_X11
+void *libva_x11;
 Display *x11_display;
 #endif
 
@@ -1565,6 +1574,8 @@ static void vaapi_device_free(AVHWDeviceContext *ctx)
 vaTerminate(hwctx->display);
 
 #if HAVE_VAAPI_X11
+if (priv->libva_x11)
+dlclose(priv->libva_x11);
 if (priv->x11_display)
 XCloseDisplay(priv->x11_display);
 #endif
@@ -1723,14 +1734,35 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, 
const char *device,
 
 #if HAVE_VAAPI_X11
 if (!display && try_x11) {
+VADisplay (*GetDisplay)(Display *dpy);
+
+priv->libva_x11 = dlopen(VA_X11_LIB, RTLD_NOW | RTLD_LOCAL);
+if (!priv->libva_x11) {
+av_log(ctx, AV_LOG_ERROR, "Cannot open %s library %s.\n",
+   VA_X11_LIB, dlerror());
+return AVERROR_UNKNOWN;
+}
+
+GetDisplay = dlsym(priv->libva_x11, "vaGetDisplay");
+if (!GetDisplay) {
+av_log(ctx, AV_LOG_ERROR, "Cannot retrieve %s entrypoint %s.\n",
+   "vaGetDisplay", dlerror());
+// Always dlclose after the dlerror(). The former can alter the
+// error string returned by the latter.
+dlclose(priv->libva_x11);
+return AVERROR_UNKNOWN;
+}
+
 // Try to open the device as an X11 display.
 priv->x11_display = XOpenDisplay(device);
 if (!priv->x11_display) {
+dlclose(priv->libva_x11);
 av_log(ctx, AV_LOG_VERBOSE, "Cannot open X11 display "
"%s.\n", XDisplayName(device));
 } else {
-display = vaGetDisplay(priv->x11_display);
+display = GetDisplay(priv->x11_display);
 if (!display) {
+dlclose(priv->libva_x11);
 av_log(ctx, AV_LOG_ERROR, "Cannot open a VA display "
"from X11 display %s.\n", XDisplayName(device));
 return AVERROR_UNKNOWN;
-- 
2.37.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH v2 2/3] hwcontext_vaapi: do not link against libva-drm.so

2022-07-20 Thread Emil Velikov
From: Emil Velikov 

There is an internal ABI between libva.so and libva-drm.so. So having
mismatched versions can cause all sorts of issues.

We had the breakage between libva.so and libva-x11.so addressed with
earlier commit. There's no point in waiting for things to break wrt
libva-drm.so so pre-emptively, switch to dlopen()-ing the library.

Signed-off-by: Emil Velikov 
---
v2: rebase against the libdl fixup
---
 configure   |  2 +-
 libavutil/hwcontext_vaapi.c | 48 +++--
 2 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 605afd58a7..a941d4b927 100755
--- a/configure
+++ b/configure
@@ -3817,7 +3817,7 @@ swscale_suggest="libm stdatomic"
 avcodec_extralibs="pthreads_extralibs iconv_extralibs dxva2_extralibs"
 avfilter_extralibs="pthreads_extralibs"
 avutil_deps="libdl"
-avutil_extralibs="d3d11va_extralibs nanosleep_extralibs pthreads_extralibs 
vaapi_drm_extralibs vdpau_x11_extralibs"
+avutil_extralibs="d3d11va_extralibs nanosleep_extralibs pthreads_extralibs 
vdpau_x11_extralibs"
 
 # programs
 ffmpeg_deps="avcodec avfilter avformat"
diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index e44d324928..7734a50fc0 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -31,6 +31,8 @@
 #endif
 #if HAVE_VAAPI_DRM
 #   include 
+#   include 
+#   define VA_DRM_LIB "libva-drm.so" VA_ABI
 #endif
 
 #if CONFIG_LIBDRM
@@ -66,6 +68,7 @@ typedef struct VAAPIDevicePriv {
 Display *x11_display;
 #endif
 
+void *libva_drm;
 int drm_fd;
 } VAAPIDevicePriv;
 
@@ -1582,6 +1585,8 @@ static void vaapi_device_free(AVHWDeviceContext *ctx)
 
 if (priv->drm_fd >= 0)
 close(priv->drm_fd);
+if (priv->libva_drm)
+dlclose(priv->libva_drm);
 
 av_freep(&priv);
 }
@@ -1665,6 +1670,8 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, 
const char *device,
 
 #if HAVE_VAAPI_DRM
 while (!display && try_drm) {
+VADisplay (*GetDisplayDRM)(int fd);
+
 // If the device is specified, try to open it as a DRM device node.
 // If not, look for a usable render node, possibly restricted to those
 // using a specified kernel driver.
@@ -1722,8 +1729,26 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, 
const char *device,
 break;
 }
 
-display = vaGetDisplayDRM(priv->drm_fd);
+priv->libva_drm = dlopen(VA_DRM_LIB, RTLD_NOW | RTLD_LOCAL);
+if (!priv->libva_drm) {
+av_log(ctx, AV_LOG_ERROR, "Cannot open %s library %s.\n",
+   VA_DRM_LIB, dlerror());
+return AVERROR_UNKNOWN;
+}
+
+GetDisplayDRM = dlsym(priv->libva_drm, "vaGetDisplayDRM");
+if (!GetDisplayDRM) {
+av_log(ctx, AV_LOG_ERROR, "Cannot retrieve %s entrypoint %s.\n",
+   "vaGetDisplayDRM", dlerror());
+// Always dlclose after the dlerror(). The former can alter the
+// error string returned by the latter.
+dlclose(priv->libva_drm);
+return AVERROR_UNKNOWN;
+}
+
+display = GetDisplayDRM(priv->drm_fd);
 if (!display) {
+dlclose(priv->libva_drm);
 av_log(ctx, AV_LOG_VERBOSE, "Cannot open a VA display "
"from DRM device %s.\n", device);
 return AVERROR_EXTERNAL;
@@ -1811,6 +1836,7 @@ static int vaapi_device_derive(AVHWDeviceContext *ctx,
 #if HAVE_VAAPI_DRM
 if (src_ctx->type == AV_HWDEVICE_TYPE_DRM) {
 AVDRMDeviceContext *src_hwctx = src_ctx->hwctx;
+VADisplay (*GetDisplayDRM)(int fd);
 VADisplay *display;
 VAAPIDevicePriv *priv;
 int fd;
@@ -1879,8 +1905,26 @@ static int vaapi_device_derive(AVHWDeviceContext *ctx,
 ctx->user_opaque = priv;
 ctx->free= &vaapi_device_free;
 
-display = vaGetDisplayDRM(fd);
+priv->libva_drm = dlopen(VA_DRM_LIB, RTLD_NOW | RTLD_LOCAL);
+if (!priv->libva_drm) {
+av_log(ctx, AV_LOG_ERROR, "Cannot open %s library %s.\n",
+   VA_DRM_LIB, dlerror());
+return AVERROR_UNKNOWN;
+}
+
+GetDisplayDRM = dlsym(priv->libva_drm, "vaGetDisplayDRM");
+if (!GetDisplayDRM) {
+av_log(ctx, AV_LOG_ERROR, "Cannot retrieve %s entrypoint %s.\n",
+   "vaGetDisplayDRM", dlerror());
+// Always dlclose after the dlerror(). The former can alter the
+// error string returned by the latter.
+dlclose(priv->libva_drm);
+return AVERROR_UNKNOWN;
+}
+
+display = GetDisplayDRM(fd);
 if (!display) {
+dlclose(priv->libva_drm);
 av_log(ctx, AV_LOG_ERROR, "Failed to open a VA display from "
"DRM device.\n");
 return AVERROR(EIO);
-- 
2.37.0

___
ffmpeg-devel mailing list
ff

[FFmpeg-devel] [PATCH v2 3/3] hwcontext_vaapi: #if guard VAAPI_DRM specifics

2022-07-20 Thread Emil Velikov
From: Emil Velikov 

Similar to the VAAPI_X11 bits, guard all the VAAPI_DRM parts behind a
compiler guard.

Signed-off-by: Emil Velikov 
---
 libavutil/hwcontext_vaapi.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index 7734a50fc0..7aea3e7b96 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -18,6 +18,10 @@
 
 #include "config.h"
 
+#if !HAVE_VAAPI_X11 && !HAVE_VAAPI_DRM
+#error "At least one VAAPI winsys is required X11 or DRM"
+#endif
+
 #if CONFIG_VAAPI_1
 #   define VA_ABI ".2"
 #else
@@ -68,8 +72,10 @@ typedef struct VAAPIDevicePriv {
 Display *x11_display;
 #endif
 
+#if HAVE_VAAPI_DRM
 void *libva_drm;
 int drm_fd;
+#endif
 } VAAPIDevicePriv;
 
 typedef struct VAAPISurfaceFormat {
@@ -1583,10 +1589,12 @@ static void vaapi_device_free(AVHWDeviceContext *ctx)
 XCloseDisplay(priv->x11_display);
 #endif
 
+#if HAVE_VAAPI_DRM
 if (priv->drm_fd >= 0)
 close(priv->drm_fd);
 if (priv->libva_drm)
 dlclose(priv->libva_drm);
+#endif
 
 av_freep(&priv);
 }
@@ -1645,7 +1653,9 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, 
const char *device,
 if (!priv)
 return AVERROR(ENOMEM);
 
+#if HAVE_VAAPI_DRM
 priv->drm_fd = -1;
+#endif
 
 ctx->user_opaque = priv;
 ctx->free= vaapi_device_free;
-- 
2.37.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] libavformat/movenc: Is packets being more than INT_MAX apart always an error?

2022-07-20 Thread facefunk
It's commonly the case with forced subtitle tracks that samples are more
than INT_MAX microseconds (35m47.48s) apart. This being the case, packet
duration will be deemed out of range by check_pkt and the packet dts set to
an incorrect value, even if pkt->duration is actually valid.

I had begun working out how to inject extra packets to satisfy this check
but I thought I would ask. Is this check necessary for mov_text packets?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] libavformat/movenc: Is packets being more than INT_MAX apart always an error?

2022-07-20 Thread zhilizhao(赵志立)


> On Jul 20, 2022, at 8:18 PM, facefunk  wrote:
> 
> It's commonly the case with forced subtitle tracks that samples are more
> than INT_MAX microseconds (35m47.48s) apart. This being the case, packet
> duration will be deemed out of range by check_pkt and the packet dts set to
> an incorrect value, even if pkt->duration is actually valid.
> 
> I had begun working out how to inject extra packets to satisfy this check
> but I thought I would ask. Is this check necessary for mov_text packets?

I think so, it’s still limited by the 32bits sample_delta in stts.

On the other hand, I have an idea that a timescale like 100 can be used in
that case, which is 2^31/100/3600 = 5965 hours.

> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 5/5] avfilter/vf_yadif: Add x86_64 avx yadif asm

2022-07-20 Thread Michael Niedermayer
On Tue, Jul 19, 2022 at 09:41:17PM -0700, Chris Phlipot wrote:
> Add a new version of yadif_filter_line performed using packed bytes
> instead of the packed words used by the current implementaiton. As
> a result this implementation runs almost 2x as fast as the current
> fastest SSSE3 implementation.
> 
> This implementation is created from scratch based on the C code, with
> the goal of keeping all intermediate values within 8-bits so that
> the vectorized code can be computed using packed bytes. differences
> are as follows:
> - Use algorithms to compute avg and abs difference using only 8-bit
>  intermediate values.
> - Reworked the mode 1 code by applying various mathematical identities
>  to keep all intermediate values within 8-bits.
> - Attempt to compute the spatial score using only 8-bits. The actual
>  spatial score fits within this range 97% (content dependent) of the
>  time for the entire 128-bit xmm vector. In the case that spatial
>  score needs more than 8-bits to be represented, we detect this case,
>  and recompute the spatial score using 16-bit packed words instead.
> 
> In 3% of cases the spatial_score will need more than 8-bytes to store
> so we have a slow path, where the spatial score is computed using
> packed words instead.
> 
> This implementation is currently limited to x86_64 due to the number
> of registers required. x86_32 is possible, but the performance benefit
> over the existing SSSE3 implentation is not as great, due to all of the
> stack spills that would result from having far fewer registers. ASM was
> not generated for the 32-bit varient due to limited ROI, as most AVX
> users are likely on 64-bit OS at this point and 32-bit users would
> lose out on most of the performance benefit.
> 
> Signed-off-by: Chris Phlipot 

theres no need to support 32it but ffmpeg build must not break
on linux x86-32

src/libavfilter/x86/vf_yadif_x64.asm:145: error: impossible combination of 
address sizes
src/libavfilter/x86/vf_yadif_x64.asm:145: error: invalid effective address
src/libavfilter/x86/vf_yadif_x64.asm:146: error: impossible combination of 
address sizes
src//libavutil/x86/x86inc.asm:1399: ... from macro `movdqu' defined here
src//libavutil/x86/x86inc.asm:1264: ... from macro `RUN_AVX_INSTR' defined here
src//libavutil/x86/x86inc.asm:1717: ... from macro `vmovdqu' defined here


[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Everything should be made as simple as possible, but not simpler.
-- Albert Einstein


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 2/2] avcodec/hdrdec: lines can be empty

2022-07-20 Thread Michael Niedermayer
On Wed, Jul 20, 2022 at 08:55:45AM +0200, Paul B Mahol wrote:
> lgtm

will apply

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 1/6] avcodec/mpeg4videoenc: fix encoding long frames

2022-07-20 Thread Michael Niedermayer
On Tue, Jul 19, 2022 at 01:34:48PM +0200, Michael Niedermayer wrote:
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/mpeg4videoenc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

will apply

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Take away the freedom of one citizen and you will be jailed, take away
the freedom of all citizens and you will be congratulated by your peers
in Parliament.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 5/6] avcodec/ffv1dec: consider run increase in minimal golomb frame size

2022-07-20 Thread Michael Niedermayer
On Tue, Jul 19, 2022 at 08:37:38AM -0300, James Almer wrote:
> 
> 
> On 7/19/2022 8:34 AM, Michael Niedermayer wrote:
> > Fixes: Timeout
> > Fixes: 
> > 49160/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-5672826144686080
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >   libavcodec/ffv1dec.c | 6 +-
> >   1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
> > index 01ddcaa512..9bdac0be4e 100644
> > --- a/libavcodec/ffv1dec.c
> > +++ b/libavcodec/ffv1dec.c
> > @@ -883,7 +883,11 @@ static int decode_frame(AVCodecContext *avctx, AVFrame 
> > *rframe,
> >   if (buf_size < avctx->width * avctx->height / (128*8))
> >   return AVERROR_INVALIDDATA;
> >   } else {
> > -if (buf_size < avctx->height / 8)
> > +int i;
> 
> for (int i...

will apply with that change

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Take away the freedom of one citizen and you will be jailed, take away
the freedom of all citizens and you will be congratulated by your peers
in Parliament.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 3/6] tools/target_dec_fuzzer: Adjust threshold for MMVIDEO

2022-07-20 Thread Michael Niedermayer
On Wed, Jul 20, 2022 at 06:58:10PM +1000, Peter Ross wrote:
> On Tue, Jul 19, 2022 at 01:34:50PM +0200, Michael Niedermayer wrote:
> > Fixes: Timeout
> > Fixes: 
> > 49003/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MMVIDEO_fuzzer-5550368423018496
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  tools/target_dec_fuzzer.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
> > index 1587045e02..017c5cf024 100644
> > --- a/tools/target_dec_fuzzer.c
> > +++ b/tools/target_dec_fuzzer.c
> > @@ -246,6 +246,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
> > size) {
> >  case AV_CODEC_ID_LOCO:maxpixels  /= 1024;  break;
> >  case AV_CODEC_ID_VORBIS:  maxsamples /= 1024;  break;
> >  case AV_CODEC_ID_LSCR:maxpixels  /= 16;break;
> > +case AV_CODEC_ID_MMVIDEO: maxpixels  /= 256;   break;
> >  case AV_CODEC_ID_MOTIONPIXELS:maxpixels  /= 256;   break;
> >  case AV_CODEC_ID_MP4ALS:  maxsamples /= 65536; break;
> >  case AV_CODEC_ID_MSA1:maxpixels  /= 16384; break;
> 
> please apply.

will apply

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If a bugfix only changes things apparently unrelated to the bug with no
further explanation, that is a good sign that the bugfix is wrong.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH v2 1/4] avformat/argo_cvg: name unk{1, 2} fields correctly

2022-07-20 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 libavformat/argo_cvg.c | 31 +++
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/libavformat/argo_cvg.c b/libavformat/argo_cvg.c
index f32487023a..be78091f0c 100644
--- a/libavformat/argo_cvg.c
+++ b/libavformat/argo_cvg.c
@@ -40,9 +40,9 @@
 #define ARGO_CVG_SAMPLES_PER_BLOCK  28
 
 typedef struct ArgoCVGHeader {
-uint32_t size; /*< File size -8 (this + trailing checksum) */
-uint32_t unk1; /*< Unknown. Always seems to be 0 or 1. */
-uint32_t unk2; /*< Unknown. Always seems to be 0 or 1. */
+uint32_t size;   /*< File size -8 (this + trailing checksum) */
+uint32_t loop;   /*< Loop flag. */
+uint32_t reverb; /*< Reverb flag. */
 } ArgoCVGHeader;
 
 typedef struct ArgoCVGOverride {
@@ -91,17 +91,17 @@ static int argo_cvg_probe(const AVProbeData *p)
 if (p->buf_size < ARGO_CVG_HEADER_SIZE)
 return 0;
 
-cvg.size = AV_RL32(p->buf + 0);
-cvg.unk1 = AV_RL32(p->buf + 4);
-cvg.unk2 = AV_RL32(p->buf + 8);
+cvg.size   = AV_RL32(p->buf + 0);
+cvg.loop   = AV_RL32(p->buf + 4);
+cvg.reverb = AV_RL32(p->buf + 8);
 
 if (cvg.size < 8)
 return 0;
 
-if (cvg.unk1 != 0 && cvg.unk1 != 1)
+if (cvg.loop != 0 && cvg.loop != 1)
 return 0;
 
-if (cvg.unk2 != 0 && cvg.unk2 != 1)
+if (cvg.reverb != 0 && cvg.reverb != 1)
 return 0;
 
 return AVPROBE_SCORE_MAX / 4 + 1;
@@ -150,15 +150,14 @@ static int argo_cvg_read_header(AVFormatContext *s)
 else if (ret != ARGO_CVG_HEADER_SIZE)
 return AVERROR(EIO);
 
-ctx->header.size = AV_RL32(buf + 0);
-ctx->header.unk1 = AV_RL32(buf + 4);
-ctx->header.unk2 = AV_RL32(buf + 8);
+ctx->header.size   = AV_RL32(buf + 0);
+ctx->header.loop   = AV_RL32(buf + 4);
+ctx->header.reverb = AV_RL32(buf + 8);
 
 if (ctx->header.size < 8)
 return AVERROR_INVALIDDATA;
 
 av_log(s, AV_LOG_TRACE, "size   = %u\n", ctx->header.size);
-av_log(s, AV_LOG_TRACE, "unk= %u, %u\n", ctx->header.unk1, 
ctx->header.unk2);
 
 if ((ret = argo_cvg_read_checksum(s->pb, &ctx->header, &ctx->checksum)) < 
0)
 return ret;
@@ -172,10 +171,10 @@ static int argo_cvg_read_header(AVFormatContext *s)
 
 for (size_t i = 0; i < FF_ARRAY_ELEMS(overrides); i++) {
 const ArgoCVGOverride *ovr = overrides + i;
-if (ovr->header.size != ctx->header.size ||
-ovr->header.unk1 != ctx->header.unk1 ||
-ovr->header.unk2 != ctx->header.unk2 ||
-ovr->checksum!= ctx->checksum||
+if (ovr->header.size   != ctx->header.size ||
+ovr->header.loop   != ctx->header.loop ||
+ovr->header.reverb != ctx->header.reverb ||
+ovr->checksum  != ctx->checksum||
 av_strcasecmp(filename, ovr->name) != 0)
 continue;
 
-- 
2.36.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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v2 4/4] avformat/argo_cvg: expose loop/reverb/checksum via metadata

2022-07-20 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 libavformat/argo_cvg.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/libavformat/argo_cvg.c b/libavformat/argo_cvg.c
index 12465dcbcc..3d4abb4758 100644
--- a/libavformat/argo_cvg.c
+++ b/libavformat/argo_cvg.c
@@ -162,6 +162,15 @@ static int argo_cvg_read_header(AVFormatContext *s)
 if ((ret = argo_cvg_read_checksum(s->pb, &ctx->header, &ctx->checksum)) < 
0)
 return ret;
 
+if (av_dict_set_int(&st->metadata, "loop", ctx->header.loop, 0) < 0)
+return AVERROR(ENOMEM);
+
+if (av_dict_set_int(&st->metadata, "reverb", ctx->header.reverb, 0) < 0)
+return AVERROR(ENOMEM);
+
+if (av_dict_set_int(&st->metadata, "checksum", ctx->checksum, 0) < 0)
+return AVERROR(ENOMEM);
+
 par = st->codecpar;
 par->codec_type = AVMEDIA_TYPE_AUDIO;
 par->codec_id   = AV_CODEC_ID_ADPCM_PSX;
-- 
2.36.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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v2 3/4] avformat/argo_cvg: remove trace logging

2022-07-20 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 libavformat/argo_cvg.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/libavformat/argo_cvg.c b/libavformat/argo_cvg.c
index 32247a06be..12465dcbcc 100644
--- a/libavformat/argo_cvg.c
+++ b/libavformat/argo_cvg.c
@@ -159,13 +159,9 @@ static int argo_cvg_read_header(AVFormatContext *s)
 if (ctx->header.size < 8)
 return AVERROR_INVALIDDATA;
 
-av_log(s, AV_LOG_TRACE, "size   = %u\n", ctx->header.size);
-
 if ((ret = argo_cvg_read_checksum(s->pb, &ctx->header, &ctx->checksum)) < 
0)
 return ret;
 
-av_log(s, AV_LOG_TRACE, "checksum   = %u\n", ctx->checksum);
-
 par = st->codecpar;
 par->codec_type = AVMEDIA_TYPE_AUDIO;
 par->codec_id   = AV_CODEC_ID_ADPCM_PSX;
-- 
2.36.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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v2 2/4] avformat/argo_cvg: add -loop and -reverb options

2022-07-20 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 libavformat/argo_cvg.c | 28 +---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/libavformat/argo_cvg.c b/libavformat/argo_cvg.c
index be78091f0c..32247a06be 100644
--- a/libavformat/argo_cvg.c
+++ b/libavformat/argo_cvg.c
@@ -62,6 +62,8 @@ typedef struct ArgoCVGDemuxContext {
 typedef struct ArgoCVGMuxContext {
 const AVClass *class;
 int   skip_rate_check;
+int   loop;
+int   reverb;
 uint32_t  checksum;
 size_tsize;
 } ArgoCVGMuxContext;
@@ -301,10 +303,10 @@ static int argo_cvg_write_header(AVFormatContext *s)
 ArgoCVGMuxContext *ctx = s->priv_data;
 
 avio_wl32(s->pb, 0); /* Size, fixed later. */
-avio_wl32(s->pb, 0);
-avio_wl32(s->pb, 1);
+avio_wl32(s->pb, !!ctx->loop);
+avio_wl32(s->pb, !!ctx->reverb);
 
-ctx->checksum = 1;
+ctx->checksum = !!ctx->loop + !!ctx->reverb;
 ctx->size = 8;
 return 0;
 }
@@ -363,6 +365,26 @@ static const AVOption argo_cvg_options[] = {
 .max = 1,
 .flags   = AV_OPT_FLAG_ENCODING_PARAM
 },
+{
+.name= "loop",
+.help= "set loop flag",
+.offset  = offsetof(ArgoCVGMuxContext, loop),
+.type= AV_OPT_TYPE_BOOL,
+.default_val = {.i64 = 0},
+.min = 0,
+.max = 1,
+.flags   = AV_OPT_FLAG_ENCODING_PARAM
+},
+{
+.name= "reverb",
+.help= "set reverb flag",
+.offset  = offsetof(ArgoCVGMuxContext, reverb),
+.type= AV_OPT_TYPE_BOOL,
+.default_val = {.i64 = 1},
+.min = 0,
+.max = 1,
+.flags   = AV_OPT_FLAG_ENCODING_PARAM
+},
 { NULL }
 };
 
-- 
2.36.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-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] RELEASE_NOTES: Based on the version from 5.0

2022-07-20 Thread Michael Niedermayer
On Sun, Jul 17, 2022 at 10:01:19AM +0200, Martijn van Beurden wrote:
> Op zo 17 jul. 2022 om 00:50 schreef Michael Niedermayer <
> mich...@niedermayer.cc>:
> 
> > ATM we have to maintain many releases because each is used by some  distro
> > the LTS designation might cause distros to coalescence onto fewer releases
> > This may also make life easier to distro maintainers
> >
> 
> Then maybe this can be placed in the release notes
> 
> +   The FFmpeg Project proudly presents FFmpeg 5.1 "Riemann" LTS, about 6
> +   months after the release of FFmpeg 5.0, our first Long Term Support
> +   release. While several past FFmpeg releases have enjoyed long term
> support,
> +   this is the first release where such an intention is made clear at
> release.

will apply with this change

thx
[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

"Nothing to hide" only works if the folks in power share the values of
you and everyone you know entirely and always will -- Tom Scott



signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] Live Transcoding: SCTE35 passthrough

2022-07-20 Thread Shane Warren
Thanks, I hand patched that back into a newer ffmpeg and with a few changes it 
worked great.

-Original Message-
From: ffmpeg-devel  On Behalf Of Devin 
Heitmueller
Sent: Tuesday, July 19, 2022 11:40 AM
To: FFmpeg development discussions and patches 
Subject: Re: [FFmpeg-devel] Live Transcoding: SCTE35 passthrough


On Tue, Jul 19, 2022 at 9:44 AM Shane Warren  wrote:
>
> I have been working on getting scte35 pass through working in FFmpeg. I have 
> the SIT pid being passed through fine, but I need to adjust the 
> pts_adjustment field since I'm doing a live transcode and using vsync 1.
>
> I'm struggling with finding how to match up an incoming frame of video to a 
> transcoded frame of video so I can figure out the pts adjustment. Am I 
> missing something, or is there some way to match up an incoming frame to a 
> encoded frame and figure out their pts difference?

I've got this working in a branch that isn't upstream.  This includes a BSF 
which deals with the pts_adjust field.  It should do what you need (although 
the branch point is a bit stale):

https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FLTNGlobal-opensource%2FFFmpeg-ltn%2Fcommits%2Fn4.3.1-scte35&data=05%7C01%7Cshanew%40innovsys.com%7C2fb835f6c03d4bf4ea9e08da69a564d0%7C7a48ce45ee974a95ac183390878a179b%7C0%7C0%7C637938456345483120%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=SJJDcJrCY3rHXNn9tzpQ3M5bj6Ey%2BUIepSIOYAZU49M%3D&reserved=0

If you're comfortable recompiling from source, you can incorporate a variant of 
these patches into your local tree.

Devin

--
Devin Heitmueller, Senior Software Engineer LTN Global Communications
o: +1 (301) 363-1001
w: 
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fltnglobal.com%2F&data=05%7C01%7Cshanew%40innovsys.com%7C2fb835f6c03d4bf4ea9e08da69a564d0%7C7a48ce45ee974a95ac183390878a179b%7C0%7C0%7C637938456345483120%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=1HYGR80ix2UDxPFGDPiuqE3EM%2Ba%2FDlvevbSy1IW2etU%3D&reserved=0
  e: devin.heitmuel...@ltnglobal.com 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fffmpeg.org%2Fmailman%2Flistinfo%2Fffmpeg-devel&data=05%7C01%7Cshanew%40innovsys.com%7C2fb835f6c03d4bf4ea9e08da69a564d0%7C7a48ce45ee974a95ac183390878a179b%7C0%7C0%7C637938456345483120%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=k6cbuARZH%2FtGrweYhtHuypy5TCyW%2BCDIq%2Fhftl3YxTE%3D&reserved=0

To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with 
subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH v2 1/3] hwcontext_vaapi: do not link against libva-x11.so

2022-07-20 Thread Emil Velikov
On Wed, 20 Jul 2022 at 11:56, Emil Velikov  wrote:
>
> From: Emil Velikov 
>
> There is an internal ABI between libva.so the libva-XXX.so libraries.
>
> With a recent change, the internal va_fool API was removed breaking the
> ABI. So if libva.so and libva-x11.so are from different version, the
> whole stack will crash.
>
> Instead we can dlopen() the libva-x11 library and gracefully error out.
>
> Signed-off-by: Emil Velikov 
> ---
> v2: add libdl dependency
> ---
>  configure   |  3 ++-
>  libavutil/hwcontext_vaapi.c | 34 +-
>  2 files changed, 35 insertions(+), 2 deletions(-)
>
> diff --git a/configure b/configure
> index 18d9b61a99..605afd58a7 100755
> --- a/configure
> +++ b/configure
> @@ -3816,7 +3816,8 @@ swscale_suggest="libm stdatomic"
>
>  avcodec_extralibs="pthreads_extralibs iconv_extralibs dxva2_extralibs"
>  avfilter_extralibs="pthreads_extralibs"
> -avutil_extralibs="d3d11va_extralibs nanosleep_extralibs pthreads_extralibs 
> vaapi_drm_extralibs vaapi_x11_extralibs vdpau_x11_extralibs"
> +avutil_deps="libdl"

Hmm, using _deps seems to be causing issues - "libdl at $avdevice_deps
is not at $LIBRARY_LIST".
In particular, due to the direct dependency between avutil and
avdevice, libdl gets propagated into avdevice_deps and libdl where not
part of $LIBRARY_LIST.

On the other hand, if we use avutil_deps_any libdl does not end up in
avdevice_deps (is this intentional), yet it looks incorrect. We're
providing a single entry in an "any" list, where we do need the
functionality.
Be that explicitly from libdl.so or implicitly from the C runtime.

Looking at all the other deps - perhaps deps_select is the best option
to use here?

Aside: Kicking off `make` after configure is changed does not trigger
[config.mak] regeneration. Is that intentional? All the other projects
that I've used do so.

Thanks in advance,
Emil
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH v2 0/3] hwcontext_vaapi: dlopen libva-x11 and libva-drm

2022-07-20 Thread Emil Velikov
On Tue, 19 Jul 2022 at 19:16, Nicolas George  wrote:
>
> Emil Velikov (12022-07-19):
> > As you may know the libva* set of libraries share an internal ABI
> > between them. In a resent libva commit, the va_fool API was removed.
> >
> > Thus if one is to mix different versions of libva.so and libva-x11.so
> > they will get an error, leading to a crash of the whole stack.
> >
> > The simple solution is
>
> ... a configure check.
>
> If the person who installs replaces a library with another, it is their
> responsibility to check they are compatible.
>

While I wholeheartedly agree, it's not so easy to enforce compile time
decisions at runtime. In the past, I have debugged and reported issues
where Linux distributions do not enforce the above.

We do have the typical Linux distribution model (where we have dozens
upon distros) and other distribution models. IMHO checking each
instance and combination doesn't scale. We could bring awareness to
the issue in say distribution/workflow X, which sadly may come as
finger-pointing and thus alienating.

Hope that makes sense and the team is willing to consider the extra 90
lines worth of code.

Thanks in advance
Emil
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH v2 0/8] ddagrab source filter, lavfi.c wrapped_avframe and dependent changes

2022-07-20 Thread Timo Rothenpieler

On 20/07/2022 10:21, Mark Himsley wrote:

On Tue, 19 Jul 2022 at 13:20, Timo Rothenpieler  wrote:


I added an explicit configure check for that type.
Definitely odd, IDXGIOutput5 and it are both Windows 10 APIs, so I'd
have expected them to always exist in tandem.


Thank you - that fixed the build for me.


You might want to update or repair your weird Windows SDK.


I thought x86_64-w64-mingw32 was quite standard.


You must have some rather old or odd version of it.
I've tested this patch with both the very latest self built version from 
git and with the one bundled in Ubuntu 22.04. (And with MSVC).


It worked in all of them.

Keep in mind that the Windows SDK used and the compiler toolchain are 
only loosely related, and can be mixed in various ways.


In any case, with the latest patch, this should hopefully work on all 
SDK versions (or not be compiled at all if support is missing) and not 
break backwards compat of the binary.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH v2 4/4] avformat/argo_cvg: expose loop/reverb/checksum via metadata

2022-07-20 Thread Andreas Rheinhardt
Zane van Iperen:
> Signed-off-by: Zane van Iperen 
> ---
>  libavformat/argo_cvg.c | 9 +
>  1 file changed, 9 insertions(+)
> 
> diff --git a/libavformat/argo_cvg.c b/libavformat/argo_cvg.c
> index 12465dcbcc..3d4abb4758 100644
> --- a/libavformat/argo_cvg.c
> +++ b/libavformat/argo_cvg.c
> @@ -162,6 +162,15 @@ static int argo_cvg_read_header(AVFormatContext *s)
>  if ((ret = argo_cvg_read_checksum(s->pb, &ctx->header, &ctx->checksum)) 
> < 0)
>  return ret;
>  
> +if (av_dict_set_int(&st->metadata, "loop", ctx->header.loop, 0) < 0)
> +return AVERROR(ENOMEM);
> +
> +if (av_dict_set_int(&st->metadata, "reverb", ctx->header.reverb, 0) < 0)
> +return AVERROR(ENOMEM);
> +
> +if (av_dict_set_int(&st->metadata, "checksum", ctx->checksum, 0) < 0)
> +return AVERROR(ENOMEM);
> +
>  par = st->codecpar;
>  par->codec_type = AVMEDIA_TYPE_AUDIO;
>  par->codec_id   = AV_CODEC_ID_ADPCM_PSX;

Don't second-guess error codes (unless you have a good reason to).

- Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 5/6] avcodec/ffv1dec: consider run increase in minimal golomb frame size

2022-07-20 Thread Andreas Rheinhardt
Michael Niedermayer:
> On Tue, Jul 19, 2022 at 08:37:38AM -0300, James Almer wrote:
>>
>>
>> On 7/19/2022 8:34 AM, Michael Niedermayer wrote:
>>> Fixes: Timeout
>>> Fixes: 
>>> 49160/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-5672826144686080
>>>
>>> Found-by: continuous fuzzing process 
>>> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
>>> Signed-off-by: Michael Niedermayer 
>>> ---
>>>   libavcodec/ffv1dec.c | 6 +-
>>>   1 file changed, 5 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
>>> index 01ddcaa512..9bdac0be4e 100644
>>> --- a/libavcodec/ffv1dec.c
>>> +++ b/libavcodec/ffv1dec.c
>>> @@ -883,7 +883,11 @@ static int decode_frame(AVCodecContext *avctx, AVFrame 
>>> *rframe,
>>>   if (buf_size < avctx->width * avctx->height / (128*8))
>>>   return AVERROR_INVALIDDATA;
>>>   } else {
>>> -if (buf_size < avctx->height / 8)
>>> +int i;
>>
>> for (int i...
> 
> will apply with that change
> 
> thx
> 

James' suggestion made you use an uninitialized i in the actual check;
and even the original check is wrong, as one can overrun ff_log2_run
(unless there is a check that I am not missing). So it seems to me that
reverting 15785e044ee1265464bb4f3ed727e2a8074f97b4 is appropriate.

- Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] avcodec/aacdec: remove skip samples multiplier

2022-07-20 Thread Andreas Rheinhardt
James Almer:
> The amount of padding samples reported by containers take into account the
> extended samplerate in HE-AAC.
> 
> Fixes ticket #9671.
> 
> Signed-off-by: James Almer 
> ---
>  libavcodec/aacdec_template.c | 3 ---
>  tests/ref/fate/audiomatch-afconvert-16000-mono-he-m4a| 2 +-
>  tests/ref/fate/audiomatch-afconvert-16000-stereo-he-m4a  | 2 +-
>  tests/ref/fate/audiomatch-afconvert-16000-stereo-he2-m4a | 2 +-
>  tests/ref/fate/audiomatch-afconvert-44100-mono-he-m4a| 2 +-
>  tests/ref/fate/audiomatch-afconvert-44100-stereo-he-m4a  | 2 +-
>  tests/ref/fate/audiomatch-afconvert-44100-stereo-he2-m4a | 2 +-
>  tests/ref/fate/audiomatch-nero-16000-mono-he-m4a | 2 +-
>  tests/ref/fate/audiomatch-nero-16000-stereo-he-m4a   | 2 +-
>  tests/ref/fate/audiomatch-nero-16000-stereo-he2-m4a  | 2 +-
>  tests/ref/fate/audiomatch-nero-44100-mono-he-m4a | 2 +-
>  tests/ref/fate/audiomatch-nero-44100-stereo-he-m4a   | 2 +-
>  tests/ref/fate/audiomatch-nero-44100-stereo-he2-m4a  | 2 +-
>  13 files changed, 12 insertions(+), 15 deletions(-)
> 
> diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
> index 10fba3d3b2..119976aa19 100644
> --- a/libavcodec/aacdec_template.c
> +++ b/libavcodec/aacdec_template.c
> @@ -3418,9 +3418,6 @@ static int aac_decode_frame_int(AVCodecContext *avctx, 
> AVFrame *frame,
>  ac->oc[1].status = OC_LOCKED;
>  }
>  
> -if (multiplier)
> -avctx->internal->skip_samples_multiplier = 2;

This is the only user of the skip_samples_multiplier field. If you
remove this, you should remove the field and its remaining redundant
occurrences.

> -
>  if (!ac->frame->data[0] && samples) {
>  av_log(avctx, AV_LOG_ERROR, "no frame data found\n");
>  err = AVERROR_INVALIDDATA;
> diff --git a/tests/ref/fate/audiomatch-afconvert-16000-mono-he-m4a 
> b/tests/ref/fate/audiomatch-afconvert-16000-mono-he-m4a
> index f6f8df5e00..b8fd03942c 100644
> --- a/tests/ref/fate/audiomatch-afconvert-16000-mono-he-m4a
> +++ b/tests/ref/fate/audiomatch-afconvert-16000-mono-he-m4a
> @@ -1 +1 @@
> -presig: 481 postsig:223 c: 0.9835 lenerr:704
> +presig: 1537 postsig:223 c: 0.9835 lenerr:1760
> diff --git a/tests/ref/fate/audiomatch-afconvert-16000-stereo-he-m4a 
> b/tests/ref/fate/audiomatch-afconvert-16000-stereo-he-m4a
> index 9ba0ef2338..b0381bfa0f 100644
> --- a/tests/ref/fate/audiomatch-afconvert-16000-stereo-he-m4a
> +++ b/tests/ref/fate/audiomatch-afconvert-16000-stereo-he-m4a
> @@ -1 +1 @@
> -presig: 962 postsig:446 c: 0.9895 lenerr:1408
> +presig: 3074 postsig:446 c: 0.9895 lenerr:3520
> diff --git a/tests/ref/fate/audiomatch-afconvert-16000-stereo-he2-m4a 
> b/tests/ref/fate/audiomatch-afconvert-16000-stereo-he2-m4a
> index d4fc21bda5..0b16a523f7 100644
> --- a/tests/ref/fate/audiomatch-afconvert-16000-stereo-he2-m4a
> +++ b/tests/ref/fate/audiomatch-afconvert-16000-stereo-he2-m4a
> @@ -1 +1 @@
> -presig: 962 postsig:446 c: 0.9839 lenerr:1408
> +presig: 3074 postsig:446 c: 0.9839 lenerr:3520
> diff --git a/tests/ref/fate/audiomatch-afconvert-44100-mono-he-m4a 
> b/tests/ref/fate/audiomatch-afconvert-44100-mono-he-m4a
> index 0ad4911ff8..34921ed8b5 100644
> --- a/tests/ref/fate/audiomatch-afconvert-44100-mono-he-m4a
> +++ b/tests/ref/fate/audiomatch-afconvert-44100-mono-he-m4a
> @@ -1 +1 @@
> -presig: 962 postsig:822 c: 0.9911 lenerr:1784
> +presig: 3074 postsig:822 c: 0.9911 lenerr:3896
> diff --git a/tests/ref/fate/audiomatch-afconvert-44100-stereo-he-m4a 
> b/tests/ref/fate/audiomatch-afconvert-44100-stereo-he-m4a
> index ff5540b572..3bab086939 100644
> --- a/tests/ref/fate/audiomatch-afconvert-44100-stereo-he-m4a
> +++ b/tests/ref/fate/audiomatch-afconvert-44100-stereo-he-m4a
> @@ -1 +1 @@
> -presig: 1924 postsig:1644 c: 0.9890 lenerr:3568
> +presig: 6148 postsig:1644 c: 0.9890 lenerr:7792
> diff --git a/tests/ref/fate/audiomatch-afconvert-44100-stereo-he2-m4a 
> b/tests/ref/fate/audiomatch-afconvert-44100-stereo-he2-m4a
> index f8214cfbdc..27341f54e2 100644
> --- a/tests/ref/fate/audiomatch-afconvert-44100-stereo-he2-m4a
> +++ b/tests/ref/fate/audiomatch-afconvert-44100-stereo-he2-m4a
> @@ -1 +1 @@
> -presig: 1924 postsig:1644 c: 0.9909 lenerr:3568
> +presig: 6148 postsig:1644 c: 0.9909 lenerr:7792
> diff --git a/tests/ref/fate/audiomatch-nero-16000-mono-he-m4a 
> b/tests/ref/fate/audiomatch-nero-16000-mono-he-m4a
> index 4ee764e967..fb62ae0c36 100644
> --- a/tests/ref/fate/audiomatch-nero-16000-mono-he-m4a
> +++ b/tests/ref/fate/audiomatch-nero-16000-mono-he-m4a
> @@ -1 +1 @@
> -presig: -4 postsig:196 c: 0.9736 lenerr:192
> +presig: 2332 postsig:196 c: 0.9736 lenerr:2528
> diff --git a/tests/ref/fate/audiomatch-nero-16000-stereo-he-m4a 
> b/tests/ref/fate/audiomatch-nero-16000-stereo-he-m4a
> index cdc31c12ef..4a30beca9d 100644
> --- a/tests/ref/fate/audiomatch-nero-16000-stereo-he-m4a
> +++ b/tests/ref/fate/audiomatch-nero-16000-stereo-he-m4a
> @@ -1 +1 @@
> -presig: -8 postsig:39

Re: [FFmpeg-devel] [PATCH v11 06/13] qsvenc: support multi-frame encode when MFX_VERSION < 2.0

2022-07-20 Thread Andreas Rheinhardt
Xiang, Haihao:
> From: Haihao Xiang 
> 
> Multi-frame encode isn't supported for MFX_VERSION >= 2.0[1][2]. This is
> in preparation for oneVPL support
> 
> [1] 
> https://spec.oneapi.io/versions/latest/elements/oneVPL/source/VPL_intel_media_sdk.html#msdk-full-name-feature-removals
> [2] https://github.com/oneapi-src/oneVPL
> ---
>  libavcodec/qsvenc.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
> index 4cadc38a59..40e2f65eff 100644
> --- a/libavcodec/qsvenc.h
> +++ b/libavcodec/qsvenc.h
> @@ -44,7 +44,7 @@
>  #else
>  #define QSV_HAVE_AVBR   0
>  #define QSV_HAVE_VCM0
> -#define QSV_HAVE_MF 1
> +#define QSV_HAVE_MF !QSV_ONEVPL
>  #endif
>  
>  #define QSV_COMMON_OPTS \

"support multi-frame encode when MFX_VERSION < 2.0" sounds as if you
were adding support for multi-frame encode. But the remaining commit
message makes it clear that you are actually restricting multi-frame
encode to MFX_VERSION < 2.0. So maybe you should reword the commit title
accordingly (some other commits in this patchset suffer from the same
defect).

- Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 5/6] avcodec/ffv1dec: consider run increase in minimal golomb frame size

2022-07-20 Thread Michael Niedermayer
On Thu, Jul 21, 2022 at 12:17:22AM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > On Tue, Jul 19, 2022 at 08:37:38AM -0300, James Almer wrote:
> >>
> >>
> >> On 7/19/2022 8:34 AM, Michael Niedermayer wrote:
> >>> Fixes: Timeout
> >>> Fixes: 
> >>> 49160/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-5672826144686080
> >>>
> >>> Found-by: continuous fuzzing process 
> >>> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> >>> Signed-off-by: Michael Niedermayer 
> >>> ---
> >>>   libavcodec/ffv1dec.c | 6 +-
> >>>   1 file changed, 5 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
> >>> index 01ddcaa512..9bdac0be4e 100644
> >>> --- a/libavcodec/ffv1dec.c
> >>> +++ b/libavcodec/ffv1dec.c
> >>> @@ -883,7 +883,11 @@ static int decode_frame(AVCodecContext *avctx, 
> >>> AVFrame *rframe,
> >>>   if (buf_size < avctx->width * avctx->height / (128*8))
> >>>   return AVERROR_INVALIDDATA;
> >>>   } else {
> >>> -if (buf_size < avctx->height / 8)
> >>> +int i;
> >>
> >> for (int i...
> > 
> > will apply with that change
> > 
> > thx
> > 
> 
> James' suggestion made you use an uninitialized i in the actual check;

yes


> and even the original check is wrong, as one can overrun ff_log2_run
> (unless there is a check that I am not missing). 

Theres a check but its too late


> So it seems to me that
> reverting 15785e044ee1265464bb4f3ed727e2a8074f97b4 is appropriate.

not against that but heres a quick fix attempt


Author: Michael Niedermayer 
Date:   Thu Jul 21 00:20:41 2022 +0200

avcodec/ffv1dec: Fix AC_GOLOMB_RICE min size check

Found-by: mkver

Signed-off-by: Michael Niedermayer 

diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
index d71584505d..c6eca3227c 100644
--- a/libavcodec/ffv1dec.c
+++ b/libavcodec/ffv1dec.c
@@ -884,9 +884,14 @@ static int decode_frame(AVCodecContext *avctx, AVFrame 
*rframe,
 return AVERROR_INVALIDDATA;
 } else {
 int w = avctx->width;
-for (int i = 0; w > (1< (1height + s*i + 6)/ 8)
 return AVERROR_INVALIDDATA;
 }
 
 

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 2
"100% positive feedback" - "All either got their money back or didnt complain"
"Best seller ever, very honest" - "Seller refunded buyer after failed scam"


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH v2 1/5] avfilter/vf_yadif: Fix edge size when MAX_ALIGN is < 4

2022-07-20 Thread Chris Phlipot
If alignment is set to less than 4 filter_edges will produce incorrect
output and not filter the entire edge. To fix this, make sure that
the edge size is at least 3.

Signed-off-by: Chris Phlipot 
---
 libavfilter/vf_yadif.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c
index afa4d1d53d..055327d7a4 100644
--- a/libavfilter/vf_yadif.c
+++ b/libavfilter/vf_yadif.c
@@ -120,7 +120,7 @@ static void filter_edges(void *dst1, void *prev1, void 
*cur1, void *next1,
 uint8_t *prev2 = parity ? prev : cur ;
 uint8_t *next2 = parity ? cur  : next;
 
-const int edge = MAX_ALIGN - 1;
+const int edge = FFMAX(MAX_ALIGN - 1, 3);
 int offset = FFMAX(w - edge, 3);
 
 /* Only edge pixels need to be processed here.  A constant value of false
@@ -169,7 +169,7 @@ static void filter_edges_16bit(void *dst1, void *prev1, 
void *cur1, void *next1,
 uint16_t *prev2 = parity ? prev : cur ;
 uint16_t *next2 = parity ? cur  : next;
 
-const int edge = MAX_ALIGN / 2 - 1;
+const int edge = FFMAX(MAX_ALIGN / 2 - 1, 3);
 int offset = FFMAX(w - edge, 3);
 
 mrefs /= 2;
-- 
2.25.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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v2 2/5] avfilter/vf_yadif: Allow alignment to be configurable

2022-07-20 Thread Chris Phlipot
Allow the alignment to be determined based on what yadif_filter_line
implementation is used. Currently this is either 1, or 8 depending
on whether the C code or the x86 SSE code is used, but allows for
other future implementations that use a larger alignment.

Adjusting MAX_ALIGN to 32 in the case of an AVX2 implementation
could potentially hurt the performance of the SSE implementation,
so we allow yadif to use the smallest needed alignment instead to
maintain existing performance if implementations with wider vectors
are added.

Signed-off-by: Chris Phlipot 
---
 libavfilter/vf_yadif.c  | 16 +---
 libavfilter/x86/vf_yadif_init.c |  1 +
 libavfilter/yadif.h |  4 +++-
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c
index 055327d7a4..42f6246330 100644
--- a/libavfilter/vf_yadif.c
+++ b/libavfilter/vf_yadif.c
@@ -108,9 +108,9 @@ static void filter_line_c(void *dst1,
 FILTER(0, w, 1)
 }
 
-#define MAX_ALIGN 8
 static void filter_edges(void *dst1, void *prev1, void *cur1, void *next1,
- int w, int prefs, int mrefs, int parity, int mode)
+ int w, int prefs, int mrefs, int parity, int mode,
+ int alignment)
 {
 uint8_t *dst  = dst1;
 uint8_t *prev = prev1;
@@ -120,7 +120,7 @@ static void filter_edges(void *dst1, void *prev1, void 
*cur1, void *next1,
 uint8_t *prev2 = parity ? prev : cur ;
 uint8_t *next2 = parity ? cur  : next;
 
-const int edge = FFMAX(MAX_ALIGN - 1, 3);
+const int edge = FFMAX(alignment - 1, 3);
 int offset = FFMAX(w - edge, 3);
 
 /* Only edge pixels need to be processed here.  A constant value of false
@@ -159,7 +159,8 @@ static void filter_line_c_16bit(void *dst1,
 }
 
 static void filter_edges_16bit(void *dst1, void *prev1, void *cur1, void 
*next1,
-   int w, int prefs, int mrefs, int parity, int 
mode)
+   int w, int prefs, int mrefs, int parity, int 
mode,
+   int alignment)
 {
 uint16_t *dst  = dst1;
 uint16_t *prev = prev1;
@@ -169,7 +170,7 @@ static void filter_edges_16bit(void *dst1, void *prev1, 
void *cur1, void *next1,
 uint16_t *prev2 = parity ? prev : cur ;
 uint16_t *next2 = parity ? cur  : next;
 
-const int edge = FFMAX(MAX_ALIGN / 2 - 1, 3);
+const int edge = FFMAX(alignment / 2 - 1, 3);
 int offset = FFMAX(w - edge, 3);
 
 mrefs /= 2;
@@ -199,7 +200,7 @@ static int filter_slice(AVFilterContext *ctx, void *arg, 
int jobnr, int nb_jobs)
 int slice_start = (td->h *  jobnr   ) / nb_jobs;
 int slice_end   = (td->h * (jobnr+1)) / nb_jobs;
 int y;
-int edge = 3 + MAX_ALIGN / df - 1;
+int edge = 3 + s->req_align / df - 1;
 
 /* filtering reads 3 pixels to the left/right; to avoid invalid reads,
  * we need to call the c variant which avoids this for border pixels
@@ -219,7 +220,7 @@ static int filter_slice(AVFilterContext *ctx, void *arg, 
int jobnr, int nb_jobs)
 s->filter_edges(dst, prev, cur, next, td->w,
 y + 1 < td->h ? refs : -refs,
 y ? -refs : refs,
-td->parity ^ td->tff, mode);
+td->parity ^ td->tff, mode, s->req_align);
 } else {
 memcpy(&td->frame->data[td->plane][y * 
td->frame->linesize[td->plane]],
&s->cur->data[td->plane][y * refs], td->w * df);
@@ -303,6 +304,7 @@ static int config_output(AVFilterLink *outlink)
 
 s->csp = av_pix_fmt_desc_get(outlink->format);
 s->filter = filter;
+s->req_align = 1;
 if (s->csp->comp[0].depth > 8) {
 s->filter_line  = filter_line_c_16bit;
 s->filter_edges = filter_edges_16bit;
diff --git a/libavfilter/x86/vf_yadif_init.c b/libavfilter/x86/vf_yadif_init.c
index 257c3f9199..9dd73f8e44 100644
--- a/libavfilter/x86/vf_yadif_init.c
+++ b/libavfilter/x86/vf_yadif_init.c
@@ -53,6 +53,7 @@ av_cold void ff_yadif_init_x86(YADIFContext *yadif)
 int bit_depth = (!yadif->csp) ? 8
   : yadif->csp->comp[0].depth;
 
+yadif->req_align = 8;
 if (bit_depth >= 15) {
 if (EXTERNAL_SSE2(cpu_flags))
 yadif->filter_line = ff_yadif_filter_line_16bit_sse2;
diff --git a/libavfilter/yadif.h b/libavfilter/yadif.h
index c928911b35..b81f2fc1d9 100644
--- a/libavfilter/yadif.h
+++ b/libavfilter/yadif.h
@@ -66,11 +66,13 @@ typedef struct YADIFContext {
 /**
  * Required alignment for filter_line
  */
+int req_align;
 void (*filter_line)(void *dst,
 void *prev, void *cur, void *next,
 int w, int prefs, int mrefs, int parity, int mode);
 void (*filter_edges)(void *dst, void *prev, void *cur, void *next,
- int w, int prefs, int mrefs, int parity, int mode);
+

[FFmpeg-devel] [PATCH v2 3/5] avfilter/vf_yadif: reformat code to improve readability

2022-07-20 Thread Chris Phlipot
Reformat some of the code to improve readability and reduce code
duplication. This change is intended to be purely cosmentic and
shouldn't result in any functional changes.

Signed-off-by: Chris Phlipot 
---
 libavfilter/vf_yadif.c | 11 +--
 libavfilter/yadif.h|  3 +--
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c
index 42f6246330..54109566be 100644
--- a/libavfilter/vf_yadif.c
+++ b/libavfilter/vf_yadif.c
@@ -211,16 +211,15 @@ static int filter_slice(AVFilterContext *ctx, void *arg, 
int jobnr, int nb_jobs)
 uint8_t *cur  = &s->cur ->data[td->plane][y * refs];
 uint8_t *next = &s->next->data[td->plane][y * refs];
 uint8_t *dst  = &td->frame->data[td->plane][y * 
td->frame->linesize[td->plane]];
+int prefs = y + 1 < td->h ? refs : -refs;
+int mrefs = y ? -refs : refs;
+intparity = td->parity ^ td->tff;
 int mode  = y == 1 || y + 2 == td->h ? 2 : s->mode;
 s->filter_line(dst + pix_3, prev + pix_3, cur + pix_3,
next + pix_3, td->w - edge,
-   y + 1 < td->h ? refs : -refs,
-   y ? -refs : refs,
-   td->parity ^ td->tff, mode);
+   prefs, mrefs, parity, mode);
 s->filter_edges(dst, prev, cur, next, td->w,
-y + 1 < td->h ? refs : -refs,
-y ? -refs : refs,
-td->parity ^ td->tff, mode, s->req_align);
+prefs, mrefs, parity, mode, s->req_align);
 } else {
 memcpy(&td->frame->data[td->plane][y * 
td->frame->linesize[td->plane]],
&s->cur->data[td->plane][y * refs], td->w * df);
diff --git a/libavfilter/yadif.h b/libavfilter/yadif.h
index b81f2fc1d9..f271fe8304 100644
--- a/libavfilter/yadif.h
+++ b/libavfilter/yadif.h
@@ -67,8 +67,7 @@ typedef struct YADIFContext {
  * Required alignment for filter_line
  */
 int req_align;
-void (*filter_line)(void *dst,
-void *prev, void *cur, void *next,
+void (*filter_line)(void *dst, void *prev, void *cur, void *next,
 int w, int prefs, int mrefs, int parity, int mode);
 void (*filter_edges)(void *dst, void *prev, void *cur, void *next,
  int w, int prefs, int mrefs, int parity, int mode,
-- 
2.25.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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v2 4/5] avfilter/vf_yadif: Process more pixels using filter_line

2022-07-20 Thread Chris Phlipot
filter_line is generally vectorized, wheras filter_edge is implemented
in C. Currently we rely on filter_edge to process non-edges in cases
where the width doesn't match the alignment. This causes us to process
non-edge pixels with the slow C implementation vs the faster SSE
implementation.

It is generally faster to process 8 pixels with the slowest SSE2
vectorized implementation than it is to process 2 pixels with the
C implementation. Therefore, if filter_edge needs to process 2 or
more non-edge pixels, it would be faster to process these non-edge
pixels with filter_line instead even if it processes more pixels
than necessary.

To address this, we use filter_line so long as we know that at least
2 pixels will be used in the final output even if the rest of the
computed pixels are invalid. Any incorrect output pixels generated by
filter_line will be overwritten by the following call to filter_edge.
In addtion we avoid running filter_line if it would read or write
pixels outside the current slice.

Signed-off-by: Chris Phlipot 
---
 libavfilter/vf_yadif.c | 23 +--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c
index 54109566be..394c04a985 100644
--- a/libavfilter/vf_yadif.c
+++ b/libavfilter/vf_yadif.c
@@ -201,6 +201,8 @@ static int filter_slice(AVFilterContext *ctx, void *arg, 
int jobnr, int nb_jobs)
 int slice_end   = (td->h * (jobnr+1)) / nb_jobs;
 int y;
 int edge = 3 + s->req_align / df - 1;
+int filter_width_target = td->w - 3;
+int filter_width_rounded_up = (filter_width_target & ~(s->req_align-1)) + 
s->req_align;
 
 /* filtering reads 3 pixels to the left/right; to avoid invalid reads,
  * we need to call the c variant which avoids this for border pixels
@@ -215,11 +217,28 @@ static int filter_slice(AVFilterContext *ctx, void *arg, 
int jobnr, int nb_jobs)
 int mrefs = y ? -refs : refs;
 intparity = td->parity ^ td->tff;
 int mode  = y == 1 || y + 2 == td->h ? 2 : s->mode;
+
+/* Adjust width and alignment to process extra pixels in 
filter_line
+ * using potentially vectorized code so long as it doesn't cause
+ * reads or writes outside of the current slice. filter_edge will
+ * correct any incorrect pixels written by filter_line in this
+ * scenario.
+ */
+int filter_width;
+int edge_alignment;
+if (filter_width_rounded_up - filter_width_target >= 2
+&& y*refs + filter_width_rounded_up < slice_end * refs + refs 
- 3) {
+filter_width = filter_width_rounded_up;
+edge_alignment = 1;
+} else {
+filter_width = td->w - edge;
+edge_alignment = s->req_align;
+}
 s->filter_line(dst + pix_3, prev + pix_3, cur + pix_3,
-   next + pix_3, td->w - edge,
+   next + pix_3, filter_width,
prefs, mrefs, parity, mode);
 s->filter_edges(dst, prev, cur, next, td->w,
-prefs, mrefs, parity, mode, s->req_align);
+prefs, mrefs, parity, mode, edge_alignment);
 } else {
 memcpy(&td->frame->data[td->plane][y * 
td->frame->linesize[td->plane]],
&s->cur->data[td->plane][y * refs], td->w * df);
-- 
2.25.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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v2 5/5] avfilter/vf_yadif: Add x86_64 avx yadif asm

2022-07-20 Thread Chris Phlipot
Add a new version of yadif_filter_line performed using packed bytes
instead of the packed words used by the current implementaiton. As
a result this implementation runs almost 2x as fast as the current
fastest SSSE3 implementation.

This implementation is created from scratch based on the C code, with
the goal of keeping all intermediate values within 8-bits so that
the vectorized code can be computed using packed bytes. differences
are as follows:
- Use algorithms to compute avg and abs difference using only 8-bit
 intermediate values.
- Reworked the mode 1 code by applying various mathematical identities
 to keep all intermediate values within 8-bits.
- Attempt to compute the spatial score using only 8-bits. The actual
 spatial score fits within this range 97% (content dependent) of the
 time for the entire 128-bit xmm vector. In the case that spatial
 score needs more than 8-bits to be represented, we detect this case,
 and recompute the spatial score using 16-bit packed words instead.

In 3% of cases the spatial_score will need more than 8-bytes to store
so we have a slow path, where the spatial score is computed using
packed words instead.

This implementation is currently limited to x86_64 due to the number
of registers required. x86_32 is possible, but the performance benefit
over the existing SSSE3 implentation is not as great, due to all of the
stack spills that would result from having far fewer registers. ASM was
not generated for the 32-bit varient due to limited ROI, as most AVX
users are likely on 64-bit OS at this point and 32-bit users would
lose out on most of the performance benefit.

Signed-off-by: Chris Phlipot 
---
 libavfilter/x86/Makefile |   2 +-
 libavfilter/x86/vf_yadif_init.c  |  11 +
 libavfilter/x86/vf_yadif_x64.asm | 492 +++
 3 files changed, 504 insertions(+), 1 deletion(-)
 create mode 100644 libavfilter/x86/vf_yadif_x64.asm

diff --git a/libavfilter/x86/Makefile b/libavfilter/x86/Makefile
index e87481bd7a..19161ffa23 100644
--- a/libavfilter/x86/Makefile
+++ b/libavfilter/x86/Makefile
@@ -80,4 +80,4 @@ X86ASM-OBJS-$(CONFIG_TRANSPOSE_FILTER)   += 
x86/vf_transpose.o
 X86ASM-OBJS-$(CONFIG_VOLUME_FILTER)  += x86/af_volume.o
 X86ASM-OBJS-$(CONFIG_V360_FILTER)+= x86/vf_v360.o
 X86ASM-OBJS-$(CONFIG_W3FDIF_FILTER)  += x86/vf_w3fdif.o
-X86ASM-OBJS-$(CONFIG_YADIF_FILTER)   += x86/vf_yadif.o x86/yadif-16.o 
x86/yadif-10.o
+X86ASM-OBJS-$(CONFIG_YADIF_FILTER)   += x86/vf_yadif.o 
x86/vf_yadif_x64.o x86/yadif-16.o x86/yadif-10.o
diff --git a/libavfilter/x86/vf_yadif_init.c b/libavfilter/x86/vf_yadif_init.c
index 9dd73f8e44..1369081690 100644
--- a/libavfilter/x86/vf_yadif_init.c
+++ b/libavfilter/x86/vf_yadif_init.c
@@ -29,6 +29,11 @@ void ff_yadif_filter_line_sse2(void *dst, void *prev, void 
*cur,
 void ff_yadif_filter_line_ssse3(void *dst, void *prev, void *cur,
 void *next, int w, int prefs,
 int mrefs, int parity, int mode);
+#if ARCH_X86_64
+void ff_yadif_filter_line_avx(void *dst, void *prev, void *cur,
+  void *next, int w, int prefs,
+  int mrefs, int parity, int mode);
+#endif
 
 void ff_yadif_filter_line_16bit_sse2(void *dst, void *prev, void *cur,
  void *next, int w, int prefs,
@@ -71,5 +76,11 @@ av_cold void ff_yadif_init_x86(YADIFContext *yadif)
 yadif->filter_line = ff_yadif_filter_line_sse2;
 if (EXTERNAL_SSSE3(cpu_flags))
 yadif->filter_line = ff_yadif_filter_line_ssse3;
+#if ARCH_X86_64
+if (EXTERNAL_AVX(cpu_flags)) {
+yadif->filter_line = ff_yadif_filter_line_avx;
+yadif->req_align = 16;
+}
+#endif
 }
 }
diff --git a/libavfilter/x86/vf_yadif_x64.asm b/libavfilter/x86/vf_yadif_x64.asm
new file mode 100644
index 00..c7e236ade7
--- /dev/null
+++ b/libavfilter/x86/vf_yadif_x64.asm
@@ -0,0 +1,492 @@
+;**
+;* Copyright (C) 2006-2011 Michael Niedermayer 
+;*   2010  James Darnley 
+;*   2013-2022 Chris Phlipot 
+;*
+;* This file is part of FFmpeg.
+;*
+;* FFmpeg is free software;* you can redistribute it and/or
+;* modify it under the terms of the GNU Lesser General Public
+;* License as published by the Free Software Foundation;* either
+;* version 2.1 of the License, or (at your option) any later version.
+;*
+;* FFmpeg is distributed in the hope that it will be useful,
+;* but WITHOUT ANY WARRANTY; without even the implied warranty of
+;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;* Lesser General Public License for more details.
+;*
+;* You should have received a copy of the GNU Lesser General Public
+;* License along with FFmpeg; if not, write to the Free Software
+;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston

Re: [FFmpeg-devel] [PATCH 5/5] avfilter/vf_yadif: Add x86_64 avx yadif asm

2022-07-20 Thread Chris Phlipot
Thanks for calling that out. It looks like I was cross-compiling for 32-bit
incorrectly from my 64-bit host. I've reproduced the failure and submitted
a v2 with the fix. If you're still seeing build failures even after v2, can
you also provide more details on how you are building so I can reproduce
and fix?
- Chris

On Wed, Jul 20, 2022 at 6:17 AM Michael Niedermayer 
wrote:

> On Tue, Jul 19, 2022 at 09:41:17PM -0700, Chris Phlipot wrote:
> > Add a new version of yadif_filter_line performed using packed bytes
> > instead of the packed words used by the current implementaiton. As
> > a result this implementation runs almost 2x as fast as the current
> > fastest SSSE3 implementation.
> >
> > This implementation is created from scratch based on the C code, with
> > the goal of keeping all intermediate values within 8-bits so that
> > the vectorized code can be computed using packed bytes. differences
> > are as follows:
> > - Use algorithms to compute avg and abs difference using only 8-bit
> >  intermediate values.
> > - Reworked the mode 1 code by applying various mathematical identities
> >  to keep all intermediate values within 8-bits.
> > - Attempt to compute the spatial score using only 8-bits. The actual
> >  spatial score fits within this range 97% (content dependent) of the
> >  time for the entire 128-bit xmm vector. In the case that spatial
> >  score needs more than 8-bits to be represented, we detect this case,
> >  and recompute the spatial score using 16-bit packed words instead.
> >
> > In 3% of cases the spatial_score will need more than 8-bytes to store
> > so we have a slow path, where the spatial score is computed using
> > packed words instead.
> >
> > This implementation is currently limited to x86_64 due to the number
> > of registers required. x86_32 is possible, but the performance benefit
> > over the existing SSSE3 implentation is not as great, due to all of the
> > stack spills that would result from having far fewer registers. ASM was
> > not generated for the 32-bit varient due to limited ROI, as most AVX
> > users are likely on 64-bit OS at this point and 32-bit users would
> > lose out on most of the performance benefit.
> >
> > Signed-off-by: Chris Phlipot 
>
> theres no need to support 32it but ffmpeg build must not break
> on linux x86-32
>
> src/libavfilter/x86/vf_yadif_x64.asm:145: error: impossible combination of
> address sizes
> src/libavfilter/x86/vf_yadif_x64.asm:145: error: invalid effective address
> src/libavfilter/x86/vf_yadif_x64.asm:146: error: impossible combination of
> address sizes
> src//libavutil/x86/x86inc.asm:1399: ... from macro `movdqu' defined here
> src//libavutil/x86/x86inc.asm:1264: ... from macro `RUN_AVX_INSTR' defined
> here
> src//libavutil/x86/x86inc.asm:1717: ... from macro `vmovdqu' defined here
>
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Everything should be made as simple as possible, but not simpler.
> -- Albert Einstein
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH v11 06/13] qsvenc: support multi-frame encode when MFX_VERSION < 2.0

2022-07-20 Thread Xiang, Haihao
On Thu, 2022-07-21 at 00:45 +0200, Andreas Rheinhardt wrote:
> Xiang, Haihao:
> > From: Haihao Xiang 
> > 
> > Multi-frame encode isn't supported for MFX_VERSION >= 2.0[1][2]. This is
> > in preparation for oneVPL support
> > 
> > [1] 
> > https://spec.oneapi.io/versions/latest/elements/oneVPL/source/VPL_intel_media_sdk.html#msdk-full-name-feature-removals
> > [2] https://github.com/oneapi-src/oneVPL
> > ---
> >  libavcodec/qsvenc.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
> > index 4cadc38a59..40e2f65eff 100644
> > --- a/libavcodec/qsvenc.h
> > +++ b/libavcodec/qsvenc.h
> > @@ -44,7 +44,7 @@
> >  #else
> >  #define QSV_HAVE_AVBR   0
> >  #define QSV_HAVE_VCM0
> > -#define QSV_HAVE_MF 1
> > +#define QSV_HAVE_MF !QSV_ONEVPL
> >  #endif
> >  
> >  #define QSV_COMMON_OPTS \
> 
> "support multi-frame encode when MFX_VERSION < 2.0" sounds as if you
> were adding support for multi-frame encode. But the remaining commit
> message makes it clear that you are actually restricting multi-frame
> encode to MFX_VERSION < 2.0. So maybe you should reword the commit title
> accordingly (some other commits in this patchset suffer from the same
> defect).
> 

Thanks, I'll update the log in the next version.

-Haihao

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 5/6] avcodec/ffv1dec: consider run increase in minimal golomb frame size

2022-07-20 Thread Michael Niedermayer
On Thu, Jul 21, 2022 at 12:46:38AM +0200, Michael Niedermayer wrote:
> On Thu, Jul 21, 2022 at 12:17:22AM +0200, Andreas Rheinhardt wrote:
> > Michael Niedermayer:
> > > On Tue, Jul 19, 2022 at 08:37:38AM -0300, James Almer wrote:
> > >>
> > >>
> > >> On 7/19/2022 8:34 AM, Michael Niedermayer wrote:
> > >>> Fixes: Timeout
> > >>> Fixes: 
> > >>> 49160/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-5672826144686080
> > >>>
> > >>> Found-by: continuous fuzzing process 
> > >>> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > >>> Signed-off-by: Michael Niedermayer 
> > >>> ---
> > >>>   libavcodec/ffv1dec.c | 6 +-
> > >>>   1 file changed, 5 insertions(+), 1 deletion(-)
> > >>>
> > >>> diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
> > >>> index 01ddcaa512..9bdac0be4e 100644
> > >>> --- a/libavcodec/ffv1dec.c
> > >>> +++ b/libavcodec/ffv1dec.c
> > >>> @@ -883,7 +883,11 @@ static int decode_frame(AVCodecContext *avctx, 
> > >>> AVFrame *rframe,
> > >>>   if (buf_size < avctx->width * avctx->height / (128*8))
> > >>>   return AVERROR_INVALIDDATA;
> > >>>   } else {
> > >>> -if (buf_size < avctx->height / 8)
> > >>> +int i;
> > >>
> > >> for (int i...
> > > 
> > > will apply with that change
> > > 
> > > thx
> > > 
> > 
> > James' suggestion made you use an uninitialized i in the actual check;
> 
> yes
> 
> 
> > and even the original check is wrong, as one can overrun ff_log2_run
> > (unless there is a check that I am not missing). 
> 
> Theres a check but its too late
> 
> 
> > So it seems to me that
> > reverting 15785e044ee1265464bb4f3ed727e2a8074f97b4 is appropriate.
> 
> not against that but heres a quick fix attempt
> 
> 
> Author: Michael Niedermayer 
> Date:   Thu Jul 21 00:20:41 2022 +0200
> 
> avcodec/ffv1dec: Fix AC_GOLOMB_RICE min size check

will apply this so the uninitialized read is fixed. If this has
some off by 1 error or something that can be adjusted later
dont want to leave this bug open

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No great genius has ever existed without some touch of madness. -- Aristotle


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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