Re: [FFmpeg-devel] [PATCH] avfilter: add backgroundkey video filter

2022-11-04 Thread Paul B Mahol
On 11/3/22, Paul B Mahol  wrote:
> On 11/3/22, Andreas Rheinhardt  wrote:
>> Paul B Mahol:
>>> On 11/2/22, Andreas Rheinhardt  wrote:
 Paul B Mahol:
> +static int filter_frame(AVFilterLink *link, AVFrame *frame)
> +{
> +AVFilterContext *avctx = link->dst;
> +BackgroundkeyContext *s = avctx->priv;
> +int64_t sum = 0;
> +int ret;
> +
> +if (!s->background) {
> +s->background = av_frame_clone(frame);
> +if (!s->background)
> +return AVERROR(ENOMEM);
> +av_frame_make_writable(s->background);

 You are never writing to the background frame, so there is no point in
 making it writable; what you actually want to achieve here is making
 frame writable again and to achieve this you should make frame, not
 background writable (and of course you should check said call).

>>>
>>> This is invalid, input pad receives always writable frames as there is
>>> flag.
>>>
>>
>> But in case this branch here is executed, the av_frame_clone() makes
>> frame non-writable, so it needs to be made writable again.
>
> Than will use copy frame.
>
>>
 (Actually, you never

> +}
> +
> +if (ret = ff_filter_execute(avctx, s->do_slice, frame, NULL,
> +FFMIN(frame->height, s->nb_threads)))
> +return ret;
> +
> +for (int n = 0; n < s->nb_threads; n++)
> +sum += s->sums[n];
> +if (s->max_sum * s->threshold < sum) {
> +av_frame_free(&s->background);
> +s->background = av_frame_clone(frame);
> +if (!s->background)
> +return AVERROR(ENOMEM);
> +av_frame_make_writable(s->background);

 Given that you never write to background, there is no need to make it
 writable. This time, there is also no need to make frame writable (the
 next filter in the chain may not need a writable frame anyway), so just
 remove this.
 And the av_frame_free+av_frame_clone can become an
 av_frame_unref+av_frame_ref (this will necessitate modifying the check
 above to not only check for to existence of s->background).

> +}
> +
> +return ff_filter_frame(avctx->outputs[0], frame);
> +}

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

Will apply witjh av_copy_frame() solution.
___
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 v7] libavfilter/x86/vf_convolution: add sobel filter optimization and unit test with intel AVX512 VNNI

2022-11-04 Thread bin . wang-at-intel . com
From: bwang30 

This commit enabled assembly code with intel AVX512 VNNI and added unit test 
for sobel filter

sobel_c: 4537
sobel_avx512icl 2136

Signed-off-by: bwang30 
---
 libavfilter/convolution.h |  74 +
 libavfilter/vf_convolution.c  |  91 +++-
 libavfilter/x86/vf_convolution.asm| 147 ++
 libavfilter/x86/vf_convolution_init.c |  18 
 tests/checkasm/Makefile   |   1 +
 tests/checkasm/checkasm.c |   3 +
 tests/checkasm/checkasm.h |   1 +
 tests/checkasm/vf_convolution.c   | 104 ++
 tests/fate/checkasm.mak   |   1 +
 9 files changed, 362 insertions(+), 78 deletions(-)
 create mode 100644 tests/checkasm/vf_convolution.c

diff --git a/libavfilter/convolution.h b/libavfilter/convolution.h
index 88aabe9a20..e44bfb5da8 100644
--- a/libavfilter/convolution.h
+++ b/libavfilter/convolution.h
@@ -21,6 +21,7 @@
 #ifndef AVFILTER_CONVOLUTION_H
 #define AVFILTER_CONVOLUTION_H
 #include "avfilter.h"
+#include "libavutil/intreadwrite.h"
 
 enum MatrixMode {
 MATRIX_SQUARE,
@@ -61,4 +62,77 @@ typedef struct ConvolutionContext {
 } ConvolutionContext;
 
 void ff_convolution_init_x86(ConvolutionContext *s);
+void ff_sobel_init_x86(ConvolutionContext *s, int depth, int nb_planes);
+
+static void setup_3x3(int radius, const uint8_t *c[], const uint8_t *src, int 
stride,
+  int x, int w, int y, int h, int bpc)
+{
+int i;
+
+for (i = 0; i < 9; i++) {
+int xoff = FFABS(x + ((i % 3) - 1));
+int yoff = FFABS(y + (i / 3) - 1);
+
+xoff = xoff >= w ? 2 * w - 1 - xoff : xoff;
+yoff = yoff >= h ? 2 * h - 1 - yoff : yoff;
+
+c[i] = src + xoff * bpc + yoff * stride;
+}
+}
+
+static void filter_sobel(uint8_t *dst, int width,
+ float scale, float delta, const int *const matrix,
+ const uint8_t *c[], int peak, int radius,
+ int dstride, int stride, int size)
+{
+const uint8_t *c0 = c[0], *c1 = c[1], *c2 = c[2];
+const uint8_t *c3 = c[3], *c5 = c[5];
+const uint8_t *c6 = c[6], *c7 = c[7], *c8 = c[8];
+int x;
+
+for (x = 0; x < width; x++) {
+float suma = c0[x] * -1 + c1[x] * -2 + c2[x] * -1 +
+ c6[x] *  1 + c7[x] *  2 + c8[x] *  1;
+float sumb = c0[x] * -1 + c2[x] *  1 + c3[x] * -2 +
+ c5[x] *  2 + c6[x] * -1 + c8[x] *  1;
+
+dst[x] = av_clip_uint8(sqrtf(suma*suma + sumb*sumb) * scale + delta);
+}
+}
+
+static void filter16_sobel(uint8_t *dstp, int width,
+   float scale, float delta, const int *const matrix,
+   const uint8_t *c[], int peak, int radius,
+   int dstride, int stride, int size)
+{
+uint16_t *dst = (uint16_t *)dstp;
+int x;
+
+for (x = 0; x < width; x++) {
+float suma = AV_RN16A(&c[0][2 * x]) * -1 + AV_RN16A(&c[1][2 * x]) * -2 
+ AV_RN16A(&c[2][2 * x]) * -1 +
+ AV_RN16A(&c[6][2 * x]) *  1 + AV_RN16A(&c[7][2 * x]) *  2 
+ AV_RN16A(&c[8][2 * x]) *  1;
+float sumb = AV_RN16A(&c[0][2 * x]) * -1 + AV_RN16A(&c[2][2 * x]) *  1 
+ AV_RN16A(&c[3][2 * x]) * -2 +
+ AV_RN16A(&c[5][2 * x]) *  2 + AV_RN16A(&c[6][2 * x]) * -1 
+ AV_RN16A(&c[8][2 * x]) *  1;
+
+dst[x] = av_clip(sqrtf(suma*suma + sumb*sumb) * scale + delta, 0, 
peak);
+}
+}
+
+static av_unused void ff_sobel_init(ConvolutionContext *s, int depth, int 
nb_planes)
+{
+for (int i = 0; i < 4; i++) {
+s->filter[i] = filter_sobel;
+s->copy[i] = !((1 << i) & s->planes);
+s->size[i] = 3;
+s->setup[i] = setup_3x3;
+s->rdiv[i] = s->scale;
+s->bias[i] = s->delta;
+}
+if (s->depth > 8)
+for (int i = 0; i < 4; i++)
+s->filter[i] = filter16_sobel;
+#if ARCH_X86_64
+ff_sobel_init_x86(s, depth, nb_planes);
+#endif
+}
 #endif
diff --git a/libavfilter/vf_convolution.c b/libavfilter/vf_convolution.c
index 9a9c099e6d..7762fa2a05 100644
--- a/libavfilter/vf_convolution.c
+++ b/libavfilter/vf_convolution.c
@@ -139,24 +139,6 @@ static void filter16_roberts(uint8_t *dstp, int width,
 }
 }
 
-static void filter16_sobel(uint8_t *dstp, int width,
-   float scale, float delta, const int *const matrix,
-   const uint8_t *c[], int peak, int radius,
-   int dstride, int stride, int size)
-{
-uint16_t *dst = (uint16_t *)dstp;
-int x;
-
-for (x = 0; x < width; x++) {
-float suma = AV_RN16A(&c[0][2 * x]) * -1 + AV_RN16A(&c[1][2 * x]) * -2 
+ AV_RN16A(&c[2][2 * x]) * -1 +
- AV_RN16A(&c[6][2 * x]) *  1 + AV_RN16A(&c[7][2 * x]) *  2 
+ AV_RN16A(&c[8][2 * x]) *  1;
-float sumb = AV_RN16A(&c[0][2 * x]) * -1 + AV_RN16A(&c[2][2 * x]) *  1 
+ AV_RN16A(&c[3][2 * x]) * -2 +
-   

Re: [FFmpeg-devel] FFmpeg 5.2 ?

2022-11-04 Thread Jean-Baptiste Kempf
On Thu, 3 Nov 2022, at 22:59, Michael Niedermayer wrote:
> do we want a release/5.2 branch made in december ?

Based on what? Master or 5.1?


-- 
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 v3] avcodec/nvenc: add AV1 encoding support

2022-11-04 Thread Timo Rothenpieler
The encoder seems to be trading blows with hevc_nvenc.
In terms of quality at low bitrate cbr settings, it seems to
outperform it even. It produces fewer artifacts and the ones it
does produce are less jarring to my perception.

At higher bitrates I had a hard time finding differences between
the two encoders in terms of subjective visual quality.

Using the 'slow' preset, av1_nvenc outperformed hevc_nvenc in terms
of encoding speed by 75% to 100% while performing above tests.

Needless to say, it always massively outperformed h264_nvenc in terms
of quality for a given bitrate, while also being slightly faster.
---
 configure  |  14 ++-
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/nvenc.c | 137 ++--
 libavcodec/nvenc.h |   9 ++
 libavcodec/nvenc_av1.c | 196 +
 libavcodec/version.h   |   4 +-
 7 files changed, 348 insertions(+), 14 deletions(-)
 create mode 100644 libavcodec/nvenc_av1.c

diff --git a/configure b/configure
index 2bcdf18a57..c793daf333 100755
--- a/configure
+++ b/configure
@@ -3184,6 +3184,8 @@ nvenc_deps_any="libdl LoadLibrary"
 aac_mf_encoder_deps="mediafoundation"
 ac3_mf_encoder_deps="mediafoundation"
 av1_cuvid_decoder_deps="cuvid CUVIDAV1PICPARAMS"
+av1_nvenc_encoder_deps="nvenc NV_ENC_PIC_PARAMS_AV1"
+av1_nvenc_encoder_select="atsc_a53"
 h263_v4l2m2m_decoder_deps="v4l2_m2m h263_v4l2_m2m"
 h263_v4l2m2m_encoder_deps="v4l2_m2m h263_v4l2_m2m"
 h264_amf_encoder_deps="amf"
@@ -6466,10 +6468,10 @@ fi
 
 if ! disabled ffnvcodec; then
 ffnv_hdr_list="ffnvcodec/nvEncodeAPI.h ffnvcodec/dynlink_cuda.h 
ffnvcodec/dynlink_cuviddec.h ffnvcodec/dynlink_nvcuvid.h"
-check_pkg_config ffnvcodec "ffnvcodec >= 9.1.23.1" "$ffnv_hdr_list" "" || \
-  check_pkg_config ffnvcodec "ffnvcodec >= 9.0.18.3 ffnvcodec < 9.1" 
"$ffnv_hdr_list" "" || \
-  check_pkg_config ffnvcodec "ffnvcodec >= 8.2.15.10 ffnvcodec < 8.3" 
"$ffnv_hdr_list" "" || \
-  check_pkg_config ffnvcodec "ffnvcodec >= 8.1.24.11 ffnvcodec < 8.2" 
"$ffnv_hdr_list" ""
+check_pkg_config ffnvcodec "ffnvcodec >= 12.0.11.0" "$ffnv_hdr_list" "" || 
\
+  check_pkg_config ffnvcodec "ffnvcodec >= 11.1.5.2 ffnvcodec < 12.0" 
"$ffnv_hdr_list" "" || \
+  check_pkg_config ffnvcodec "ffnvcodec >= 11.0.10.2 ffnvcodec < 11.1" 
"$ffnv_hdr_list" "" || \
+  check_pkg_config ffnvcodec "ffnvcodec >= 8.1.24.14 ffnvcodec < 8.2" 
"$ffnv_hdr_list" ""
 fi
 
 if enabled_all libglslang libshaderc; then
@@ -7050,6 +7052,10 @@ void f(void) { struct { const GUID guid; } s[] = { { 
NV_ENC_PRESET_HQ_GUID } };
 int main(void) { return 0; }
 EOF
 
+if enabled nvenc; then
+check_type "ffnvcodec/nvEncodeAPI.h" "NV_ENC_PIC_PARAMS_AV1"
+fi
+
 if enabled_any nvdec cuvid; then
 check_type "ffnvcodec/dynlink_cuda.h ffnvcodec/dynlink_cuviddec.h" 
"CUVIDAV1PICPARAMS"
 fi
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 72d2f92901..32318fd7ed 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -244,6 +244,7 @@ OBJS-$(CONFIG_AURA_DECODER)+= cyuv.o
 OBJS-$(CONFIG_AURA2_DECODER)   += aura.o
 OBJS-$(CONFIG_AV1_DECODER) += av1dec.o
 OBJS-$(CONFIG_AV1_CUVID_DECODER)   += cuviddec.o
+OBJS-$(CONFIG_AV1_NVENC_ENCODER)   += nvenc_av1.o nvenc.o
 OBJS-$(CONFIG_AV1_QSV_ENCODER) += qsvenc_av1.o
 OBJS-$(CONFIG_AVRN_DECODER)+= avrndec.o
 OBJS-$(CONFIG_AVRP_DECODER)+= r210dec.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 4f1d66cb0c..f5ec3bc6e1 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -827,6 +827,7 @@ extern const FFCodec ff_libaom_av1_decoder;
 /* hwaccel hooks only, so prefer external decoders */
 extern const FFCodec ff_av1_decoder;
 extern const FFCodec ff_av1_cuvid_decoder;
+extern const FFCodec ff_av1_nvenc_encoder;
 extern const FFCodec ff_av1_qsv_decoder;
 extern const FFCodec ff_av1_qsv_encoder;
 extern const FFCodec ff_libopenh264_encoder;
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 73c05fcd37..ffa96d4aa1 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -1,5 +1,5 @@
 /*
- * H.264/HEVC hardware encoding using nvidia nvenc
+ * H.264/HEVC/AV1 hardware encoding using nvidia nvenc
  * Copyright (c) 2016 Timo Rothenpieler 
  *
  * This file is part of FFmpeg.
@@ -222,8 +222,14 @@ static void nvenc_map_preset(NvencContext *ctx)
 
 static void nvenc_print_driver_requirement(AVCodecContext *avctx, int level)
 {
-#if NVENCAPI_CHECK_VERSION(11, 2)
+#if NVENCAPI_CHECK_VERSION(12, 1)
 const char *minver = "(unknown)";
+#elif NVENCAPI_CHECK_VERSION(12, 0)
+# if defined(_WIN32) || defined(__CYGWIN__)
+const char *minver = "522.25";
+# else
+const char *minver = "520.56.06";
+# endif
 #elif NVENCAPI_CHECK_VERSION(11, 1)
 # if defined(_WIN32) || defined(__CYGWIN__)
 const char *minver = "471.41";
@@ -658,6 +664,11 @@ static av_cold int nvenc_setup_device(AVCodecContext 
*avctx)
 

Re: [FFmpeg-devel] [PATCH] lavfi/vf_fieldmatch: keep fields as-is if not matched properly

2022-11-04 Thread Paul B Mahol
On 11/3/22, m...@nodoa.me  wrote:
> Makes it possible to use deinterlacers which output one frame for each field
> as fallback if field
> matching fails (combmatch=full).
>
> Currently, the documented example with fallback on a post-deinterlacer will
> only work in case the
> deinterlacer outputs one frame per first field (as yadif=mode=0). The reason
> for that is that
> fieldmatch will attempt to match the second field regardless of whether it
> recognizes the end
> result is still interlaced. This produces garbled output with for example
> mixed telecined 24fps and
> 60i content combined with a field-based deinterlaced such as yadif=mode=1.
> This patch orders fieldmatch to revert to using the second field of the
> current frame in case the
> end result is still interlaced and a post-deinterlacer is assumed to be
> used.
>

Are there samples, ways to reproduce this?

> Signed-off-by: lovesyk 
> ---
>  libavfilter/vf_fieldmatch.c | 10 --
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/libavfilter/vf_fieldmatch.c b/libavfilter/vf_fieldmatch.c
> index 40e559df9e..bf946beec9 100644
> --- a/libavfilter/vf_fieldmatch.c
> +++ b/libavfilter/vf_fieldmatch.c
> @@ -680,7 +680,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
> *in)
>  AVFilterLink *outlink = ctx->outputs[0];
>  FieldMatchContext *fm = ctx->priv;
>  int combs[] = { -1, -1, -1, -1, -1 };
> -int order, field, i, match, sc = 0, ret = 0;
> +int order, field, i, match, interlaced_frame, sc = 0, ret = 0;
>  const int *fxo;
>  AVFrame *gen_frames[] = { NULL, NULL, NULL, NULL, NULL };
>  AVFrame *dst = NULL;
> @@ -793,6 +793,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
> *in)
>  }
>  }
>
> +/* keep fields as-is if not matched properly */
> +interlaced_frame = combs[match] >= fm->combpel;
> +if (interlaced_frame && fm->combmatch == COMBMATCH_FULL) {
> +match = mC;
> +}
> +
>  /* get output frame and drop the others */
>  if (fm->ppsrc) {
>  /* field matching was based on a filtered/post-processed input, we
> now
> @@ -813,7 +819,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
> *in)
>
>  /* mark the frame we are unable to match properly as interlaced so a
> proper
>   * de-interlacer can take the relay */
> -dst->interlaced_frame = combs[match] >= fm->combpel;
> +dst->interlaced_frame = interlaced_frame;
>  if (dst->interlaced_frame) {
>  av_log(ctx, AV_LOG_WARNING, "Frame #%"PRId64" at %s is still
> interlaced\n",
> outlink->frame_count_in, av_ts2timestr(in->pts,
> &inlink->time_base));
> --
> 2.34.2
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-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".


[FFmpeg-devel] [crop support for matroska demuxer, V4 1/3] libavcodec: Add crop related fields to structure AVCodecContext and AVCodecParameters.

2022-11-04 Thread OvchinnikovDmitrii
---
 libavcodec/avcodec.h   | 35 +++
 libavcodec/codec_par.h |  8 
 libavcodec/options_table.h |  4 
 3 files changed, 47 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 3edd8e2636..57b340c24d 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -380,6 +380,19 @@ typedef struct RcOverride{
  */
 #define AV_GET_ENCODE_BUFFER_FLAG_REF (1 << 0)
 
+/**
+* Video decoding only. Certain container support cropping, meaning that
+* only a sub-rectangle of the decoded frame is intended for display.
+* Certain codec supports cropping as well.This option controls how
+* cropping is handled by libavcodec when  container cropping and
+* codec cropping exist.
+*/
+enum CONTAINER_CROPPING_POLICY_TYPE {
+FF_CONTAINER_CROPPING_IGNORE = 0,
+FF_CONTAINER_CROPPING_ADDITION,
+FF_CONTAINER_CROPPING_OVERWRITE
+};
+
 struct AVCodecInternal;
 
 /**
@@ -2057,6 +2070,28 @@ typedef struct AVCodecContext {
  * The decoder can then override during decoding as needed.
  */
 AVChannelLayout ch_layout;
+
+/* When set to 1 (the default), libavcodec will apply container cropping
+ * to codec cropping additionally.
+ *
+ * When set to 2, libavcodec will use container cropping to overwrite
+ * codec cropping (the final cropping uses container cropping parameters)
+ *
+ * When set to 0, libavcodec will ignore container cropping parameters
+ * (the final cropping uses codec cropping parameters)
+ *
+ * This field works with "apply_cropping". Only if apply_cropping is 1, 
this
+ * field works
+ */
+enum CONTAINER_CROPPING_POLICY_TYPE container_apply_cropping;
+
+/**
+ * The cropping parameters from container.
+ */
+int container_crop_top;
+int container_crop_left;
+int container_crop_bottom;
+int container_crop_right;
 } AVCodecContext;
 
 /**
diff --git a/libavcodec/codec_par.h b/libavcodec/codec_par.h
index f51d27c590..cc0695689c 100644
--- a/libavcodec/codec_par.h
+++ b/libavcodec/codec_par.h
@@ -211,6 +211,14 @@ typedef struct AVCodecParameters {
  * Audio only. The channel layout and number of channels.
  */
 AVChannelLayout ch_layout;
+
+/**
+ * The cropping parameters from container.
+ */
+int container_crop_top;
+int container_crop_left;
+int container_crop_bottom;
+int container_crop_right;
 } AVCodecParameters;
 
 /**
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index cd02f5096f..fd1ef21f90 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -401,6 +401,10 @@ static const AVOption avcodec_options[] = {
 {"allow_profile_mismatch", "attempt to decode anyway if HW accelerated 
decoder's supported profiles do not exactly match the stream", 0, 
AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH }, INT_MIN, 
INT_MAX, V | D, "hwaccel_flags"},
 {"extra_hw_frames", "Number of extra hardware frames to allocate for the 
user", OFFSET(extra_hw_frames), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, 
V|D },
 {"discard_damaged_percentage", "Percentage of damaged samples to discard a 
frame", OFFSET(discard_damaged_percentage), AV_OPT_TYPE_INT, {.i64 = 95 }, 0, 
100, V|D },
+{ "container_apply_cropping", "ploicy using container cropping parameters", 
OFFSET(container_apply_cropping), AV_OPT_TYPE_INT64, {.i64 = 
FF_CONTAINER_CROPPING_ADDITION }, 0, 2, V | D, "container_apply_cropping" },
+{ "ignore","ignore container cropping",
   0, AV_OPT_TYPE_CONST, {.i64 = FF_CONTAINER_CROPPING_IGNORE },0, 0, V 
| D, "container_apply_cropping" },
+{ "addition",  "apply container cropping additionally to elementary stream 
cropping", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CONTAINER_CROPPING_ADDITION },  0, 
0, V | D, "container_apply_cropping" },
+{ "overwrite", "use container cropping to overwrite elementary stream 
cropping",  0, AV_OPT_TYPE_CONST, {.i64 = FF_CONTAINER_CROPPING_OVERWRITE 
}, 0, 0, V | D, "container_apply_cropping" },
 {NULL},
 };
 
-- 
2.30.0.windows.2

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

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


[FFmpeg-devel] [crop support for matroska demuxer, V4 2/3] libavcodec: Public code to support container crop

2022-11-04 Thread OvchinnikovDmitrii
Support both simple and receive_frame api
The container crop information is applied additional to frame crop information
---
 libavcodec/codec_par.c | 30 ++-
 libavcodec/decode.c| 54 ++
 2 files changed, 73 insertions(+), 11 deletions(-)

diff --git a/libavcodec/codec_par.c b/libavcodec/codec_par.c
index abda649aa8..9738402434 100644
--- a/libavcodec/codec_par.c
+++ b/libavcodec/codec_par.c
@@ -115,17 +115,21 @@ int avcodec_parameters_from_context(AVCodecParameters 
*par,
 
 switch (par->codec_type) {
 case AVMEDIA_TYPE_VIDEO:
-par->format  = codec->pix_fmt;
-par->width   = codec->width;
-par->height  = codec->height;
-par->field_order = codec->field_order;
-par->color_range = codec->color_range;
-par->color_primaries = codec->color_primaries;
-par->color_trc   = codec->color_trc;
-par->color_space = codec->colorspace;
-par->chroma_location = codec->chroma_sample_location;
-par->sample_aspect_ratio = codec->sample_aspect_ratio;
-par->video_delay = codec->has_b_frames;
+par->format= codec->pix_fmt;
+par->width = codec->width;
+par->height= codec->height;
+par->container_crop_top= codec->container_crop_top;
+par->container_crop_left   = codec->container_crop_left;
+par->container_crop_bottom = codec->container_crop_bottom;
+par->container_crop_right  = codec->container_crop_right;
+par->field_order   = codec->field_order;
+par->color_range   = codec->color_range;
+par->color_primaries   = codec->color_primaries;
+par->color_trc = codec->color_trc;
+par->color_space   = codec->colorspace;
+par->chroma_location   = codec->chroma_sample_location;
+par->sample_aspect_ratio   = codec->sample_aspect_ratio;
+par->video_delay   = codec->has_b_frames;
 break;
 case AVMEDIA_TYPE_AUDIO:
 par->format   = codec->sample_fmt;
@@ -199,6 +203,10 @@ int avcodec_parameters_to_context(AVCodecContext *codec,
 codec->pix_fmt= par->format;
 codec->width  = par->width;
 codec->height = par->height;
+codec->container_crop_top = par->container_crop_top;
+codec->container_crop_left= par->container_crop_left;
+codec->container_crop_bottom  = par->container_crop_bottom;
+codec->container_crop_right   = par->container_crop_right;
 codec->field_order= par->field_order;
 codec->color_range= par->color_range;
 codec->color_primaries= par->color_primaries;
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 6be2d3d6ed..9e44fcb293 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -693,6 +693,60 @@ static int apply_cropping(AVCodecContext *avctx, AVFrame 
*frame)
 if (!avctx->apply_cropping)
 return 0;
 
+if (avctx->container_apply_cropping == FF_CONTAINER_CROPPING_ADDITION)
+{
+/*check if container parameter and elementary streaming cropping 
parameters are safe for applying  */
+if (avctx->container_crop_left + frame->crop_left>= INT_MAX - 
(avctx->container_crop_right + frame->crop_right) ||
+avctx->container_crop_top + frame->crop_top >= INT_MAX - 
(avctx->container_crop_bottom + frame->crop_bottom) ||
+(avctx->container_crop_left + frame->crop_left + 
avctx->container_crop_right + frame->crop_right) >= frame->width ||
+(avctx->container_crop_top + frame->crop_top + 
avctx->container_crop_bottom + frame->crop_bottom) >= frame->height) {
+av_log(avctx, AV_LOG_WARNING,
+"Apply container  and elementary stream corpping parametes 
error: "
+"container cropping parameters"
+
"%"SIZE_SPECIFIER"/%"SIZE_SPECIFIER"/%"SIZE_SPECIFIER"/%"SIZE_SPECIFIER" "
+"elementary stream croping paramters"
+
"%"SIZE_SPECIFIER"/%"SIZE_SPECIFIER"/%"SIZE_SPECIFIER"/%"SIZE_SPECIFIER" "
+"(frame size %dx%d). This is a bug, please report it\n",
+avctx->container_crop_left, avctx->container_crop_right, 
avctx->container_crop_top, avctx->container_crop_bottom,
+frame->crop_left, frame->crop_right, frame->crop_top, 
frame->crop_bottom,
+frame->width, frame->height);
+frame->crop_left   = 0;
+frame->crop_right  = 0;
+frame->crop_top= 0;
+frame->crop_bottom = 0;
+return 0;
+}
+
+frame->crop_top+= avctx->container_crop_top;
+frame->crop_left   += avctx->container_crop_left;
+frame->

[FFmpeg-devel] [crop support for matroska demuxer, V4 3/3] libavformat\matroskadec.c: crop support for matroska demuxer.

2022-11-04 Thread OvchinnikovDmitrii
In webm specification, it supports cropping information. 
(https://www.webmproject.org/docs/container/)
In ffmpeg, the implementation of webm is a subset of matroska. In 
matroskadec.c, those cropping related four fields are forced to 0.

for the sample file with crop (crop_bottom =8, crop_top=crop_left=crop_right=0.)
ffmpeg.exe -i  test_with_container_crop.webm -pix_fmt yuv420p -y output.yuv

original ffmpeg code - the output.yuv resolution is 1920x1088
changed code - the output.yuv resolution is 1920x1080

Previous discussion 
:https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=7668
---
 libavformat/matroskadec.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index d582f566a2..2023fd4977 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -210,6 +210,10 @@ typedef struct MatroskaTrackVideo {
 uint64_t pixel_width;
 uint64_t pixel_height;
 EbmlBin  color_space;
+uint64_t pixel_cropt;
+uint64_t pixel_cropl;
+uint64_t pixel_cropb;
+uint64_t pixel_cropr;
 uint64_t display_unit;
 uint64_t interlaced;
 uint64_t field_order;
@@ -517,10 +521,10 @@ static EbmlSyntax matroska_track_video[] = {
 { MATROSKA_ID_VIDEOALPHAMODE,  EBML_UINT,  0, 0, 
offsetof(MatroskaTrackVideo, alpha_mode), { .u = 0 } },
 { MATROSKA_ID_VIDEOCOLOR,  EBML_NEST,  0, 
sizeof(MatroskaTrackVideoColor), offsetof(MatroskaTrackVideo, color), { .n = 
matroska_track_video_color } },
 { MATROSKA_ID_VIDEOPROJECTION, EBML_NEST,  0, 0, 
offsetof(MatroskaTrackVideo, projection), { .n = 
matroska_track_video_projection } },
-{ MATROSKA_ID_VIDEOPIXELCROPB, EBML_NONE },
-{ MATROSKA_ID_VIDEOPIXELCROPT, EBML_NONE },
-{ MATROSKA_ID_VIDEOPIXELCROPL, EBML_NONE },
-{ MATROSKA_ID_VIDEOPIXELCROPR, EBML_NONE },
+{ MATROSKA_ID_VIDEOPIXELCROPT, EBML_UINT,  0, 0, 
offsetof(MatroskaTrackVideo, pixel_cropt), {.u = 0 } },
+{ MATROSKA_ID_VIDEOPIXELCROPL, EBML_UINT,  0, 0, 
offsetof(MatroskaTrackVideo, pixel_cropl), {.u = 0 } },
+{ MATROSKA_ID_VIDEOPIXELCROPB, EBML_UINT,  0, 0, 
offsetof(MatroskaTrackVideo, pixel_cropb), {.u = 0 } },
+{ MATROSKA_ID_VIDEOPIXELCROPR, EBML_UINT,  0, 0, 
offsetof(MatroskaTrackVideo, pixel_cropr), {.u = 0 } },
 { MATROSKA_ID_VIDEODISPLAYUNIT,EBML_UINT,  0, 0, 
offsetof(MatroskaTrackVideo, display_unit), { .u= 
MATROSKA_VIDEO_DISPLAYUNIT_PIXELS } },
 { MATROSKA_ID_VIDEOFLAGINTERLACED, EBML_UINT,  0, 0, 
offsetof(MatroskaTrackVideo, interlaced),  { .u = 
MATROSKA_VIDEO_INTERLACE_FLAG_UNDETERMINED } },
 { MATROSKA_ID_VIDEOFIELDORDER, EBML_UINT,  0, 0, 
offsetof(MatroskaTrackVideo, field_order), { .u = 
MATROSKA_VIDEO_FIELDORDER_UNDETERMINED } },
@@ -2879,6 +2883,11 @@ static int matroska_parse_tracks(AVFormatContext *s)
 st->codecpar->width  = track->video.pixel_width;
 st->codecpar->height = track->video.pixel_height;
 
+st->codecpar->container_crop_top= track->video.pixel_cropt;
+st->codecpar->container_crop_left   = track->video.pixel_cropl;
+st->codecpar->container_crop_bottom = track->video.pixel_cropb;
+st->codecpar->container_crop_right  = track->video.pixel_cropr;
+
 if (track->video.interlaced == 
MATROSKA_VIDEO_INTERLACE_FLAG_INTERLACED)
 st->codecpar->field_order = mkv_field_order(matroska, 
track->video.field_order);
 else if (track->video.interlaced == 
MATROSKA_VIDEO_INTERLACE_FLAG_PROGRESSIVE)
-- 
2.30.0.windows.2

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

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


Re: [FFmpeg-devel] FFmpeg 5.2 ?

2022-11-04 Thread Artem Galin
DTS to PTS reorder bsf, threading changes, ddagrab, oneVPL support with AV1 HW
encode for new ARC Gfx as well as DX11 for QSV are valuable items for next
5.2 release

On Fri, 4 Nov 2022 at 14:10, Michael Niedermayer 
wrote:

> On Fri, Nov 04, 2022 at 11:30:38AM +0100, Jean-Baptiste Kempf wrote:
> > On Thu, 3 Nov 2022, at 22:59, Michael Niedermayer wrote:
> > > do we want a release/5.2 branch made in december ?
> >
> > Based on what? Master or 5.1?
>
> new release branches are cut from master
> it seems not a great idea ATM though so iam asking what people want
> as the previous plans where for one in december. These plans just
> dont seem that great with the LTS prior
>
> So question for december is:
> 5.2 in December / 5.2 in June / 5.2 in January
>
> and then next we could do: (if we go with 2 releases per year)
> [5.3 would be 5.2 in the 5.2 june case]
> A B C
> 2023 june   5.3 / 5.3 LTS / 6.0
> 2023 december   5.4 LTS / 5.4 / 6.1 LTS
>
> anyone has any other suggestions / comments?
>
> 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.
> ___
> 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] FFmpeg 5.2 ?

2022-11-04 Thread Paul B Mahol
On 11/4/22, Artem Galin  wrote:
> DTS to PTS reorder bsf, threading changes, ddagrab, oneVPL support with AV1
> HW
> encode for new ARC Gfx as well as DX11 for QSV are valuable items for next
> 5.2 release

Yes, anything else is not valuable at all and should be removed.

>
> On Fri, 4 Nov 2022 at 14:10, Michael Niedermayer 
> wrote:
>
>> On Fri, Nov 04, 2022 at 11:30:38AM +0100, Jean-Baptiste Kempf wrote:
>> > On Thu, 3 Nov 2022, at 22:59, Michael Niedermayer wrote:
>> > > do we want a release/5.2 branch made in december ?
>> >
>> > Based on what? Master or 5.1?
>>
>> new release branches are cut from master
>> it seems not a great idea ATM though so iam asking what people want
>> as the previous plans where for one in december. These plans just
>> dont seem that great with the LTS prior
>>
>> So question for december is:
>> 5.2 in December / 5.2 in June / 5.2 in January
>>
>> and then next we could do: (if we go with 2 releases per year)
>> [5.3 would be 5.2 in the 5.2 june case]
>> A B C
>> 2023 june   5.3 / 5.3 LTS / 6.0
>> 2023 december   5.4 LTS / 5.4 / 6.1 LTS
>>
>> anyone has any other suggestions / comments?
>>
>> 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.
>> ___
>> 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".
>
___
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] lavfi/vf_fieldmatch: keep fields as-is if not matched properly

2022-11-04 Thread mail
This is reproducible using for example
https://samples.ffmpeg.org/MPEG2/interlaced/burosch1.mpg

ffmpeg -i burosch1.mpg -map 0:v -c:v libx264 -vf
fieldmatch=combmatch=full,yadif=mode=1:deint=interlaced -preset veryfast
-crf 10 burosch1.mp4

The end result will be in 50p and without the patch randomly have the frames
in the wrong order.

___
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] MAINTAINERS: add myself as amfenc* maintainer

2022-11-04 Thread OvchinnikovDmitrii
Due to the lack of an active AMF maintainer at the moment, as well as plans to 
add the av1 encoder and other improvements of AMF, I added myself to the 
maintainers. Timely review and merging patches targeting AMF integration should 
improve support of AMD dGPUs and APUs in FFmpeg
For the last couple of years I have been working on AMF related patches to 
ffmpeg and other open source projects.
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index eebfa5cfb7..4f54a1dea3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -215,6 +215,7 @@ Codecs:
   msvideo1.cMike Melanson
   nuv.c Reimar Doeffinger
   nvdec*, nvenc*Timo Rothenpieler
+  amfenc*   Dmitrii Ovchinnikov
   omx.c Martin Storsjo, Aman Gupta
   opus* Rostislav Pehlivanov
   paf.* Paul B Mahol
-- 
2.30.0.windows.2

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

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


[FFmpeg-devel] [PATCH, v2] MAINTAINERS: add myself as amfenc* maintainer

2022-11-04 Thread OvchinnikovDmitrii


Due to the lack of an active AMF maintainer at the moment, as well 
as plans to add the av1 encoder and other improvements of AMF, 
I added myself to the maintainers. Timely review and merging 
patches targeting AMF integration should improve support 
of AMD GPUs and APUs in FFmpeg.
For the last couple of years I have been working on AMF related 
patches to ffmpeg and other open source projects.
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index eebfa5cfb7..4f54a1dea3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -215,6 +215,7 @@ Codecs:
   msvideo1.cMike Melanson
   nuv.c Reimar Doeffinger
   nvdec*, nvenc*Timo Rothenpieler
+  amfenc*   Dmitrii Ovchinnikov
   omx.c Martin Storsjo, Aman Gupta
   opus* Rostislav Pehlivanov
   paf.* Paul B Mahol
-- 
2.30.0.windows.2

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

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


[FFmpeg-devel] [PATCH, v3] MAINTAINERS: add myself as amfenc* maintainer

2022-11-04 Thread OvchinnikovDmitrii
Due to the lack of an active AMF maintainer at the moment, as well
as plans to add the av1 encoder and other improvements of AMF,
I added myself to the maintainers. Timely review and merging
patches targeting AMF integration should improve support
of AMD GPUs and APUs in FFmpeg.
For the last couple of years I have been working on AMF related
patches to ffmpeg and other open source projects.
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index eebfa5cfb7..2bc6613a83 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -136,6 +136,7 @@ Codecs:
   adpcm.c   Zane van Iperen
   alacenc.c Jaikrishnan Menon
   alsdec.c  Thilo Borgmann, Umair Khan
+  amfenc*   Dmitrii Ovchinnikov
   aptx.cAurelien Jacobs
   ass*  Aurelien Jacobs
   asv*  Michael Niedermayer
-- 
2.30.0.windows.2

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

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


Re: [FFmpeg-devel] [PATCH] avfilter: add backgroundkey video filter

2022-11-04 Thread Paul B Mahol
On 11/2/22, Paul B Mahol  wrote:
> On 10/30/22, Paul B Mahol  wrote:
>> Patch attached.
>>
>
> Improved patch attached.
>

Another improvement.
From 5fed074cc24a201c0789a0757dca8710ef5f5c05 Mon Sep 17 00:00:00 2001
From: Paul B Mahol 
Date: Fri, 28 Oct 2022 22:02:29 +0200
Subject: [PATCH] avfilter: add backgroundkey video filter

Signed-off-by: Paul B Mahol 
---
 doc/filters.texi   |  19 +++
 libavfilter/Makefile   |   1 +
 libavfilter/allfilters.c   |   1 +
 libavfilter/vf_backgroundkey.c | 253 +
 4 files changed, 274 insertions(+)
 create mode 100644 libavfilter/vf_backgroundkey.c

diff --git a/doc/filters.texi b/doc/filters.texi
index 006173ba47..75d771ef4a 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -7987,6 +7987,25 @@ The command accepts the same syntax of the corresponding option.
 If the specified expression is not valid, it is kept at its current
 value.
 
+@section backgroundkey
+
+Turns a static background into transparency.
+
+The filter accepts the following option:
+
+@table @option
+@item threshold
+Threshold for scene change detection.
+@item similarity
+Similarity percentage with the background.
+@item blend
+Set the blend amount for pixels that are not similar.
+@end table
+
+@subsection Commands
+This filter supports same @ref{commands} as options except option @code{s}.
+The command accepts the same syntax of the corresponding option.
+
 @section bbox
 
 Compute the bounding box for the non-black pixels in the input frame
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 195e616ccc..0e971d5c3e 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -192,6 +192,7 @@ OBJS-$(CONFIG_AVGBLUR_FILTER)+= vf_avgblur.o
 OBJS-$(CONFIG_AVGBLUR_OPENCL_FILTER) += vf_avgblur_opencl.o opencl.o \
 opencl/avgblur.o boxblur.o
 OBJS-$(CONFIG_AVGBLUR_VULKAN_FILTER) += vf_avgblur_vulkan.o vulkan.o vulkan_filter.o
+OBJS-$(CONFIG_BACKGROUNDKEY_FILTER)  += vf_backgroundkey.o
 OBJS-$(CONFIG_BBOX_FILTER)   += bbox.o vf_bbox.o
 OBJS-$(CONFIG_BENCH_FILTER)  += f_bench.o
 OBJS-$(CONFIG_BILATERAL_FILTER)  += vf_bilateral.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 97225a3679..1e0391f7a4 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -178,6 +178,7 @@ extern const AVFilter ff_vf_atadenoise;
 extern const AVFilter ff_vf_avgblur;
 extern const AVFilter ff_vf_avgblur_opencl;
 extern const AVFilter ff_vf_avgblur_vulkan;
+extern const AVFilter ff_vf_backgroundkey;
 extern const AVFilter ff_vf_bbox;
 extern const AVFilter ff_vf_bench;
 extern const AVFilter ff_vf_bilateral;
diff --git a/libavfilter/vf_backgroundkey.c b/libavfilter/vf_backgroundkey.c
new file mode 100644
index 00..0df6d0f4d6
--- /dev/null
+++ b/libavfilter/vf_backgroundkey.c
@@ -0,0 +1,253 @@
+/*
+ * 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, MA 02110-1301 USA
+ */
+
+#include "libavutil/opt.h"
+#include "libavutil/imgutils.h"
+#include "avfilter.h"
+#include "formats.h"
+#include "internal.h"
+#include "video.h"
+
+typedef struct BackgroundkeyContext {
+const AVClass *class;
+
+float threshold;
+float similarity;
+float blend;
+int max;
+
+int nb_threads;
+int hsub_log2;
+int vsub_log2;
+
+int64_t max_sum;
+int64_t *sums;
+
+AVFrame *background;
+
+int (*do_slice)(AVFilterContext *avctx, void *arg,
+int jobnr, int nb_jobs);
+} BackgroundkeyContext;
+
+static int do_backgroundkey_slice(AVFilterContext *avctx, void *arg, int jobnr, int nb_jobs)
+{
+BackgroundkeyContext *s = avctx->priv;
+AVFrame *frame = arg;
+const int slice_start = (frame->height * jobnr) / nb_jobs;
+const int slice_end = (frame->height * (jobnr + 1)) / nb_jobs;
+const int min_diff = (255 + 255 + 255) * s->similarity;
+const float blend = s->blend;
+const int hsub = s->hsub_log2;
+const int vsub = s->vsub_log2;
+int64_t sum = 0;
+
+for (int y = slice_start; y < slice_end; y++) {
+const uint8_t *srcy = frame->data[0] + frame->linesize[0] * y;
+const uint8_t *srcu = frame->data[1] + frame->linesize[1] *

Re: [FFmpeg-devel] [PATCH, v3] MAINTAINERS: add myself as amfenc* maintainer

2022-11-04 Thread Timo Rothenpieler

On 04.11.2022 19:57, OvchinnikovDmitrii wrote:

Due to the lack of an active AMF maintainer at the moment, as well
as plans to add the av1 encoder and other improvements of AMF,
I added myself to the maintainers. Timely review and merging
patches targeting AMF integration should improve support
of AMD GPUs and APUs in FFmpeg.
For the last couple of years I have been working on AMF related
patches to ffmpeg and other open source projects.


LGTM from me

One note: The usual format FFmpeg follows for the commit Author is 
"Firstname Lastname ".
You're close enough, so it hardly matters. But something to keep in mind 
for future patches.

___
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, v3] MAINTAINERS: add myself as amfenc* maintainer

2022-11-04 Thread Soft Works



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> OvchinnikovDmitrii
> Sent: Friday, November 4, 2022 7:58 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: OvchinnikovDmitrii 
> Subject: [FFmpeg-devel] [PATCH, v3] MAINTAINERS: add myself as
> amfenc* maintainer
> 
> Due to the lack of an active AMF maintainer at the moment, as well
> as plans to add the av1 encoder and other improvements of AMF,
> I added myself to the maintainers. Timely review and merging
> patches targeting AMF integration should improve support
> of AMD GPUs and APUs in FFmpeg.
> For the last couple of years I have been working on AMF related
> patches to ffmpeg and other open source projects.

Considering the lack of ambition in the past, I think there's
no point in waiting for AMD to come around, and having a maintainer
would surely be beneficial, hence
LGTM.

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