Re: [FFmpeg-devel] [PATCH v3 1/4] lavc/hevc_refs: fix dpb logical for IRAP

2022-07-24 Thread Xiang, Haihao
On Mon, 2022-07-18 at 09:09 +, Xiang, Haihao wrote:
> On Fri, 2022-07-15 at 13:06 +0800, Fei Wang wrote:
> > From: Xu Guangxin 
> > 
> > According to C.5.2.2, item 2. When we got an IRAP, and the
> > NoOutputOfPriorPicsFlag = 0, we need bump all outputable frames.
> > 
> > Tested-by: Fei Wang 
> > Signed-off-by: Xu Guangxin 
> > ---
> > update:
> > 1. clean and replace 0xff with HEVC_SEQUENCE_COUNTER_MASK
> > 
> >  libavcodec/hevc_refs.c | 23 +--
> >  1 file changed, 13 insertions(+), 10 deletions(-)
> > 
> > diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
> > index 6a70c817b0..2b0468d6c4 100644
> > --- a/libavcodec/hevc_refs.c
> > +++ b/libavcodec/hevc_refs.c
> > @@ -175,21 +175,24 @@ int ff_hevc_set_new_ref(HEVCContext *s, AVFrame
> > **frame,
> > int poc)
> >  
> >  int ff_hevc_output_frame(HEVCContext *s, AVFrame *out, int flush)
> >  {
> > +if (IS_IRAP(s) && s->no_rasl_output_flag == 1) {
> > +const static int mask = HEVC_FRAME_FLAG_BUMPING |
> > HEVC_FRAME_FLAG_OUTPUT;
> > +for (int i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
> > +HEVCFrame *frame = >DPB[i];
> > +if ((frame->flags & mask) == HEVC_FRAME_FLAG_OUTPUT &&
> > +frame->sequence != s->seq_decode) {
> > +if (s->sh.no_output_of_prior_pics_flag == 1)
> > +ff_hevc_unref_frame(s, frame, HEVC_FRAME_FLAG_OUTPUT);
> > +else
> > +frame->flags |= HEVC_FRAME_FLAG_BUMPING;
> > +}
> > +}
> > +}
> >  do {
> >  int nb_output = 0;
> >  int min_poc   = INT_MAX;
> >  int i, min_idx, ret;
> >  
> > -if (s->sh.no_output_of_prior_pics_flag == 1 && s-
> > >no_rasl_output_flag 
> > == 1) {
> > -for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
> > -HEVCFrame *frame = >DPB[i];
> > -if (!(frame->flags & HEVC_FRAME_FLAG_BUMPING) && frame->poc
> > != s->poc &&
> > -frame->sequence == s->seq_output) {
> > -ff_hevc_unref_frame(s, frame, HEVC_FRAME_FLAG_OUTPUT);
> > -}
> > -}
> > -}
> > -
> >  for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
> >  HEVCFrame *frame = >DPB[i];
> >  if ((frame->flags & HEVC_FRAME_FLAG_OUTPUT) &&
> 
> Patchset LGTM. 
> 

The patchset works well for me. Are there any more comments here ? If not, I'll
apply this patchset in a few days.

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


[FFmpeg-devel] [PATCH v3 2/2] ffmpeg_opt: consider HW acceleration method when selecting decoder

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

Usually a HW decoder is expected when user specifies a HW acceleration
method via -hwaccel option, however the current implementation doesn't
take HW acceleration method into account, it is possible to select a SW
decoder.

For example:
$ ffmpeg -hwaccel vaapi -i av1.mp4 -f null -
$ ffmpeg -hwaccel nvdec -i av1.mp4 -f null -
$ ffmpeg -hwaccel vdpau -i av1.mp4 -f null -
[...]
Stream #0:0 -> #0:0 (av1 (libdav1d) -> wrapped_avframe (native))

libdav1d is selected in this case even if vaapi, nvdec or vdpau is
specified.

After applying this patch, the native av1 decoder (with vaapi, nvdec or
vdpau support) is selected for decoding(libdav1d is still used for
probing format).
$ ffmpeg -hwaccel vaapi -i av1.mp4 -f null -
$ ffmpeg -hwaccel nvdec -i av1.mp4 -f null -
$ ffmpeg -hwaccel vdpau -i av1.mp4 -f null -
[...]
Stream #0:0 -> #0:0 (av1 (native) -> wrapped_avframe (native))

Tested-by: Mario Roy 
Signed-off-by: Haihao Xiang 
---
 fftools/ffmpeg_opt.c | 44 +++-
 1 file changed, 43 insertions(+), 1 deletion(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 2771c5d993..614bfeea80 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -861,6 +861,48 @@ static const AVCodec *choose_decoder(OptionsContext *o, 
AVFormatContext *s, AVSt
 return avcodec_find_decoder(st->codecpar->codec_id);
 }
 
+static const AVCodec *choose_decoder2(InputStream *ist, OptionsContext *o, 
AVFormatContext *s, AVStream *st)
+{
+char *codec_name = NULL;
+
+MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, st);
+if (codec_name) {
+const AVCodec *codec = find_codec_or_die(codec_name, 
st->codecpar->codec_type, 0);
+st->codecpar->codec_id = codec->id;
+if (recast_media && st->codecpar->codec_type != codec->type)
+st->codecpar->codec_type = codec->type;
+return codec;
+} else {
+if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
+ist->hwaccel_id == HWACCEL_GENERIC &&
+ist->hwaccel_device_type != AV_HWDEVICE_TYPE_NONE) {
+const AVCodec *p;
+void *i = 0;
+
+while ((p = av_codec_iterate())) {
+int j;
+
+if (p->id != st->codecpar->codec_id ||
+!av_codec_is_decoder(p) ||
+!avcodec_get_hw_config(p, 0))
+continue;
+
+for (j = 0; ;j++) {
+const AVCodecHWConfig *config = avcodec_get_hw_config(p, 
j);
+
+if (!config)
+break;
+
+if (config->device_type == ist->hwaccel_device_type)
+return p;
+}
+}
+}
+
+return avcodec_find_decoder(st->codecpar->codec_id);
+}
+}
+
 /* Add all the streams from the given input file to the global
  * list of input streams. */
 static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
@@ -973,7 +1015,7 @@ static void add_input_streams(OptionsContext *o, 
AVFormatContext *ic)
 ist->hwaccel_pix_fmt = AV_PIX_FMT_NONE;
 }
 
-ist->dec = choose_decoder(o, ic, st);
+ist->dec = choose_decoder2(ist, o, ic, st);
 ist->decoder_opts = filter_codec_opts(o->g->codec_opts, 
ist->st->codecpar->codec_id, ic, st, ist->dec);
 
 ist->reinit_filters = -1;
-- 
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 v3 1/2] ffmpeg_opt: select a decoder after getting values for per-stream hwdec options

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

After applying this patch, the desired HW acceleration method is known
before selecting decoder, so we may take HW acceleration method into
account when selecting decoder for input stream in the next commit

There should be no functional changes in this patch

Signed-off-by: Haihao Xiang 
---
 fftools/ffmpeg_opt.c | 134 ++-
 1 file changed, 68 insertions(+), 66 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 8ac73c0efc..2771c5d993 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -905,72 +905,7 @@ static void add_input_streams(OptionsContext *o, 
AVFormatContext *ic)
 st->codecpar->codec_tag = tag;
 }
 
-ist->dec = choose_decoder(o, ic, st);
-ist->decoder_opts = filter_codec_opts(o->g->codec_opts, 
ist->st->codecpar->codec_id, ic, st, ist->dec);
-
-ist->reinit_filters = -1;
-MATCH_PER_STREAM_OPT(reinit_filters, i, ist->reinit_filters, ic, st);
-
-MATCH_PER_STREAM_OPT(discard, str, discard_str, ic, st);
-ist->user_set_discard = AVDISCARD_NONE;
-
-if ((o->video_disable && ist->st->codecpar->codec_type == 
AVMEDIA_TYPE_VIDEO) ||
-(o->audio_disable && ist->st->codecpar->codec_type == 
AVMEDIA_TYPE_AUDIO) ||
-(o->subtitle_disable && ist->st->codecpar->codec_type == 
AVMEDIA_TYPE_SUBTITLE) ||
-(o->data_disable && ist->st->codecpar->codec_type == 
AVMEDIA_TYPE_DATA))
-ist->user_set_discard = AVDISCARD_ALL;
-
-if (discard_str && av_opt_eval_int(, discard_opt, discard_str, 
>user_set_discard) < 0) {
-av_log(NULL, AV_LOG_ERROR, "Error parsing discard %s.\n",
-discard_str);
-exit_program(1);
-}
-
-ist->filter_in_rescale_delta_last = AV_NOPTS_VALUE;
-ist->prev_pkt_pts = AV_NOPTS_VALUE;
-
-ist->dec_ctx = avcodec_alloc_context3(ist->dec);
-if (!ist->dec_ctx) {
-av_log(NULL, AV_LOG_ERROR, "Error allocating the decoder 
context.\n");
-exit_program(1);
-}
-
-ret = avcodec_parameters_to_context(ist->dec_ctx, par);
-if (ret < 0) {
-av_log(NULL, AV_LOG_ERROR, "Error initializing the decoder 
context.\n");
-exit_program(1);
-}
-
-ist->decoded_frame = av_frame_alloc();
-if (!ist->decoded_frame)
-exit_program(1);
-
-ist->pkt = av_packet_alloc();
-if (!ist->pkt)
-exit_program(1);
-
-if (o->bitexact)
-ist->dec_ctx->flags |= AV_CODEC_FLAG_BITEXACT;
-
-switch (par->codec_type) {
-case AVMEDIA_TYPE_VIDEO:
-if(!ist->dec)
-ist->dec = avcodec_find_decoder(par->codec_id);
-
-// avformat_find_stream_info() doesn't set this for us anymore.
-ist->dec_ctx->framerate = st->avg_frame_rate;
-
-MATCH_PER_STREAM_OPT(frame_rates, str, framerate, ic, st);
-if (framerate && av_parse_video_rate(>framerate,
- framerate) < 0) {
-av_log(NULL, AV_LOG_ERROR, "Error parsing framerate %s.\n",
-   framerate);
-exit_program(1);
-}
-
-ist->top_field_first = -1;
-MATCH_PER_STREAM_OPT(top_field_first, i, ist->top_field_first, ic, 
st);
-
+if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
 MATCH_PER_STREAM_OPT(hwaccels, str, hwaccel, ic, st);
 MATCH_PER_STREAM_OPT(hwaccel_output_formats, str,
  hwaccel_output_format, ic, st);
@@ -1036,6 +971,73 @@ static void add_input_streams(OptionsContext *o, 
AVFormatContext *ic)
 }
 
 ist->hwaccel_pix_fmt = AV_PIX_FMT_NONE;
+}
+
+ist->dec = choose_decoder(o, ic, st);
+ist->decoder_opts = filter_codec_opts(o->g->codec_opts, 
ist->st->codecpar->codec_id, ic, st, ist->dec);
+
+ist->reinit_filters = -1;
+MATCH_PER_STREAM_OPT(reinit_filters, i, ist->reinit_filters, ic, st);
+
+MATCH_PER_STREAM_OPT(discard, str, discard_str, ic, st);
+ist->user_set_discard = AVDISCARD_NONE;
+
+if ((o->video_disable && ist->st->codecpar->codec_type == 
AVMEDIA_TYPE_VIDEO) ||
+(o->audio_disable && ist->st->codecpar->codec_type == 
AVMEDIA_TYPE_AUDIO) ||
+(o->subtitle_disable && ist->st->codecpar->codec_type == 
AVMEDIA_TYPE_SUBTITLE) ||
+(o->data_disable && ist->st->codecpar->codec_type == 
AVMEDIA_TYPE_DATA))
+ist->user_set_discard = AVDISCARD_ALL;
+
+if (discard_str && av_opt_eval_int(, discard_opt, discard_str, 
>user_set_discard) < 0) {
+av_log(NULL, AV_LOG_ERROR, "Error parsing discard %s.\n",
+discard_str);
+exit_program(1);
+}
+
+ist->filter_in_rescale_delta_last = 

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

2022-07-24 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 8a6702f2a8..b292de69e2 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 

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

2022-07-24 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, , >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, ,
+   >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 *)_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, );
+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, );
+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_IDX(link)  ((int)((link)->dstpad 

[FFmpeg-devel] [PATCH v12 06/13] qsvenc: restrict multi-frame encode to MFX_VERSION < 2.0

2022-07-24 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 v12 10/13] lavu/hwcontext_qsv: make qsv hwdevice works with oneVPL

2022-07-24 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 | 532 +++---
 1 file changed, 494 insertions(+), 38 deletions(-)

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 21a2a805f8..510f422562 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,437 @@ 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, _IDXGIDevice, 
(void**));
+if (SUCCEEDED(hr)) {
+hr = IDXGIDevice_GetAdapter(pDXGIDevice, );
+if (FAILED(hr)) {
+av_log(ctx, AV_LOG_ERROR, "Error IDXGIDevice_GetAdapter %d\n", hr);
+goto fail;
+}
+
+hr = IDXGIAdapter_GetDesc(pDXGIAdapter, );
+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 = 
+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, _handle);
+if (FAILED(hr)) {
+av_log(ctx, AV_LOG_ERROR, "Error OpenDeviceHandle %d\n", hr);
+goto fail;
+}
+
+hr = IDirect3DDeviceManager9_LockDevice(devmgr, device_handle, , 
TRUE);
+if (FAILED(hr)) {
+av_log(ctx, AV_LOG_ERROR, "Error LockDevice %d\n", hr);
+goto fail;
+}
+
+hr = IDirect3DDevice9Ex_GetCreationParameters(device, );
+if (FAILED(hr)) {
+av_log(ctx, AV_LOG_ERROR, "Error 
IDirect3DDevice9_GetCreationParameters %d\n", hr);
+goto unlock;
+}
+
+hr = IDirect3DDevice9Ex_GetDirect3D(device, );
+if (FAILED(hr)) {
+av_log(ctx, AV_LOG_ERROR, "Error IDirect3DDevice9Ex_GetAdapterLUID 
%d\n", hr);
+goto unlock;
+}
+
+hr = IDirect3D9Ex_GetAdapterLUID(d3d9ex, params.AdapterOrdinal, );
+if (FAILED(hr)) {
+av_log(ctx, 

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

2022-07-24 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 *)_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, );
+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 **)))
+goto fail;
+
+av_assert0(loader);
+} else {
+av_log(avctx, AV_LOG_VERBOSE,
+   "Use Intel(R) oneVPL to create MFX session with the specified 
MFX 

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

2022-07-24 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 v12 08/13] qsv: restrict OPAQUE memory to MFX_VERSION < 2.0

2022-07-24 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, >internal_qs.session,
  >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(>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, >internal_qs.session,
  >frames_ctx, q->load_plugins,
+#if QSV_HAVE_OPAQUE
  q->param.IOPattern == 
MFX_IOPATTERN_IN_OPAQUE_MEMORY,
+#else
+  

[FFmpeg-devel] [PATCH v12 07/13] qsvenc: restrict MFX_RATECONTROL_LA_EXT to MFX_VERSION < 2.0

2022-07-24 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 v12 05/13] qsv: restrict audio related code to MFX_VERSION < 2.0

2022-07-24 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 v12 04/13] qsv: restrict user plugin to MFX_VERSION < 2.0

2022-07-24 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 v12 03/13] qsv: remove mfx/ prefix from mfx headers

2022-07-24 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 33ca654424..8a6702f2a8 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 

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

2022-07-24 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 are
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 027fd756c4..33ca654424 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 v12 01/13] configure: ensure --enable-libmfx uses libmfx 1.x

2022-07-24 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 6629d14099..027fd756c4 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 v12 00/13] make QSV works with the Intel's oneVPL

2022-07-24 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

v12:
  - Update some commit logs
  - Update qsv_va_update_config() for configuration filter on Linux

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: restrict user plugin to MFX_VERSION < 2.0
  qsv: restrict audio related code to MFX_VERSION < 2.0
  qsvenc: restrict multi-frame encode to MFX_VERSION < 2.0
  qsvenc: restrict MFX_RATECONTROL_LA_EXT to MFX_VERSION < 2.0
  qsv: restrict OPAQUE memory to 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| 590 ---
 libavutil/hwcontext_qsv.h|  13 +-
 libavutil/version.h  |   2 +-
 21 files changed, 1099 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] avcodec/x86/pngdsp: Remove obsolete ff_add_bytes_l2_mmx()

2022-07-24 Thread Andreas Rheinhardt
It is overridden by ff_add_bytes_l2_sse2() on any non-ancient CPU.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/x86/pngdsp.asm| 16 ++--
 libavcodec/x86/pngdsp_init.c |  7 ---
 2 files changed, 2 insertions(+), 21 deletions(-)

diff --git a/libavcodec/x86/pngdsp.asm b/libavcodec/x86/pngdsp.asm
index 50e4255dec..7bc43c79a0 100644
--- a/libavcodec/x86/pngdsp.asm
+++ b/libavcodec/x86/pngdsp.asm
@@ -29,9 +29,8 @@ cextern pw_255
 
 SECTION .text
 
-; %1 = nr. of xmm registers used
-%macro ADD_BYTES_FN 1
-cglobal add_bytes_l2, 4, 6, %1, dst, src1, src2, wa, w, i
+INIT_XMM sse2
+cglobal add_bytes_l2, 4, 6, 2, dst, src1, src2, wa, w, i
 %if ARCH_X86_64
 movsxd waq, wad
 %endif
@@ -53,7 +52,6 @@ cglobal add_bytes_l2, 4, 6, %1, dst, src1, src2, wa, w, i
 cmp iq, waq
 jl .loop_v
 
-%if mmsize == 16
 ; vector loop
 movwaq, wq
 andwaq, ~7
@@ -66,7 +64,6 @@ cglobal add_bytes_l2, 4, 6, %1, dst, src1, src2, wa, w, i
 .end_l:
 cmp iq, waq
 jl .loop_l
-%endif
 
 ; scalar loop for leftover
 jmp .end_s
@@ -79,15 +76,6 @@ cglobal add_bytes_l2, 4, 6, %1, dst, src1, src2, wa, w, i
 cmp iq, wq
 jl .loop_s
 REP_RET
-%endmacro
-
-%if ARCH_X86_32
-INIT_MMX mmx
-ADD_BYTES_FN 0
-%endif
-
-INIT_XMM sse2
-ADD_BYTES_FN 2
 
 %macro ADD_PAETH_PRED_FN 1
 cglobal add_png_paeth_prediction, 5, 7, %1, dst, src, top, w, bpp, end, cntr
diff --git a/libavcodec/x86/pngdsp_init.c b/libavcodec/x86/pngdsp_init.c
index edbe866c22..e2cd5effe3 100644
--- a/libavcodec/x86/pngdsp_init.c
+++ b/libavcodec/x86/pngdsp_init.c
@@ -20,7 +20,6 @@
  */
 
 #include 
-#include "config.h"
 #include "libavutil/attributes.h"
 #include "libavutil/x86/cpu.h"
 #include "libavcodec/pngdsp.h"
@@ -29,8 +28,6 @@ void ff_add_png_paeth_prediction_mmxext(uint8_t *dst, uint8_t 
*src,
 uint8_t *top, int w, int bpp);
 void ff_add_png_paeth_prediction_ssse3(uint8_t *dst, uint8_t *src,
uint8_t *top, int w, int bpp);
-void ff_add_bytes_l2_mmx (uint8_t *dst, uint8_t *src1,
-  uint8_t *src2, int w);
 void ff_add_bytes_l2_sse2(uint8_t *dst, uint8_t *src1,
   uint8_t *src2, int w);
 
@@ -38,10 +35,6 @@ av_cold void ff_pngdsp_init_x86(PNGDSPContext *dsp)
 {
 int cpu_flags = av_get_cpu_flags();
 
-#if ARCH_X86_32
-if (EXTERNAL_MMX(cpu_flags))
-dsp->add_bytes_l2 = ff_add_bytes_l2_mmx;
-#endif
 if (EXTERNAL_MMXEXT(cpu_flags))
 dsp->add_paeth_prediction = ff_add_png_paeth_prediction_mmxext;
 if (EXTERNAL_SSE2(cpu_flags))
-- 
2.34.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] qsv: Update ffmpeg qsv_errors to recognize GPU hang

2022-07-24 Thread Xiang, Haihao
On Fri, 2022-07-22 at 11:06 -0700, Dmitry Rogozhkin wrote:
> GPU hang is one of the most typical errors on Intel GPUs in
> case something goes wrong. It's important to recognize it
> explicitly for easier bugs triage. Also, this error code
> can be used to trigger GPU recovery path in self-written
> applications.
> 
> Signed-off-by: Hon Wai Chow 
> Signed-off-by: Dmitry Rogozhkin 
> ---
>  libavcodec/qsv.c | 1 +
>  libavfilter/qsvvpp.c | 1 +
>  2 files changed, 2 insertions(+)
> 
> diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
> index 385b43b..55bcb6e 100644
> --- a/libavcodec/qsv.c
> +++ b/libavcodec/qsv.c
> @@ -125,6 +125,7 @@ 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"},
> +{ MFX_ERR_GPU_HANG, AVERROR(EIO),"GPU
> Hang" },
>  { MFX_ERR_INCOMPATIBLE_AUDIO_PARAM, AVERROR(EINVAL), "incompatible audio
> parameters"},
>  { MFX_ERR_INVALID_AUDIO_PARAM,  AVERROR(EINVAL), "invalid audio
> parameters" },
>  
> diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
> index 954f882..7504906 100644
> --- a/libavfilter/qsvvpp.c
> +++ b/libavfilter/qsvvpp.c
> @@ -100,6 +100,7 @@ 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"},
> +{ MFX_ERR_GPU_HANG, AVERROR(EIO),"GPU
> Hang" },
>  { MFX_ERR_INCOMPATIBLE_AUDIO_PARAM, AVERROR(EINVAL), "incompatible audio
> parameters"},
>  { MFX_ERR_INVALID_AUDIO_PARAM,  AVERROR(EINVAL), "invalid audio
> parameters" },
>  

Could you add other missing qsv video errors or warnings too ?

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 14/18] avcodec/hevcdec: Don't allocate redundant HEVCContexts

2022-07-24 Thread Andreas Rheinhardt
Michael Niedermayer:
> On Sat, Jul 23, 2022 at 11:42:23PM +0200, Andreas Rheinhardt wrote:
>> Michael Niedermayer:
>>> On Sat, Jul 23, 2022 at 07:44:40AM +0200, Andreas Rheinhardt wrote:
 Andreas Rheinhardt:
> Michael Niedermayer:
>> On Sat, Jul 02, 2022 at 08:32:06AM +0200, Andreas Rheinhardt wrote:
>>> Michael Niedermayer:
 On Fri, Jul 01, 2022 at 12:29:45AM +0200, Andreas Rheinhardt wrote:
> The HEVC decoder has both HEVCContext and HEVCLocalContext
> structures. The latter is supposed to be the structure
> containing the per-slicethread state.
>
> Yet up until now that is not how it is handled in practice:
> Each HEVCLocalContext has a unique HEVCContext allocated for it
> and each of these coincides except in exactly one field: The
> corresponding HEVCLocalContext. This makes it possible to pass
> the HEVCContext everywhere where logically a HEVCLocalContext
> should be used. And up until recently, this is how it has been done.
>
> Yet the preceding patches changed this, making it possible
> to avoid allocating redundant HEVCContexts.
>
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/hevcdec.c | 40 
>  libavcodec/hevcdec.h |  2 --
>  2 files changed, 16 insertions(+), 26 deletions(-)
>
> diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
> index 9d1241f293..048fcc76b4 100644
> --- a/libavcodec/hevcdec.c
> +++ b/libavcodec/hevcdec.c
> @@ -2548,13 +2548,12 @@ static int 
> hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist,
>  {
>  HEVCLocalContext *lc = 
> ((HEVCLocalContext**)hevc_lclist)[self_id];
>  const HEVCContext *const s = lc->parent;
> -HEVCContext *s1  = avctxt->priv_data;
> -int ctb_size= 1<< s1->ps.sps->log2_ctb_size;
> +int ctb_size= 1 << s->ps.sps->log2_ctb_size;
>  int more_data   = 1;
>  int ctb_row = job;
> -int ctb_addr_rs = s1->sh.slice_ctb_addr_rs + ctb_row * 
> ((s1->ps.sps->width + ctb_size - 1) >> s1->ps.sps->log2_ctb_size);
> -int ctb_addr_ts = s1->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs];
> -int thread = ctb_row % s1->threads_number;
> +int ctb_addr_rs = s->sh.slice_ctb_addr_rs + ctb_row * 
> ((s->ps.sps->width + ctb_size - 1) >> s->ps.sps->log2_ctb_size);
> +int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs];
> +int thread = ctb_row % s->threads_number;
>  int ret;
>  
>  if(ctb_row) {
> @@ -2572,7 +2571,7 @@ static int hls_decode_entry_wpp(AVCodecContext 
> *avctxt, void *hevc_lclist,
>  
>  ff_thread_await_progress2(s->avctx, ctb_row, thread, 
> SHIFT_CTB_WPP);
>  
> -if (atomic_load(>wpp_err)) {
> +if (atomic_load(>wpp_err)) {
>  ff_thread_report_progress2(s->avctx, ctb_row , thread, 
> SHIFT_CTB_WPP);

 the consts in "const HEVCContext *const " make clang version 
 6.0.0-1ubuntu2 unhappy
 (this was building shared libs)


 CC libavcodec/hevcdec.o
 src/libavcodec/hevcdec.c:2574:13: error: address argument to atomic 
 operation must be a pointer to non-const _Atomic type ('const 
 atomic_int *' (aka 'const _Atomic(int) *') invalid)
 if (atomic_load(>wpp_err)) {
 ^   ~~~
 /usr/lib/llvm-6.0/lib/clang/6.0.0/include/stdatomic.h:134:29: note: 
 expanded from macro 'atomic_load'
 #define atomic_load(object) __c11_atomic_load(object, __ATOMIC_SEQ_CST)
 ^ ~~
 1 error generated.
 src/ffbuild/common.mak:81: recipe for target 'libavcodec/hevcdec.o' 
 failed
 make: *** [libavcodec/hevcdec.o] Error 1

 thx

>>>
>>> Thanks for testing this. atomic_load is indeed declared without const in
>>> 7.17.7.2:
>>>
>>> C atomic_load(volatile A *object);
>>>
>>> Upon reflection this makes sense, because if atomics are implemented via
>>> mutexes, even a read may involve a preceding write. So I'll cast const
>>> away here, too, and add a comment. (It works when casting const away,
>>> doesn't it?)
>>
>> This doesnt feel "right". These pointers should not be coming from a 
>> const
>> if they are written to
>>
>
> The HEVCContext is not const because the underlying object is const; the
> HEVCContext is const when accessed from any part of the code that may be
> run from slice threads, because if a slice thread modifies 

Re: [FFmpeg-devel] [PATCH 14/18] avcodec/hevcdec: Don't allocate redundant HEVCContexts

2022-07-24 Thread Michael Niedermayer
On Sat, Jul 23, 2022 at 11:42:23PM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > On Sat, Jul 23, 2022 at 07:44:40AM +0200, Andreas Rheinhardt wrote:
> >> Andreas Rheinhardt:
> >>> Michael Niedermayer:
>  On Sat, Jul 02, 2022 at 08:32:06AM +0200, Andreas Rheinhardt wrote:
> > Michael Niedermayer:
> >> On Fri, Jul 01, 2022 at 12:29:45AM +0200, Andreas Rheinhardt wrote:
> >>> The HEVC decoder has both HEVCContext and HEVCLocalContext
> >>> structures. The latter is supposed to be the structure
> >>> containing the per-slicethread state.
> >>>
> >>> Yet up until now that is not how it is handled in practice:
> >>> Each HEVCLocalContext has a unique HEVCContext allocated for it
> >>> and each of these coincides except in exactly one field: The
> >>> corresponding HEVCLocalContext. This makes it possible to pass
> >>> the HEVCContext everywhere where logically a HEVCLocalContext
> >>> should be used. And up until recently, this is how it has been done.
> >>>
> >>> Yet the preceding patches changed this, making it possible
> >>> to avoid allocating redundant HEVCContexts.
> >>>
> >>> Signed-off-by: Andreas Rheinhardt 
> >>> ---
> >>>  libavcodec/hevcdec.c | 40 
> >>>  libavcodec/hevcdec.h |  2 --
> >>>  2 files changed, 16 insertions(+), 26 deletions(-)
> >>>
> >>> diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
> >>> index 9d1241f293..048fcc76b4 100644
> >>> --- a/libavcodec/hevcdec.c
> >>> +++ b/libavcodec/hevcdec.c
> >>> @@ -2548,13 +2548,12 @@ static int 
> >>> hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist,
> >>>  {
> >>>  HEVCLocalContext *lc = 
> >>> ((HEVCLocalContext**)hevc_lclist)[self_id];
> >>>  const HEVCContext *const s = lc->parent;
> >>> -HEVCContext *s1  = avctxt->priv_data;
> >>> -int ctb_size= 1<< s1->ps.sps->log2_ctb_size;
> >>> +int ctb_size= 1 << s->ps.sps->log2_ctb_size;
> >>>  int more_data   = 1;
> >>>  int ctb_row = job;
> >>> -int ctb_addr_rs = s1->sh.slice_ctb_addr_rs + ctb_row * 
> >>> ((s1->ps.sps->width + ctb_size - 1) >> s1->ps.sps->log2_ctb_size);
> >>> -int ctb_addr_ts = s1->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs];
> >>> -int thread = ctb_row % s1->threads_number;
> >>> +int ctb_addr_rs = s->sh.slice_ctb_addr_rs + ctb_row * 
> >>> ((s->ps.sps->width + ctb_size - 1) >> s->ps.sps->log2_ctb_size);
> >>> +int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs];
> >>> +int thread = ctb_row % s->threads_number;
> >>>  int ret;
> >>>  
> >>>  if(ctb_row) {
> >>> @@ -2572,7 +2571,7 @@ static int hls_decode_entry_wpp(AVCodecContext 
> >>> *avctxt, void *hevc_lclist,
> >>>  
> >>>  ff_thread_await_progress2(s->avctx, ctb_row, thread, 
> >>> SHIFT_CTB_WPP);
> >>>  
> >>> -if (atomic_load(>wpp_err)) {
> >>> +if (atomic_load(>wpp_err)) {
> >>>  ff_thread_report_progress2(s->avctx, ctb_row , thread, 
> >>> SHIFT_CTB_WPP);
> >>
> >> the consts in "const HEVCContext *const " make clang version 
> >> 6.0.0-1ubuntu2 unhappy
> >> (this was building shared libs)
> >>
> >>
> >> CC libavcodec/hevcdec.o
> >> src/libavcodec/hevcdec.c:2574:13: error: address argument to atomic 
> >> operation must be a pointer to non-const _Atomic type ('const 
> >> atomic_int *' (aka 'const _Atomic(int) *') invalid)
> >> if (atomic_load(>wpp_err)) {
> >> ^   ~~~
> >> /usr/lib/llvm-6.0/lib/clang/6.0.0/include/stdatomic.h:134:29: note: 
> >> expanded from macro 'atomic_load'
> >> #define atomic_load(object) __c11_atomic_load(object, __ATOMIC_SEQ_CST)
> >> ^ ~~
> >> 1 error generated.
> >> src/ffbuild/common.mak:81: recipe for target 'libavcodec/hevcdec.o' 
> >> failed
> >> make: *** [libavcodec/hevcdec.o] Error 1
> >>
> >> thx
> >>
> >
> > Thanks for testing this. atomic_load is indeed declared without const in
> > 7.17.7.2:
> >
> > C atomic_load(volatile A *object);
> >
> > Upon reflection this makes sense, because if atomics are implemented via
> > mutexes, even a read may involve a preceding write. So I'll cast const
> > away here, too, and add a comment. (It works when casting const away,
> > doesn't it?)
> 
>  This doesnt feel "right". These pointers should not be coming from a 
>  const
>  if they are written to
> 
> >>>
> >>> The HEVCContext is not const because the underlying object is const; the
> >>> HEVCContext is const when accessed from any part of the code that may be
> >>> run from slice threads, because if a slice thread modifies it, you have
> >>> a data 

Re: [FFmpeg-devel] [PATCH] configure: properly require libx264 if enabled

2022-07-24 Thread Jan Ekström
On Sun, Jul 24, 2022 at 5:48 PM Jan Ekström  wrote:
>
> On Sun, Jul 24, 2022 at 2:04 PM Jan Ekström  wrote:
> >
> > On Sun, Jul 24, 2022 at 1:12 PM Marvin Scholz  wrote:
> > >
> > > When libx264 can not be found even though it is enabled, it should error
> > > out properly instead of silently disabling it.
> > > ---
> > >  configure | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/configure b/configure
> > > index 46f6490a64..6629d14099 100755
> > > --- a/configure
> > > +++ b/configure
> > > @@ -6673,7 +6673,7 @@ enabled libvpx&& {
> > >  enabled libwebp   && {
> > >  enabled libwebp_encoder  && require_pkg_config libwebp "libwebp 
> > > >= 0.2.0" webp/encode.h WebPGetEncoderVersion
> > >  enabled libwebp_anim_encoder && check_pkg_config 
> > > libwebp_anim_encoder "libwebpmux >= 0.4.0" webp/mux.h 
> > > WebPAnimEncoderOptionsInit; }
> > > -enabled libx264   && check_pkg_config libx264 x264 "stdint.h 
> > > x264.h" x264_encoder_encode &&
> > > +enabled libx264   && require_pkg_config libx264 x264 "stdint.h 
> > > x264.h" x264_encoder_encode &&
> >
> > Looking at the commit message in
> > dd5a0302d5286e66ca03a57770537d5afa4c7775 , support for non-pkg-config
> > usage was removed then, so require_pkg_config (which dies if the check
> > doesn't succeed) seems like the correct option to utilize.
> >
> > LGTM
>
> Verified that this now properly works with and without x264 pc file
> being available (as in, "ERROR: x264 not found using pkg-config"
> without it, and properly enabling the feature if it is available).
>
> Applied as 564d7946de56155d1c42165a8b561fcf5028cbbc .
>
> I think this might make sense to back-port onto release/5.1 as
> dd5a0302d5286e66ca03a57770537d5afa4c7775 is on that branch as well?

Got a positive response from j-b regarding back-porting this to
release/5.1 , and I have applied the change to that branch as
6d83c5f87651499dbb5d310f7cbd12a25c7d07f9 .

Jan
___
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] Contact of the Technical Committee

2022-07-24 Thread Jean-Baptiste Kempf
Have you tried tc@ffmpeg.o.. ?

jb

On Sun, 24 Jul 2022, at 17:12, Nicolas George wrote:
> Hi.
>
> What is the address to ask a question to the technical committee?
>
> Thanks,
>
> -- 
>   Nicolas George
>
> ___
> 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".
>
> Attachments:
> * signature.asc

-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
___
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] fate/imf: Rename IMF fate-target

2022-07-24 Thread Andreas Rheinhardt
It conflicts with the name of the test using the testtool
in libavformat.mak.

Fixes ticket #9841.

Signed-off-by: Andreas Rheinhardt 
---
Other naming suggestions welcome.

 tests/fate/imf.mak | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/fate/imf.mak b/tests/fate/imf.mak
index 70a3efdfbd..feb54d1361 100644
--- a/tests/fate/imf.mak
+++ b/tests/fate/imf.mak
@@ -3,4 +3,4 @@ fate-imf-cpl-with-repeat: CMD = framecrc -f imf -i 
$(TARGET_SAMPLES)/imf/countdo
 
 FATE_SAMPLES_FFMPEG-$(CONFIG_IMF_DEMUXER) += $(FATE_IMF)
 
-fate-imf: $(FATE_IMF)
+fate-imfdec: $(FATE_IMF)
-- 
2.34.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 v5 00/25] Subtitle Filtering 2022

2022-07-24 Thread Soft Works



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Nicolas George
> Sent: Sunday, July 24, 2022 5:10 PM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v5 00/25] Subtitle Filtering 2022
> 


> I suspect that if I were to do a full review, I would find a few
> other flaws. 


This is a very good example for the kind of behavior I'd kindly 
ask you to stop with. 


Do you think you have found a flaw?
===

=> please name it and explain it, ideally asking before calling it
   a "flaw"

(like your one "flaw" wasn't really one as I had laid out)


Do you think you COULD find a flaw?
===

=> Go ahead and find one - no need to tell


Thanks,
softworkz
___
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 v5 00/25] Subtitle Filtering 2022

2022-07-24 Thread Soft Works



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Nicolas George
> Sent: Sunday, July 24, 2022 5:10 PM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v5 00/25] Subtitle Filtering 2022
> 
> I hesitated a long time before replying, but all considering, at this
> point expressing what is weighing on my heart cannot make things
> worse.
> 
> 
> Michael Niedermayer (12022-07-03):
> > What is the timeline for the audio+video merge ?
> 
> I cannot give a timeline because I do not work on FFmpeg on a
> schedule,
> I work on FFmpeg in my free time, for fun. And lately, working on
> FFmpeg
> has been really un-fun. Recently, my contributions have been met with
> indifference at best (see when I proposed a XML parser six months
> ago:
> nobody cared), outright hostility at worst. Under these
> circumstances,
> whenever I am considering working on something FFmpeg-related, I
> usually
> find something else more fun to do.
> 
> I do not recognize the project I started contributing to more than
> fifteen years ago. I do not even recognize the project that boasted
> the
> clever optimization framework that made FFVP9 possible, it has become
> increasingly hostile to trying new and more efficient ways of doing
> things in favor of a corporate never-take-risks style of coding. I am
> more and more often considering giving up and cutting my losses.
> 
> > IIUC this would resolve this deadlock (with extra work adapting the
> patchset
> > so it would be work for SW adapting it and it would be work for you
> finishing
> > the merge)
> > Also can others help nicolas moving his work forward
> >
> > What i suggest is to pick a time and then try to finish the merge
> before.
> > If it succeeds this patchset needs updating and can move forward
> without
> > this main objection
> > OTOH if the time is not hit, we agree that the objection can no
> longer be
> > used
> 
> My answer as maintainer of the framework of libavfilter is: no.
> 
> Of course, maintainers are not dictators. The members of the project
> can
> collectively decide otherwise. But I have to warn you about the
> consequences.
> 
> First, the issue about negotiation is not he only severe flaw in this
> patch series. 

Negotiation hasn't been implemented for audio+video yet. Neither 
does that patchset do it for audio+video+subtitles.
It is out of scope of this patchset. It can be done later or never,
not everybody is a fan of doing so, as comments have shown.
Clearly, this is in no way a showstopping reason as you had
conceded yourself recently.

> I can immediately quote another one: for text
> subtitles,
> the approach of this proposal to synchronization is to feed
> everything
> to libass as it comes and see what comes out. It will work on easy
> cases, when the subtitles are interleaved with the video or come from
> a separate file. 

- or come from decoded closed captions
- or come from graphic subtitles converted with the graphicsub2text
  filter
- or come from the subfeed filter after fixing durations
- or come from the subfeed filter ensuring a regular repetition
  (heartbeat)

Subtitle events don't need to come in linear order. Multiple
events can have identical start times, subtitle events can
overlap. 

The overlaytextsubs filter is meant to be a direct replacement 
for the existing subtitles filter, which performs additional 
opening, parsing and decoding of the source file in parallel, 
and avoiding that was one of the primary objectives I had for 
starting development.
That's why it was very important for me to preserve the exact 
same behavior as the overlaytextsubs filter exposes.

Other approaches for implementatino are surely possible as well. 
Traian, who did  the text2graphicsub filter had initially an 
implementation that handled the timing manually instead of letting 
libass do it, but it turned out that this can quickly become a 
really complex task, especially when overlapping events or 
animations are part of the game, so it came down to feeding 
everything to libass in the end, like the overlaytextsubs 
filter and the subtitles filters do.

The nice thing about having subtitle filtering is that there
is no fixed functionality involved where you can argue about 
right or wrong: anyone is free to contribute another filter 
which is pursuing a different approach. I would welcome that 
and there may be cases where an alternative method could be
advantageous, but it surely won't be superior in general.


> But as soon as a filter will, for example, adjust the
> timing to make the subtitles more early, it will just not work. Of
> course, it was not tested because this patch series does not even
> offer the feature to adjust the time of subtitles, which is frankly
> ridiculous, it is one of the most obvious thing people might want to
> do.

The only reason why there is no timing adjustment filter is that
I didn't need one. It is really easy to implement such filter.
The 

[FFmpeg-devel] Contact of the Technical Committee

2022-07-24 Thread Nicolas George
Hi.

What is the address to ask a question to the technical committee?

Thanks,

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


Re: [FFmpeg-devel] [PATCH v5 00/25] Subtitle Filtering 2022

2022-07-24 Thread Nicolas George
I hesitated a long time before replying, but all considering, at this
point expressing what is weighing on my heart cannot make things worse.


Michael Niedermayer (12022-07-03):
> What is the timeline for the audio+video merge ?

I cannot give a timeline because I do not work on FFmpeg on a schedule,
I work on FFmpeg in my free time, for fun. And lately, working on FFmpeg
has been really un-fun. Recently, my contributions have been met with
indifference at best (see when I proposed a XML parser six months ago:
nobody cared), outright hostility at worst. Under these circumstances,
whenever I am considering working on something FFmpeg-related, I usually
find something else more fun to do.

I do not recognize the project I started contributing to more than
fifteen years ago. I do not even recognize the project that boasted the
clever optimization framework that made FFVP9 possible, it has become
increasingly hostile to trying new and more efficient ways of doing
things in favor of a corporate never-take-risks style of coding. I am
more and more often considering giving up and cutting my losses.

> IIUC this would resolve this deadlock (with extra work adapting the patchset
> so it would be work for SW adapting it and it would be work for you finishing
> the merge)
> Also can others help nicolas moving his work forward
> 
> What i suggest is to pick a time and then try to finish the merge before.
> If it succeeds this patchset needs updating and can move forward without
> this main objection
> OTOH if the time is not hit, we agree that the objection can no longer be
> used

My answer as maintainer of the framework of libavfilter is: no.

Of course, maintainers are not dictators. The members of the project can
collectively decide otherwise. But I have to warn you about the
consequences.

First, the issue about negotiation is not he only severe flaw in this
patch series. I can immediately quote another one: for text subtitles,
the approach of this proposal to synchronization is to feed everything
to libass as it comes and see what comes out. It will work on easy
cases, when the subtitles are interleaved with the video or come from a
separate file. But as soon as a filter will, for example, adjust the
timing to make the subtitles more early, it will just not work. Of
course, it was not tested because this patch series does not even offer
the feature to adjust the time of subtitles, which is frankly
ridiculous, it is one of the most obvious thing people might want to do.

Note that I did not have to perform a full review of the patch series to
find this flaw. I have been preparing to implement subtitles filtering
for years now, I know which aspects are tricky and hard to implement
properly. I only had to check precisely how it was done. And it turns
out it was not done at all.

I suspect that if I were to do a full review, I would find a few other
flaws. But the author has made painfully clear that they did not respect
my expertise in this area, I have no reason to waste my time doing it.

It illustrates what it means to be a maintainer. It does not only mean
the task of reviewing and applying bug fixes. The maintainer holds in
their head a knowledge of the code that cannot be fully shared in
writing. The maintainer also holds in their head plans to evolve and
extend the code.

I have plans for libavfilter. Not just vague ideas, but precise plans on
how to reach the goal. I have plans for subtitles filtering, of course.
But not only.

I have plans for filtering data packets, so that bistream filters do not
need to have a separate and redundant API and ffmpeg does not need a
separate code path for -c copy.

I have plans for threading, or more precisely integrating filters in a
global parallelized task and I/O scheduler.

I have plans for seeking, with the seek target going back from the
output to the input(s).

I have plans for partial graph reconfiguration, to accommodate format
changes mid-stream and let applications alter filtering in the middle.

All of this is exciting. I am eager to work on any of this.

Unfortunately, before it can happen, boring things need to be done.
Parts of the framework of libavfilter are very fragile. Working on any
of these is likely to break cases that were specifically fixed in the
past.

I can work on boring things if they are necessary to reach the exciting
parts.

What I cannot do is motivate myself to work on the boring things with
the threat that the exciting things will be snatched under me by an
inferior version from somebody who just refuses to engage with the
boring necessary things.

If this patch series gets applied, it will make the boring things a lot
harder to do and it will ruin some of the plans I mentioned above. Under
these circumstances, do not expect me to work on libavfilter again any
time soon, even if it is to apply an obviously valid fix for an
exploitable security issue.

So, the choice is:

- Apply this patch series, find a new maintainer for libavfilter 

Re: [FFmpeg-devel] [PATCH] configure: properly require libx264 if enabled

2022-07-24 Thread Jan Ekström
On Sun, Jul 24, 2022 at 2:04 PM Jan Ekström  wrote:
>
> On Sun, Jul 24, 2022 at 1:12 PM Marvin Scholz  wrote:
> >
> > When libx264 can not be found even though it is enabled, it should error
> > out properly instead of silently disabling it.
> > ---
> >  configure | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/configure b/configure
> > index 46f6490a64..6629d14099 100755
> > --- a/configure
> > +++ b/configure
> > @@ -6673,7 +6673,7 @@ enabled libvpx&& {
> >  enabled libwebp   && {
> >  enabled libwebp_encoder  && require_pkg_config libwebp "libwebp >= 
> > 0.2.0" webp/encode.h WebPGetEncoderVersion
> >  enabled libwebp_anim_encoder && check_pkg_config libwebp_anim_encoder 
> > "libwebpmux >= 0.4.0" webp/mux.h WebPAnimEncoderOptionsInit; }
> > -enabled libx264   && check_pkg_config libx264 x264 "stdint.h 
> > x264.h" x264_encoder_encode &&
> > +enabled libx264   && require_pkg_config libx264 x264 "stdint.h 
> > x264.h" x264_encoder_encode &&
>
> Looking at the commit message in
> dd5a0302d5286e66ca03a57770537d5afa4c7775 , support for non-pkg-config
> usage was removed then, so require_pkg_config (which dies if the check
> doesn't succeed) seems like the correct option to utilize.
>
> LGTM

Verified that this now properly works with and without x264 pc file
being available (as in, "ERROR: x264 not found using pkg-config"
without it, and properly enabling the feature if it is available).

Applied as 564d7946de56155d1c42165a8b561fcf5028cbbc .

I think this might make sense to back-port onto release/5.1 as
dd5a0302d5286e66ca03a57770537d5afa4c7775 is on that branch as well?

Jan
___
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] configure: properly require libx264 if enabled

2022-07-24 Thread Jan Ekström
On Sun, Jul 24, 2022 at 1:12 PM Marvin Scholz  wrote:
>
> When libx264 can not be found even though it is enabled, it should error
> out properly instead of silently disabling it.
> ---
>  configure | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/configure b/configure
> index 46f6490a64..6629d14099 100755
> --- a/configure
> +++ b/configure
> @@ -6673,7 +6673,7 @@ enabled libvpx&& {
>  enabled libwebp   && {
>  enabled libwebp_encoder  && require_pkg_config libwebp "libwebp >= 
> 0.2.0" webp/encode.h WebPGetEncoderVersion
>  enabled libwebp_anim_encoder && check_pkg_config libwebp_anim_encoder 
> "libwebpmux >= 0.4.0" webp/mux.h WebPAnimEncoderOptionsInit; }
> -enabled libx264   && check_pkg_config libx264 x264 "stdint.h x264.h" 
> x264_encoder_encode &&
> +enabled libx264   && require_pkg_config libx264 x264 "stdint.h 
> x264.h" x264_encoder_encode &&

Looking at the commit message in
dd5a0302d5286e66ca03a57770537d5afa4c7775 , support for non-pkg-config
usage was removed then, so require_pkg_config (which dies if the check
doesn't succeed) seems like the correct option to utilize.

LGTM

Jan
___
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] configure: properly require libx264 if enabled

2022-07-24 Thread Marvin Scholz
When libx264 can not be found even though it is enabled, it should error
out properly instead of silently disabling it.
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 46f6490a64..6629d14099 100755
--- a/configure
+++ b/configure
@@ -6673,7 +6673,7 @@ enabled libvpx&& {
 enabled libwebp   && {
 enabled libwebp_encoder  && require_pkg_config libwebp "libwebp >= 
0.2.0" webp/encode.h WebPGetEncoderVersion
 enabled libwebp_anim_encoder && check_pkg_config libwebp_anim_encoder 
"libwebpmux >= 0.4.0" webp/mux.h WebPAnimEncoderOptionsInit; }
-enabled libx264   && check_pkg_config libx264 x264 "stdint.h x264.h" 
x264_encoder_encode &&
+enabled libx264   && require_pkg_config libx264 x264 "stdint.h x264.h" 
x264_encoder_encode &&
  require_cpp_condition libx264 x264.h "X264_BUILD 
>= 118" && {
  [ "$toolchain" != "msvc" ] ||
  require_cpp_condition libx264 x264.h "X264_BUILD 
>= 158"; } &&
-- 
2.32.0 (Apple Git-132)

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