* [FFmpeg-devel] [PATCH 02/10] avfilter/af_afir: Move ff_afir_init() to header
2022-05-03 6:18 [FFmpeg-devel] [PATCH 01/10] avfilter/af_afir: Only keep DSP stuff in header Andreas Rheinhardt
@ 2022-05-03 6:37 ` Andreas Rheinhardt
2022-05-03 6:37 ` [FFmpeg-devel] [PATCH 03/10] avfilter/vf_blend: Move ff_blend_init into a header Andreas Rheinhardt
` (8 subsequent siblings)
9 siblings, 0 replies; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-05-03 6:37 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
This allows to inline it in af_afir.c (regardless of interposing);
moreover it removes a dependency of the checkasm test on
lavfi/af_afir.o.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavfilter/af_afir.c | 25 -------------------------
libavfilter/af_afirdsp.h | 29 ++++++++++++++++++++++++++++-
2 files changed, 28 insertions(+), 26 deletions(-)
diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c
index d7ae468428..301553575f 100644
--- a/libavfilter/af_afir.c
+++ b/libavfilter/af_afir.c
@@ -110,23 +110,6 @@ typedef struct AudioFIRContext {
AVFloatDSPContext *fdsp;
} AudioFIRContext;
-static void fcmul_add_c(float *sum, const float *t, const float *c, ptrdiff_t len)
-{
- int n;
-
- for (n = 0; n < len; n++) {
- const float cre = c[2 * n ];
- const float cim = c[2 * n + 1];
- const float tre = t[2 * n ];
- const float tim = t[2 * n + 1];
-
- sum[2 * n ] += tre * cre - tim * cim;
- sum[2 * n + 1] += tre * cim + tim * cre;
- }
-
- sum[2 * n] += t[2 * n] * c[2 * n];
-}
-
static void direct(const float *in, const AVComplexFloat *ir, int len, float *out)
{
for (int n = 0; n < len; n++)
@@ -884,14 +867,6 @@ static int config_video(AVFilterLink *outlink)
return 0;
}
-void ff_afir_init(AudioFIRDSPContext *dsp)
-{
- dsp->fcmul_add = fcmul_add_c;
-
- if (ARCH_X86)
- ff_afir_init_x86(dsp);
-}
-
static av_cold int init(AVFilterContext *ctx)
{
AudioFIRContext *s = ctx->priv;
diff --git a/libavfilter/af_afirdsp.h b/libavfilter/af_afirdsp.h
index f72ab7cd02..05182bebb4 100644
--- a/libavfilter/af_afirdsp.h
+++ b/libavfilter/af_afirdsp.h
@@ -23,12 +23,39 @@
#include <stddef.h>
+#include "config.h"
+#include "libavutil/attributes.h"
+
typedef struct AudioFIRDSPContext {
void (*fcmul_add)(float *sum, const float *t, const float *c,
ptrdiff_t len);
} AudioFIRDSPContext;
-void ff_afir_init(AudioFIRDSPContext *s);
void ff_afir_init_x86(AudioFIRDSPContext *s);
+static void fcmul_add_c(float *sum, const float *t, const float *c, ptrdiff_t len)
+{
+ int n;
+
+ for (n = 0; n < len; n++) {
+ const float cre = c[2 * n ];
+ const float cim = c[2 * n + 1];
+ const float tre = t[2 * n ];
+ const float tim = t[2 * n + 1];
+
+ sum[2 * n ] += tre * cre - tim * cim;
+ sum[2 * n + 1] += tre * cim + tim * cre;
+ }
+
+ sum[2 * n] += t[2 * n] * c[2 * n];
+}
+
+static av_unused void ff_afir_init(AudioFIRDSPContext *dsp)
+{
+ dsp->fcmul_add = fcmul_add_c;
+
+ if (ARCH_X86)
+ ff_afir_init_x86(dsp);
+}
+
#endif /* AVFILTER_AFIRDSP_H */
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 21+ messages in thread
* [FFmpeg-devel] [PATCH 03/10] avfilter/vf_blend: Move ff_blend_init into a header
2022-05-03 6:18 [FFmpeg-devel] [PATCH 01/10] avfilter/af_afir: Only keep DSP stuff in header Andreas Rheinhardt
2022-05-03 6:37 ` [FFmpeg-devel] [PATCH 02/10] avfilter/af_afir: Move ff_afir_init() to header Andreas Rheinhardt
@ 2022-05-03 6:37 ` Andreas Rheinhardt
2022-05-03 6:37 ` [FFmpeg-devel] [PATCH 04/10] avfilter/vf_eq: Move ff_nlmeans_init " Andreas Rheinhardt
` (7 subsequent siblings)
9 siblings, 0 replies; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-05-03 6:37 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
This removes a dependency of checkasm on lavfi/vf_blend.o
and also allows to inline ff_blend_init() irrespectively of
interposing.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavfilter/blend.h | 1 -
libavfilter/vf_blend.c | 176 +------------------------------
libavfilter/vf_blend_init.h | 201 ++++++++++++++++++++++++++++++++++++
tests/checkasm/vf_blend.c | 2 +-
4 files changed, 203 insertions(+), 177 deletions(-)
create mode 100644 libavfilter/vf_blend_init.h
diff --git a/libavfilter/blend.h b/libavfilter/blend.h
index ff417650cf..b046e062bc 100644
--- a/libavfilter/blend.h
+++ b/libavfilter/blend.h
@@ -81,7 +81,6 @@ typedef struct FilterParams {
struct FilterParams *param, double *values, int starty);
} FilterParams;
-void ff_blend_init(FilterParams *param, int depth);
void ff_blend_init_x86(FilterParams *param, int depth);
#endif /* AVFILTER_BLEND_H */
diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c
index c882086c51..dfe2b8b174 100644
--- a/libavfilter/vf_blend.c
+++ b/libavfilter/vf_blend.c
@@ -20,48 +20,19 @@
#include "config_components.h"
-#include "libavutil/imgutils.h"
-#include "libavutil/intfloat.h"
#include "libavutil/eval.h"
#include "libavutil/opt.h"
#include "libavutil/pixfmt.h"
#include "avfilter.h"
-#include "formats.h"
#include "framesync.h"
#include "internal.h"
+#include "vf_blend_init.h"
#include "video.h"
#include "blend.h"
#define TOP 0
#define BOTTOM 1
-#define DEPTH 8
-#include "blend_modes.c"
-
-#undef DEPTH
-#define DEPTH 9
-#include "blend_modes.c"
-
-#undef DEPTH
-#define DEPTH 10
-#include "blend_modes.c"
-
-#undef DEPTH
-#define DEPTH 12
-#include "blend_modes.c"
-
-#undef DEPTH
-#define DEPTH 14
-#include "blend_modes.c"
-
-#undef DEPTH
-#define DEPTH 16
-#include "blend_modes.c"
-
-#undef DEPTH
-#define DEPTH 32
-#include "blend_modes.c"
-
typedef struct BlendContext {
const AVClass *class;
FFFrameSync fs;
@@ -155,58 +126,6 @@ static const AVOption blend_options[] = {
FRAMESYNC_DEFINE_CLASS(blend, BlendContext, fs);
-#define COPY(src, depth) \
-static void blend_copy ## src##_##depth(const uint8_t *top, ptrdiff_t top_linesize, \
- const uint8_t *bottom, ptrdiff_t bottom_linesize,\
- uint8_t *dst, ptrdiff_t dst_linesize, \
- ptrdiff_t width, ptrdiff_t height, \
- FilterParams *param, double *values, int starty) \
-{ \
- av_image_copy_plane(dst, dst_linesize, src, src ## _linesize, \
- width * depth / 8, height); \
-}
-
-COPY(top, 8)
-COPY(bottom, 8)
-
-COPY(top, 16)
-COPY(bottom, 16)
-
-COPY(top, 32)
-COPY(bottom, 32)
-
-#undef COPY
-
-#define BLEND_NORMAL(name, type) \
-static void blend_normal_##name(const uint8_t *_top, ptrdiff_t top_linesize, \
- const uint8_t *_bottom, ptrdiff_t bottom_linesize,\
- uint8_t *_dst, ptrdiff_t dst_linesize, \
- ptrdiff_t width, ptrdiff_t height, \
- FilterParams *param, double *values, int starty) \
-{ \
- const type *top = (type*)_top; \
- const type *bottom = (type*)_bottom; \
- type *dst = (type*)_dst; \
- const float opacity = param->opacity; \
- \
- dst_linesize /= sizeof(type); \
- top_linesize /= sizeof(type); \
- bottom_linesize /= sizeof(type); \
- \
- for (int i = 0; i < height; i++) { \
- for (int j = 0; j < width; j++) { \
- dst[j] = top[j] * opacity + bottom[j] * (1.f - opacity); \
- } \
- dst += dst_linesize; \
- top += top_linesize; \
- bottom += bottom_linesize; \
- } \
-}
-
-BLEND_NORMAL(8bit, uint8_t)
-BLEND_NORMAL(16bit, uint16_t)
-BLEND_NORMAL(32bit, float)
-
#define DEFINE_BLEND_EXPR(type, name, div) \
static void blend_expr_## name(const uint8_t *_top, ptrdiff_t top_linesize, \
const uint8_t *_bottom, ptrdiff_t bottom_linesize, \
@@ -365,99 +284,6 @@ static av_cold void uninit(AVFilterContext *ctx)
av_expr_free(s->params[i].e);
}
-#define DEFINE_INIT_BLEND_FUNC(depth, nbits) \
-static av_cold void init_blend_func_##depth##_##nbits##bit(FilterParams *param) \
-{ \
- switch (param->mode) { \
- case BLEND_ADDITION: param->blend = blend_addition_##depth##bit; break; \
- case BLEND_GRAINMERGE: param->blend = blend_grainmerge_##depth##bit; break; \
- case BLEND_AND: param->blend = blend_and_##depth##bit; break; \
- case BLEND_AVERAGE: param->blend = blend_average_##depth##bit; break; \
- case BLEND_BURN: param->blend = blend_burn_##depth##bit; break; \
- case BLEND_DARKEN: param->blend = blend_darken_##depth##bit; break; \
- case BLEND_DIFFERENCE: param->blend = blend_difference_##depth##bit; break; \
- case BLEND_GRAINEXTRACT: param->blend = blend_grainextract_##depth##bit; break; \
- case BLEND_DIVIDE: param->blend = blend_divide_##depth##bit; break; \
- case BLEND_DODGE: param->blend = blend_dodge_##depth##bit; break; \
- case BLEND_EXCLUSION: param->blend = blend_exclusion_##depth##bit; break; \
- case BLEND_EXTREMITY: param->blend = blend_extremity_##depth##bit; break; \
- case BLEND_FREEZE: param->blend = blend_freeze_##depth##bit; break; \
- case BLEND_GLOW: param->blend = blend_glow_##depth##bit; break; \
- case BLEND_HARDLIGHT: param->blend = blend_hardlight_##depth##bit; break; \
- case BLEND_HARDMIX: param->blend = blend_hardmix_##depth##bit; break; \
- case BLEND_HEAT: param->blend = blend_heat_##depth##bit; break; \
- case BLEND_LIGHTEN: param->blend = blend_lighten_##depth##bit; break; \
- case BLEND_LINEARLIGHT: param->blend = blend_linearlight_##depth##bit; break; \
- case BLEND_MULTIPLY: param->blend = blend_multiply_##depth##bit; break; \
- case BLEND_MULTIPLY128: param->blend = blend_multiply128_##depth##bit; break; \
- case BLEND_NEGATION: param->blend = blend_negation_##depth##bit; break; \
- case BLEND_NORMAL: param->blend = blend_normal_##nbits##bit; break; \
- case BLEND_OR: param->blend = blend_or_##depth##bit; break; \
- case BLEND_OVERLAY: param->blend = blend_overlay_##depth##bit; break; \
- case BLEND_PHOENIX: param->blend = blend_phoenix_##depth##bit; break; \
- case BLEND_PINLIGHT: param->blend = blend_pinlight_##depth##bit; break; \
- case BLEND_REFLECT: param->blend = blend_reflect_##depth##bit; break; \
- case BLEND_SCREEN: param->blend = blend_screen_##depth##bit; break; \
- case BLEND_SOFTLIGHT: param->blend = blend_softlight_##depth##bit; break; \
- case BLEND_SUBTRACT: param->blend = blend_subtract_##depth##bit; break; \
- case BLEND_VIVIDLIGHT: param->blend = blend_vividlight_##depth##bit; break; \
- case BLEND_XOR: param->blend = blend_xor_##depth##bit; break; \
- case BLEND_SOFTDIFFERENCE:param->blend=blend_softdifference_##depth##bit;break; \
- case BLEND_GEOMETRIC: param->blend = blend_geometric_##depth##bit; break; \
- case BLEND_HARMONIC: param->blend = blend_harmonic_##depth##bit; break; \
- case BLEND_BLEACH: param->blend = blend_bleach_##depth##bit; break; \
- case BLEND_STAIN: param->blend = blend_stain_##depth##bit; break; \
- case BLEND_INTERPOLATE: param->blend = blend_interpolate_##depth##bit; break; \
- case BLEND_HARDOVERLAY: param->blend = blend_hardoverlay_##depth##bit; break; \
- } \
-}
-DEFINE_INIT_BLEND_FUNC(8, 8)
-DEFINE_INIT_BLEND_FUNC(9, 16)
-DEFINE_INIT_BLEND_FUNC(10, 16)
-DEFINE_INIT_BLEND_FUNC(12, 16)
-DEFINE_INIT_BLEND_FUNC(14, 16)
-DEFINE_INIT_BLEND_FUNC(16, 16)
-DEFINE_INIT_BLEND_FUNC(32, 32)
-
-void ff_blend_init(FilterParams *param, int depth)
-{
- switch (depth) {
- case 8:
- init_blend_func_8_8bit(param);
- break;
- case 9:
- init_blend_func_9_16bit(param);
- break;
- case 10:
- init_blend_func_10_16bit(param);
- break;
- case 12:
- init_blend_func_12_16bit(param);
- break;
- case 14:
- init_blend_func_14_16bit(param);
- break;
- case 16:
- init_blend_func_16_16bit(param);
- break;
- case 32:
- init_blend_func_32_32bit(param);
- break;
- }
-
- if (param->opacity == 0 && param->mode != BLEND_NORMAL) {
- param->blend = depth > 8 ? depth > 16 ? blend_copytop_32 : blend_copytop_16 : blend_copytop_8;
- } else if (param->mode == BLEND_NORMAL) {
- if (param->opacity == 1)
- param->blend = depth > 8 ? depth > 16 ? blend_copytop_32 : blend_copytop_16 : blend_copytop_8;
- else if (param->opacity == 0)
- param->blend = depth > 8 ? depth > 16 ? blend_copybottom_32 : blend_copybottom_16 : blend_copybottom_8;
- }
-
- if (ARCH_X86)
- ff_blend_init_x86(param, depth);
-}
-
static int config_params(AVFilterContext *ctx)
{
BlendContext *s = ctx->priv;
diff --git a/libavfilter/vf_blend_init.h b/libavfilter/vf_blend_init.h
new file mode 100644
index 0000000000..5fb2599490
--- /dev/null
+++ b/libavfilter/vf_blend_init.h
@@ -0,0 +1,201 @@
+/*
+ * Copyright (c) 2013 Paul B Mahol
+ *
+ * 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
+ */
+
+#ifndef AVFILTER_BLEND_INIT_H
+#define AVFILTER_BLEND_INIT_H
+
+#include "config.h"
+#include "libavutil/attributes.h"
+#include "libavutil/imgutils.h"
+#include "blend.h"
+
+#define DEPTH 8
+#include "blend_modes.c"
+
+#undef DEPTH
+#define DEPTH 9
+#include "blend_modes.c"
+
+#undef DEPTH
+#define DEPTH 10
+#include "blend_modes.c"
+
+#undef DEPTH
+#define DEPTH 12
+#include "blend_modes.c"
+
+#undef DEPTH
+#define DEPTH 14
+#include "blend_modes.c"
+
+#undef DEPTH
+#define DEPTH 16
+#include "blend_modes.c"
+
+#undef DEPTH
+#define DEPTH 32
+#include "blend_modes.c"
+
+#define COPY(src, depth) \
+static void blend_copy ## src##_##depth(const uint8_t *top, ptrdiff_t top_linesize, \
+ const uint8_t *bottom, ptrdiff_t bottom_linesize,\
+ uint8_t *dst, ptrdiff_t dst_linesize, \
+ ptrdiff_t width, ptrdiff_t height, \
+ FilterParams *param, double *values, int starty) \
+{ \
+ av_image_copy_plane(dst, dst_linesize, src, src ## _linesize, \
+ width * depth / 8, height); \
+}
+
+COPY(top, 8)
+COPY(bottom, 8)
+
+COPY(top, 16)
+COPY(bottom, 16)
+
+COPY(top, 32)
+COPY(bottom, 32)
+
+#undef COPY
+
+#define BLEND_NORMAL(name, type) \
+static void blend_normal_##name(const uint8_t *_top, ptrdiff_t top_linesize, \
+ const uint8_t *_bottom, ptrdiff_t bottom_linesize,\
+ uint8_t *_dst, ptrdiff_t dst_linesize, \
+ ptrdiff_t width, ptrdiff_t height, \
+ FilterParams *param, double *values, int starty) \
+{ \
+ const type *top = (type*)_top; \
+ const type *bottom = (type*)_bottom; \
+ type *dst = (type*)_dst; \
+ const float opacity = param->opacity; \
+ \
+ dst_linesize /= sizeof(type); \
+ top_linesize /= sizeof(type); \
+ bottom_linesize /= sizeof(type); \
+ \
+ for (int i = 0; i < height; i++) { \
+ for (int j = 0; j < width; j++) { \
+ dst[j] = top[j] * opacity + bottom[j] * (1.f - opacity); \
+ } \
+ dst += dst_linesize; \
+ top += top_linesize; \
+ bottom += bottom_linesize; \
+ } \
+}
+
+BLEND_NORMAL(8bit, uint8_t)
+BLEND_NORMAL(16bit, uint16_t)
+BLEND_NORMAL(32bit, float)
+
+#define DEFINE_INIT_BLEND_FUNC(depth, nbits) \
+static av_cold void init_blend_func_##depth##_##nbits##bit(FilterParams *param) \
+{ \
+ switch (param->mode) { \
+ case BLEND_ADDITION: param->blend = blend_addition_##depth##bit; break; \
+ case BLEND_GRAINMERGE: param->blend = blend_grainmerge_##depth##bit; break; \
+ case BLEND_AND: param->blend = blend_and_##depth##bit; break; \
+ case BLEND_AVERAGE: param->blend = blend_average_##depth##bit; break; \
+ case BLEND_BURN: param->blend = blend_burn_##depth##bit; break; \
+ case BLEND_DARKEN: param->blend = blend_darken_##depth##bit; break; \
+ case BLEND_DIFFERENCE: param->blend = blend_difference_##depth##bit; break; \
+ case BLEND_GRAINEXTRACT: param->blend = blend_grainextract_##depth##bit; break; \
+ case BLEND_DIVIDE: param->blend = blend_divide_##depth##bit; break; \
+ case BLEND_DODGE: param->blend = blend_dodge_##depth##bit; break; \
+ case BLEND_EXCLUSION: param->blend = blend_exclusion_##depth##bit; break; \
+ case BLEND_EXTREMITY: param->blend = blend_extremity_##depth##bit; break; \
+ case BLEND_FREEZE: param->blend = blend_freeze_##depth##bit; break; \
+ case BLEND_GLOW: param->blend = blend_glow_##depth##bit; break; \
+ case BLEND_HARDLIGHT: param->blend = blend_hardlight_##depth##bit; break; \
+ case BLEND_HARDMIX: param->blend = blend_hardmix_##depth##bit; break; \
+ case BLEND_HEAT: param->blend = blend_heat_##depth##bit; break; \
+ case BLEND_LIGHTEN: param->blend = blend_lighten_##depth##bit; break; \
+ case BLEND_LINEARLIGHT: param->blend = blend_linearlight_##depth##bit; break; \
+ case BLEND_MULTIPLY: param->blend = blend_multiply_##depth##bit; break; \
+ case BLEND_MULTIPLY128: param->blend = blend_multiply128_##depth##bit; break; \
+ case BLEND_NEGATION: param->blend = blend_negation_##depth##bit; break; \
+ case BLEND_NORMAL: param->blend = blend_normal_##nbits##bit; break; \
+ case BLEND_OR: param->blend = blend_or_##depth##bit; break; \
+ case BLEND_OVERLAY: param->blend = blend_overlay_##depth##bit; break; \
+ case BLEND_PHOENIX: param->blend = blend_phoenix_##depth##bit; break; \
+ case BLEND_PINLIGHT: param->blend = blend_pinlight_##depth##bit; break; \
+ case BLEND_REFLECT: param->blend = blend_reflect_##depth##bit; break; \
+ case BLEND_SCREEN: param->blend = blend_screen_##depth##bit; break; \
+ case BLEND_SOFTLIGHT: param->blend = blend_softlight_##depth##bit; break; \
+ case BLEND_SUBTRACT: param->blend = blend_subtract_##depth##bit; break; \
+ case BLEND_VIVIDLIGHT: param->blend = blend_vividlight_##depth##bit; break; \
+ case BLEND_XOR: param->blend = blend_xor_##depth##bit; break; \
+ case BLEND_SOFTDIFFERENCE:param->blend=blend_softdifference_##depth##bit;break; \
+ case BLEND_GEOMETRIC: param->blend = blend_geometric_##depth##bit; break; \
+ case BLEND_HARMONIC: param->blend = blend_harmonic_##depth##bit; break; \
+ case BLEND_BLEACH: param->blend = blend_bleach_##depth##bit; break; \
+ case BLEND_STAIN: param->blend = blend_stain_##depth##bit; break; \
+ case BLEND_INTERPOLATE: param->blend = blend_interpolate_##depth##bit; break; \
+ case BLEND_HARDOVERLAY: param->blend = blend_hardoverlay_##depth##bit; break; \
+ } \
+}
+DEFINE_INIT_BLEND_FUNC(8, 8)
+DEFINE_INIT_BLEND_FUNC(9, 16)
+DEFINE_INIT_BLEND_FUNC(10, 16)
+DEFINE_INIT_BLEND_FUNC(12, 16)
+DEFINE_INIT_BLEND_FUNC(14, 16)
+DEFINE_INIT_BLEND_FUNC(16, 16)
+DEFINE_INIT_BLEND_FUNC(32, 32)
+
+static av_unused void ff_blend_init(FilterParams *param, int depth)
+{
+ switch (depth) {
+ case 8:
+ init_blend_func_8_8bit(param);
+ break;
+ case 9:
+ init_blend_func_9_16bit(param);
+ break;
+ case 10:
+ init_blend_func_10_16bit(param);
+ break;
+ case 12:
+ init_blend_func_12_16bit(param);
+ break;
+ case 14:
+ init_blend_func_14_16bit(param);
+ break;
+ case 16:
+ init_blend_func_16_16bit(param);
+ break;
+ case 32:
+ init_blend_func_32_32bit(param);
+ break;
+ }
+
+ if (param->opacity == 0 && param->mode != BLEND_NORMAL) {
+ param->blend = depth > 8 ? depth > 16 ? blend_copytop_32 : blend_copytop_16 : blend_copytop_8;
+ } else if (param->mode == BLEND_NORMAL) {
+ if (param->opacity == 1)
+ param->blend = depth > 8 ? depth > 16 ? blend_copytop_32 : blend_copytop_16 : blend_copytop_8;
+ else if (param->opacity == 0)
+ param->blend = depth > 8 ? depth > 16 ? blend_copybottom_32 : blend_copybottom_16 : blend_copybottom_8;
+ }
+
+ if (ARCH_X86)
+ ff_blend_init_x86(param, depth);
+}
+
+#endif /* AVFILTER_BLEND_INIT_H */
diff --git a/tests/checkasm/vf_blend.c b/tests/checkasm/vf_blend.c
index bdd21d4986..484ed0b1d8 100644
--- a/tests/checkasm/vf_blend.c
+++ b/tests/checkasm/vf_blend.c
@@ -20,7 +20,7 @@
#include <string.h>
#include "checkasm.h"
-#include "libavfilter/blend.h"
+#include "libavfilter/vf_blend_init.h"
#include "libavutil/common.h"
#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 21+ messages in thread
* [FFmpeg-devel] [PATCH 04/10] avfilter/vf_eq: Move ff_nlmeans_init into a header
2022-05-03 6:18 [FFmpeg-devel] [PATCH 01/10] avfilter/af_afir: Only keep DSP stuff in header Andreas Rheinhardt
2022-05-03 6:37 ` [FFmpeg-devel] [PATCH 02/10] avfilter/af_afir: Move ff_afir_init() to header Andreas Rheinhardt
2022-05-03 6:37 ` [FFmpeg-devel] [PATCH 03/10] avfilter/vf_blend: Move ff_blend_init into a header Andreas Rheinhardt
@ 2022-05-03 6:37 ` Andreas Rheinhardt
2022-05-03 6:37 ` [FFmpeg-devel] [PATCH 05/10] avfilter/vf_gblur: Move ff_gblur_init " Andreas Rheinhardt
` (6 subsequent siblings)
9 siblings, 0 replies; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-05-03 6:37 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
This removes a dependency of checkasm on lavfi/vf_eq.o
and also allows to inline ff_eq_init() irrespectively of
interposing.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavfilter/vf_eq.c | 27 ---------------------------
libavfilter/vf_eq.h | 26 +++++++++++++++++++++++++-
2 files changed, 25 insertions(+), 28 deletions(-)
diff --git a/libavfilter/vf_eq.c b/libavfilter/vf_eq.c
index 80ab21efb3..46636dd29d 100644
--- a/libavfilter/vf_eq.c
+++ b/libavfilter/vf_eq.c
@@ -74,26 +74,6 @@ static void apply_lut(EQParameters *param, uint8_t *dst, int dst_stride,
}
}
-static void process_c(EQParameters *param, uint8_t *dst, int dst_stride,
- const uint8_t *src, int src_stride, int w, int h)
-{
- int x, y, pel;
-
- int contrast = (int) (param->contrast * 256 * 16);
- int brightness = ((int) (100.0 * param->brightness + 100.0) * 511) / 200 - 128 - contrast / 32;
-
- for (y = 0; y < h; y++) {
- for (x = 0; x < w; x++) {
- pel = ((src[y * src_stride + x] * contrast) >> 12) + brightness;
-
- if (pel & ~255)
- pel = (-pel) >> 31;
-
- dst[y * dst_stride + x] = pel;
- }
- }
-}
-
static void check_values(EQParameters *param, EQContext *eq)
{
if (param->contrast == 1.0 && param->brightness == 0.0 && param->gamma == 1.0)
@@ -174,13 +154,6 @@ static int set_expr(AVExpr **pexpr, const char *expr, const char *option, void *
return 0;
}
-void ff_eq_init(EQContext *eq)
-{
- eq->process = process_c;
- if (ARCH_X86)
- ff_eq_init_x86(eq);
-}
-
static int initialize(AVFilterContext *ctx)
{
EQContext *eq = ctx->priv;
diff --git a/libavfilter/vf_eq.h b/libavfilter/vf_eq.h
index cd0cd75f08..a5756977d2 100644
--- a/libavfilter/vf_eq.h
+++ b/libavfilter/vf_eq.h
@@ -100,7 +100,31 @@ typedef struct EQContext {
enum EvalMode { EVAL_MODE_INIT, EVAL_MODE_FRAME, EVAL_MODE_NB } eval_mode;
} EQContext;
-void ff_eq_init(EQContext *eq);
+static void process_c(EQParameters *param, uint8_t *dst, int dst_stride,
+ const uint8_t *src, int src_stride, int w, int h)
+{
+ int contrast = (int) (param->contrast * 256 * 16);
+ int brightness = ((int) (100.0 * param->brightness + 100.0) * 511) / 200 - 128 - contrast / 32;
+
+ for (int y = 0; y < h; y++) {
+ for (int x = 0; x < w; x++) {
+ int pel = ((src[y * src_stride + x] * contrast) >> 12) + brightness;
+
+ if (pel & ~255)
+ pel = (-pel) >> 31;
+
+ dst[y * dst_stride + x] = pel;
+ }
+ }
+}
+
void ff_eq_init_x86(EQContext *eq);
+static av_unused void ff_eq_init(EQContext *eq)
+{
+ eq->process = process_c;
+ if (ARCH_X86)
+ ff_eq_init_x86(eq);
+}
+
#endif /* AVFILTER_EQ_H */
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 21+ messages in thread
* [FFmpeg-devel] [PATCH 05/10] avfilter/vf_gblur: Move ff_gblur_init into a header
2022-05-03 6:18 [FFmpeg-devel] [PATCH 01/10] avfilter/af_afir: Only keep DSP stuff in header Andreas Rheinhardt
` (2 preceding siblings ...)
2022-05-03 6:37 ` [FFmpeg-devel] [PATCH 04/10] avfilter/vf_eq: Move ff_nlmeans_init " Andreas Rheinhardt
@ 2022-05-03 6:37 ` Andreas Rheinhardt
2022-05-03 6:37 ` [FFmpeg-devel] [PATCH 06/10] avfilter/vf_hflip: Move ff_hflip_init " Andreas Rheinhardt
` (5 subsequent siblings)
9 siblings, 0 replies; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-05-03 6:37 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
This removes a dependency of checkasm on lavfi/vf_gblur.o
and also allows to inline ff_gblur_init() irrespectively of
interposing.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavfilter/gblur.h | 1 -
libavfilter/vf_gblur.c | 89 +-------------------------
libavfilter/vf_gblur_init.h | 122 ++++++++++++++++++++++++++++++++++++
tests/checkasm/vf_gblur.c | 2 +-
4 files changed, 124 insertions(+), 90 deletions(-)
create mode 100644 libavfilter/vf_gblur_init.h
diff --git a/libavfilter/gblur.h b/libavfilter/gblur.h
index 3a66984b06..83f43c2c1e 100644
--- a/libavfilter/gblur.h
+++ b/libavfilter/gblur.h
@@ -57,6 +57,5 @@ typedef struct GBlurContext {
void (*postscale_slice)(float *buffer, int length, float postscale, float min, float max);
} GBlurContext;
-void ff_gblur_init(GBlurContext *s);
void ff_gblur_init_x86(GBlurContext *s);
#endif
diff --git a/libavfilter/vf_gblur.c b/libavfilter/vf_gblur.c
index fd664db057..b88a9a6d26 100644
--- a/libavfilter/vf_gblur.c
+++ b/libavfilter/vf_gblur.c
@@ -34,6 +34,7 @@
#include "formats.h"
#include "gblur.h"
#include "internal.h"
+#include "vf_gblur_init.h"
#include "video.h"
#define OFFSET(x) offsetof(GBlurContext, x)
@@ -54,37 +55,6 @@ typedef struct ThreadData {
int width;
} ThreadData;
-static void postscale_c(float *buffer, int length,
- float postscale, float min, float max)
-{
- for (int i = 0; i < length; i++) {
- buffer[i] *= postscale;
- buffer[i] = av_clipf(buffer[i], min, max);
- }
-}
-
-static void horiz_slice_c(float *buffer, int width, int height, int steps,
- float nu, float bscale, float *localbuf)
-{
- int step, x, y;
- float *ptr;
- for (y = 0; y < height; y++) {
- for (step = 0; step < steps; step++) {
- ptr = buffer + width * y;
- ptr[0] *= bscale;
-
- /* Filter rightwards */
- for (x = 1; x < width; x++)
- ptr[x] += nu * ptr[x - 1];
- ptr[x = width - 1] *= bscale;
-
- /* Filter leftwards */
- for (; x > 0; x--)
- ptr[x - 1] += nu * ptr[x];
- }
- }
-}
-
static int filter_horizontally(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
{
GBlurContext *s = ctx->priv;
@@ -108,53 +78,6 @@ static int filter_horizontally(AVFilterContext *ctx, void *arg, int jobnr, int n
return 0;
}
-static void do_vertical_columns(float *buffer, int width, int height,
- int column_begin, int column_end, int steps,
- float nu, float boundaryscale, int column_step)
-{
- const int numpixels = width * height;
- int i, x, k, step;
- float *ptr;
- for (x = column_begin; x < column_end;) {
- for (step = 0; step < steps; step++) {
- ptr = buffer + x;
- for (k = 0; k < column_step; k++) {
- ptr[k] *= boundaryscale;
- }
- /* Filter downwards */
- for (i = width; i < numpixels; i += width) {
- for (k = 0; k < column_step; k++) {
- ptr[i + k] += nu * ptr[i - width + k];
- }
- }
- i = numpixels - width;
-
- for (k = 0; k < column_step; k++)
- ptr[i + k] *= boundaryscale;
-
- /* Filter upwards */
- for (; i > 0; i -= width) {
- for (k = 0; k < column_step; k++)
- ptr[i - width + k] += nu * ptr[i + k];
- }
- }
- x += column_step;
- }
-}
-
-static void verti_slice_c(float *buffer, int width, int height,
- int slice_start, int slice_end, int steps,
- float nu, float boundaryscale)
-{
- int aligned_end = slice_start + (((slice_end - slice_start) >> 3) << 3);
- /* Filter vertically along columns (process 8 columns in each step) */
- do_vertical_columns(buffer, width, height, slice_start, aligned_end,
- steps, nu, boundaryscale, 8);
- /* Filter un-aligned columns one by one */
- do_vertical_columns(buffer, width, height, aligned_end, slice_end,
- steps, nu, boundaryscale, 1);
-}
-
static int filter_vertically(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
{
GBlurContext *s = ctx->priv;
@@ -239,16 +162,6 @@ static const enum AVPixelFormat pix_fmts[] = {
AV_PIX_FMT_NONE
};
-void ff_gblur_init(GBlurContext *s)
-{
- s->localbuf = NULL;
- s->horiz_slice = horiz_slice_c;
- s->verti_slice = verti_slice_c;
- s->postscale_slice = postscale_c;
- if (ARCH_X86)
- ff_gblur_init_x86(s);
-}
-
static av_cold void uninit(AVFilterContext *ctx)
{
GBlurContext *s = ctx->priv;
diff --git a/libavfilter/vf_gblur_init.h b/libavfilter/vf_gblur_init.h
new file mode 100644
index 0000000000..0fee64bc98
--- /dev/null
+++ b/libavfilter/vf_gblur_init.h
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2011 Pascal Getreuer
+ * Copyright (c) 2016 Paul B Mahol
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AVFILTER_GBLUR_INIT_H
+#define AVFILTER_GBLUR_INIT_H
+
+#include "config.h"
+#include "libavutil/attributes.h"
+#include "libavutil/common.h"
+#include "gblur.h"
+
+static void postscale_c(float *buffer, int length,
+ float postscale, float min, float max)
+{
+ for (int i = 0; i < length; i++) {
+ buffer[i] *= postscale;
+ buffer[i] = av_clipf(buffer[i], min, max);
+ }
+}
+
+static void horiz_slice_c(float *buffer, int width, int height, int steps,
+ float nu, float bscale, float *localbuf)
+{
+ int x;
+ for (int y = 0; y < height; y++) {
+ for (int step = 0; step < steps; step++) {
+ float *ptr = buffer + width * y;
+ ptr[0] *= bscale;
+
+ /* Filter rightwards */
+ for (x = 1; x < width; x++)
+ ptr[x] += nu * ptr[x - 1];
+ ptr[x = width - 1] *= bscale;
+
+ /* Filter leftwards */
+ for (; x > 0; x--)
+ ptr[x - 1] += nu * ptr[x];
+ }
+ }
+}
+
+static void do_vertical_columns(float *buffer, int width, int height,
+ int column_begin, int column_end, int steps,
+ float nu, float boundaryscale, int column_step)
+{
+ const int numpixels = width * height;
+ int i;
+ for (int x = column_begin; x < column_end;) {
+ for (int step = 0; step < steps; step++) {
+ float *ptr = buffer + x;
+ for (int k = 0; k < column_step; k++) {
+ ptr[k] *= boundaryscale;
+ }
+ /* Filter downwards */
+ for (i = width; i < numpixels; i += width) {
+ for (int k = 0; k < column_step; k++) {
+ ptr[i + k] += nu * ptr[i - width + k];
+ }
+ }
+ i = numpixels - width;
+
+ for (int k = 0; k < column_step; k++)
+ ptr[i + k] *= boundaryscale;
+
+ /* Filter upwards */
+ for (; i > 0; i -= width) {
+ for (int k = 0; k < column_step; k++)
+ ptr[i - width + k] += nu * ptr[i + k];
+ }
+ }
+ x += column_step;
+ }
+}
+
+static void verti_slice_c(float *buffer, int width, int height,
+ int slice_start, int slice_end, int steps,
+ float nu, float boundaryscale)
+{
+ int aligned_end = slice_start + (((slice_end - slice_start) >> 3) << 3);
+ /* Filter vertically along columns (process 8 columns in each step) */
+ do_vertical_columns(buffer, width, height, slice_start, aligned_end,
+ steps, nu, boundaryscale, 8);
+ /* Filter un-aligned columns one by one */
+ do_vertical_columns(buffer, width, height, aligned_end, slice_end,
+ steps, nu, boundaryscale, 1);
+}
+
+static av_unused void ff_gblur_init(GBlurContext *s)
+{
+ s->localbuf = NULL;
+ s->horiz_slice = horiz_slice_c;
+ s->verti_slice = verti_slice_c;
+ s->postscale_slice = postscale_c;
+ if (ARCH_X86)
+ ff_gblur_init_x86(s);
+}
+
+#endif /* AVFILTER_GBLUR_INIT_H */
diff --git a/tests/checkasm/vf_gblur.c b/tests/checkasm/vf_gblur.c
index a7a1c1a24e..3686a6c9f6 100644
--- a/tests/checkasm/vf_gblur.c
+++ b/tests/checkasm/vf_gblur.c
@@ -19,7 +19,7 @@
#include <float.h>
#include <string.h>
#include "checkasm.h"
-#include "libavfilter/gblur.h"
+#include "libavfilter/vf_gblur_init.h"
#define WIDTH 256
#define HEIGHT 256
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 21+ messages in thread
* [FFmpeg-devel] [PATCH 06/10] avfilter/vf_hflip: Move ff_hflip_init into a header
2022-05-03 6:18 [FFmpeg-devel] [PATCH 01/10] avfilter/af_afir: Only keep DSP stuff in header Andreas Rheinhardt
` (3 preceding siblings ...)
2022-05-03 6:37 ` [FFmpeg-devel] [PATCH 05/10] avfilter/vf_gblur: Move ff_gblur_init " Andreas Rheinhardt
@ 2022-05-03 6:37 ` Andreas Rheinhardt
2022-05-03 6:37 ` [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move ff_nlmeans_init " Andreas Rheinhardt
` (4 subsequent siblings)
9 siblings, 0 replies; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-05-03 6:37 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
This removes a dependency of checkasm on lavfi/vf_hflip.o
and also allows to inline ff_hflip_init() irrespectively of
interposing.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavfilter/hflip.h | 1 -
libavfilter/vf_hflip.c | 88 +----------------------------
libavfilter/vf_hflip_init.h | 110 ++++++++++++++++++++++++++++++++++++
tests/checkasm/vf_hflip.c | 1 +
4 files changed, 112 insertions(+), 88 deletions(-)
create mode 100644 libavfilter/vf_hflip_init.h
diff --git a/libavfilter/hflip.h b/libavfilter/hflip.h
index a40b98470b..8532dc0f46 100644
--- a/libavfilter/hflip.h
+++ b/libavfilter/hflip.h
@@ -34,7 +34,6 @@ typedef struct FlipContext {
void (*flip_line[4])(const uint8_t *src, uint8_t *dst, int w);
} FlipContext;
-int ff_hflip_init(FlipContext *s, int step[4], int nb_planes);
void ff_hflip_init_x86(FlipContext *s, int step[4], int nb_planes);
#endif /* AVFILTER_HFLIP_H */
diff --git a/libavfilter/vf_hflip.c b/libavfilter/vf_hflip.c
index 0362660679..8517b87889 100644
--- a/libavfilter/vf_hflip.c
+++ b/libavfilter/vf_hflip.c
@@ -31,6 +31,7 @@
#include "formats.h"
#include "hflip.h"
#include "internal.h"
+#include "vf_hflip_init.h"
#include "video.h"
#include "libavutil/pixdesc.h"
#include "libavutil/internal.h"
@@ -61,70 +62,6 @@ static int query_formats(AVFilterContext *ctx)
return ff_set_common_formats(ctx, pix_fmts);
}
-static void hflip_byte_c(const uint8_t *src, uint8_t *dst, int w)
-{
- int j;
-
- for (j = 0; j < w; j++)
- dst[j] = src[-j];
-}
-
-static void hflip_short_c(const uint8_t *ssrc, uint8_t *ddst, int w)
-{
- const uint16_t *src = (const uint16_t *)ssrc;
- uint16_t *dst = (uint16_t *)ddst;
- int j;
-
- for (j = 0; j < w; j++)
- dst[j] = src[-j];
-}
-
-static void hflip_dword_c(const uint8_t *ssrc, uint8_t *ddst, int w)
-{
- const uint32_t *src = (const uint32_t *)ssrc;
- uint32_t *dst = (uint32_t *)ddst;
- int j;
-
- for (j = 0; j < w; j++)
- dst[j] = src[-j];
-}
-
-static void hflip_b24_c(const uint8_t *src, uint8_t *dst, int w)
-{
- const uint8_t *in = src;
- uint8_t *out = dst;
- int j;
-
- for (j = 0; j < w; j++, out += 3, in -= 3) {
- int32_t v = AV_RB24(in);
-
- AV_WB24(out, v);
- }
-}
-
-static void hflip_b48_c(const uint8_t *src, uint8_t *dst, int w)
-{
- const uint8_t *in = src;
- uint8_t *out = dst;
- int j;
-
- for (j = 0; j < w; j++, out += 6, in -= 6) {
- int64_t v = AV_RB48(in);
-
- AV_WB48(out, v);
- }
-}
-
-static void hflip_qword_c(const uint8_t *ssrc, uint8_t *ddst, int w)
-{
- const uint64_t *src = (const uint64_t *)ssrc;
- uint64_t *dst = (uint64_t *)ddst;
- int j;
-
- for (j = 0; j < w; j++)
- dst[j] = src[-j];
-}
-
static int config_props(AVFilterLink *inlink)
{
FlipContext *s = inlink->dst->priv;
@@ -145,29 +82,6 @@ static int config_props(AVFilterLink *inlink)
return ff_hflip_init(s, s->max_step, nb_planes);
}
-int ff_hflip_init(FlipContext *s, int step[4], int nb_planes)
-{
- int i;
-
- for (i = 0; i < nb_planes; i++) {
- step[i] *= s->bayer_plus1;
- switch (step[i]) {
- case 1: s->flip_line[i] = hflip_byte_c; break;
- case 2: s->flip_line[i] = hflip_short_c; break;
- case 3: s->flip_line[i] = hflip_b24_c; break;
- case 4: s->flip_line[i] = hflip_dword_c; break;
- case 6: s->flip_line[i] = hflip_b48_c; break;
- case 8: s->flip_line[i] = hflip_qword_c; break;
- default:
- return AVERROR_BUG;
- }
- }
- if (ARCH_X86)
- ff_hflip_init_x86(s, step, nb_planes);
-
- return 0;
-}
-
typedef struct ThreadData {
AVFrame *in, *out;
} ThreadData;
diff --git a/libavfilter/vf_hflip_init.h b/libavfilter/vf_hflip_init.h
new file mode 100644
index 0000000000..b58cfec901
--- /dev/null
+++ b/libavfilter/vf_hflip_init.h
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2007 Benoit Fouet
+ * Copyright (c) 2010 Stefano Sabatini
+ *
+ * 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
+ */
+
+#ifndef AVFILTER_HFLIP_INIT_H
+#define AVFILTER_HFLIP_INIT_H
+
+#include <stdint.h>
+
+#include "config.h"
+#include "libavutil/attributes.h"
+#include "libavutil/intreadwrite.h"
+#include "hflip.h"
+
+static void hflip_byte_c(const uint8_t *src, uint8_t *dst, int w)
+{
+ for (int j = 0; j < w; j++)
+ dst[j] = src[-j];
+}
+
+static void hflip_short_c(const uint8_t *ssrc, uint8_t *ddst, int w)
+{
+ const uint16_t *src = (const uint16_t *)ssrc;
+ uint16_t *dst = (uint16_t *)ddst;
+
+ for (int j = 0; j < w; j++)
+ dst[j] = src[-j];
+}
+
+static void hflip_dword_c(const uint8_t *ssrc, uint8_t *ddst, int w)
+{
+ const uint32_t *src = (const uint32_t *)ssrc;
+ uint32_t *dst = (uint32_t *)ddst;
+
+ for (int j = 0; j < w; j++)
+ dst[j] = src[-j];
+}
+
+static void hflip_b24_c(const uint8_t *src, uint8_t *dst, int w)
+{
+ const uint8_t *in = src;
+ uint8_t *out = dst;
+
+ for (int j = 0; j < w; j++, out += 3, in -= 3) {
+ int32_t v = AV_RB24(in);
+
+ AV_WB24(out, v);
+ }
+}
+
+static void hflip_b48_c(const uint8_t *src, uint8_t *dst, int w)
+{
+ const uint8_t *in = src;
+ uint8_t *out = dst;
+
+ for (int j = 0; j < w; j++, out += 6, in -= 6) {
+ int64_t v = AV_RB48(in);
+
+ AV_WB48(out, v);
+ }
+}
+
+static void hflip_qword_c(const uint8_t *ssrc, uint8_t *ddst, int w)
+{
+ const uint64_t *src = (const uint64_t *)ssrc;
+ uint64_t *dst = (uint64_t *)ddst;
+
+ for (int j = 0; j < w; j++)
+ dst[j] = src[-j];
+}
+
+static av_unused int ff_hflip_init(FlipContext *s, int step[4], int nb_planes)
+{
+ for (int i = 0; i < nb_planes; i++) {
+ step[i] *= s->bayer_plus1;
+ switch (step[i]) {
+ case 1: s->flip_line[i] = hflip_byte_c; break;
+ case 2: s->flip_line[i] = hflip_short_c; break;
+ case 3: s->flip_line[i] = hflip_b24_c; break;
+ case 4: s->flip_line[i] = hflip_dword_c; break;
+ case 6: s->flip_line[i] = hflip_b48_c; break;
+ case 8: s->flip_line[i] = hflip_qword_c; break;
+ default:
+ return AVERROR_BUG;
+ }
+ }
+ if (ARCH_X86)
+ ff_hflip_init_x86(s, step, nb_planes);
+
+ return 0;
+}
+
+#endif /* AVFILTER_HFLIP_INIT_H */
diff --git a/tests/checkasm/vf_hflip.c b/tests/checkasm/vf_hflip.c
index a3b6e613d5..96614d12c5 100644
--- a/tests/checkasm/vf_hflip.c
+++ b/tests/checkasm/vf_hflip.c
@@ -19,6 +19,7 @@
#include <string.h>
#include "checkasm.h"
#include "libavfilter/hflip.h"
+#include "libavfilter/vf_hflip_init.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem_internal.h"
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 21+ messages in thread
* [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move ff_nlmeans_init into a header
2022-05-03 6:18 [FFmpeg-devel] [PATCH 01/10] avfilter/af_afir: Only keep DSP stuff in header Andreas Rheinhardt
` (4 preceding siblings ...)
2022-05-03 6:37 ` [FFmpeg-devel] [PATCH 06/10] avfilter/vf_hflip: Move ff_hflip_init " Andreas Rheinhardt
@ 2022-05-03 6:37 ` Andreas Rheinhardt
2022-05-13 6:28 ` Soft Works
2022-05-03 6:37 ` [FFmpeg-devel] [PATCH 08/10] avfilter/vf_threshold: Move ff_threshold_init " Andreas Rheinhardt
` (3 subsequent siblings)
9 siblings, 1 reply; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-05-03 6:37 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
This removes a dependency of checkasm on lavfi/vf_nlmeans.o
and also allows to inline ff_nlmeans_init() irrespectively of
interposing.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavfilter/vf_nlmeans.c | 108 +-------------------------
libavfilter/vf_nlmeans.h | 1 -
libavfilter/vf_nlmeans_init.h | 139 ++++++++++++++++++++++++++++++++++
tests/checkasm/vf_nlmeans.c | 2 +-
4 files changed, 141 insertions(+), 109 deletions(-)
create mode 100644 libavfilter/vf_nlmeans_init.h
diff --git a/libavfilter/vf_nlmeans.c b/libavfilter/vf_nlmeans.c
index 8a05965c9b..2fc3adacca 100644
--- a/libavfilter/vf_nlmeans.c
+++ b/libavfilter/vf_nlmeans.c
@@ -36,6 +36,7 @@
#include "formats.h"
#include "internal.h"
#include "vf_nlmeans.h"
+#include "vf_nlmeans_init.h"
#include "video.h"
typedef struct NLMeansContext {
@@ -84,48 +85,6 @@ static const enum AVPixelFormat pix_fmts[] = {
AV_PIX_FMT_NONE
};
-/**
- * Compute squared difference of the safe area (the zone where s1 and s2
- * overlap). It is likely the largest integral zone, so it is interesting to do
- * as little checks as possible; contrary to the unsafe version of this
- * function, we do not need any clipping here.
- *
- * The line above dst and the column to its left are always readable.
- */
-static void compute_safe_ssd_integral_image_c(uint32_t *dst, ptrdiff_t dst_linesize_32,
- const uint8_t *s1, ptrdiff_t linesize1,
- const uint8_t *s2, ptrdiff_t linesize2,
- int w, int h)
-{
- const uint32_t *dst_top = dst - dst_linesize_32;
-
- /* SIMD-friendly assumptions allowed here */
- av_assert2(!(w & 0xf) && w >= 16 && h >= 1);
-
- for (int y = 0; y < h; y++) {
- for (int x = 0; x < w; x += 4) {
- const int d0 = s1[x ] - s2[x ];
- const int d1 = s1[x + 1] - s2[x + 1];
- const int d2 = s1[x + 2] - s2[x + 2];
- const int d3 = s1[x + 3] - s2[x + 3];
-
- dst[x ] = dst_top[x ] - dst_top[x - 1] + d0*d0;
- dst[x + 1] = dst_top[x + 1] - dst_top[x ] + d1*d1;
- dst[x + 2] = dst_top[x + 2] - dst_top[x + 1] + d2*d2;
- dst[x + 3] = dst_top[x + 3] - dst_top[x + 2] + d3*d3;
-
- dst[x ] += dst[x - 1];
- dst[x + 1] += dst[x ];
- dst[x + 2] += dst[x + 1];
- dst[x + 3] += dst[x + 2];
- }
- s1 += linesize1;
- s2 += linesize2;
- dst += dst_linesize_32;
- dst_top += dst_linesize_32;
- }
-}
-
/**
* Compute squared difference of an unsafe area (the zone nor s1 nor s2 could
* be readable).
@@ -326,59 +285,6 @@ struct thread_data {
int p;
};
-static void compute_weights_line_c(const uint32_t *const iia,
- const uint32_t *const iib,
- const uint32_t *const iid,
- const uint32_t *const iie,
- const uint8_t *const src,
- float *total_weight,
- float *sum,
- const float *const weight_lut,
- int max_meaningful_diff,
- int startx, int endx)
-{
- for (int x = startx; x < endx; x++) {
- /*
- * M is a discrete map where every entry contains the sum of all the entries
- * in the rectangle from the top-left origin of M to its coordinate. In the
- * following schema, "i" contains the sum of the whole map:
- *
- * M = +----------+-----------------+----+
- * | | | |
- * | | | |
- * | a| b| c|
- * +----------+-----------------+----+
- * | | | |
- * | | | |
- * | | X | |
- * | | | |
- * | d| e| f|
- * +----------+-----------------+----+
- * | | | |
- * | g| h| i|
- * +----------+-----------------+----+
- *
- * The sum of the X box can be calculated with:
- * X = e-d-b+a
- *
- * See https://en.wikipedia.org/wiki/Summed_area_table
- *
- * The compute*_ssd functions compute the integral image M where every entry
- * contains the sum of the squared difference of every corresponding pixels of
- * two input planes of the same size as M.
- */
- const uint32_t a = iia[x];
- const uint32_t b = iib[x];
- const uint32_t d = iid[x];
- const uint32_t e = iie[x];
- const uint32_t patch_diff_sq = FFMIN(e - d - b + a, max_meaningful_diff);
- const float weight = weight_lut[patch_diff_sq]; // exp(-patch_diff_sq * s->pdiff_scale)
-
- total_weight[x] += weight;
- sum[x] += weight * src[x];
- }
-}
-
static int nlmeans_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
{
NLMeansContext *s = ctx->priv;
@@ -512,18 +418,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
} \
} while (0)
-void ff_nlmeans_init(NLMeansDSPContext *dsp)
-{
- dsp->compute_safe_ssd_integral_image = compute_safe_ssd_integral_image_c;
- dsp->compute_weights_line = compute_weights_line_c;
-
- if (ARCH_AARCH64)
- ff_nlmeans_init_aarch64(dsp);
-
- if (ARCH_X86)
- ff_nlmeans_init_x86(dsp);
-}
-
static av_cold int init(AVFilterContext *ctx)
{
NLMeansContext *s = ctx->priv;
diff --git a/libavfilter/vf_nlmeans.h b/libavfilter/vf_nlmeans.h
index 43611a03bd..61377f8c69 100644
--- a/libavfilter/vf_nlmeans.h
+++ b/libavfilter/vf_nlmeans.h
@@ -39,7 +39,6 @@ typedef struct NLMeansDSPContext {
int startx, int endx);
} NLMeansDSPContext;
-void ff_nlmeans_init(NLMeansDSPContext *dsp);
void ff_nlmeans_init_aarch64(NLMeansDSPContext *dsp);
void ff_nlmeans_init_x86(NLMeansDSPContext *dsp);
diff --git a/libavfilter/vf_nlmeans_init.h b/libavfilter/vf_nlmeans_init.h
new file mode 100644
index 0000000000..04ad8801b6
--- /dev/null
+++ b/libavfilter/vf_nlmeans_init.h
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2016 Clément Bœsch <u pkh me>
+ *
+ * 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
+ */
+
+#ifndef AVFILTER_NLMEANS_INIT_H
+#define AVFILTER_NLMEANS_INIT_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include "config.h"
+#include "libavutil/avassert.h"
+#include "libavutil/macros.h"
+#include "vf_nlmeans.h"
+
+/**
+ * Compute squared difference of the safe area (the zone where s1 and s2
+ * overlap). It is likely the largest integral zone, so it is interesting to do
+ * as little checks as possible; contrary to the unsafe version of this
+ * function, we do not need any clipping here.
+ *
+ * The line above dst and the column to its left are always readable.
+ */
+static void compute_safe_ssd_integral_image_c(uint32_t *dst, ptrdiff_t dst_linesize_32,
+ const uint8_t *s1, ptrdiff_t linesize1,
+ const uint8_t *s2, ptrdiff_t linesize2,
+ int w, int h)
+{
+ const uint32_t *dst_top = dst - dst_linesize_32;
+
+ /* SIMD-friendly assumptions allowed here */
+ av_assert2(!(w & 0xf) && w >= 16 && h >= 1);
+
+ for (int y = 0; y < h; y++) {
+ for (int x = 0; x < w; x += 4) {
+ const int d0 = s1[x ] - s2[x ];
+ const int d1 = s1[x + 1] - s2[x + 1];
+ const int d2 = s1[x + 2] - s2[x + 2];
+ const int d3 = s1[x + 3] - s2[x + 3];
+
+ dst[x ] = dst_top[x ] - dst_top[x - 1] + d0*d0;
+ dst[x + 1] = dst_top[x + 1] - dst_top[x ] + d1*d1;
+ dst[x + 2] = dst_top[x + 2] - dst_top[x + 1] + d2*d2;
+ dst[x + 3] = dst_top[x + 3] - dst_top[x + 2] + d3*d3;
+
+ dst[x ] += dst[x - 1];
+ dst[x + 1] += dst[x ];
+ dst[x + 2] += dst[x + 1];
+ dst[x + 3] += dst[x + 2];
+ }
+ s1 += linesize1;
+ s2 += linesize2;
+ dst += dst_linesize_32;
+ dst_top += dst_linesize_32;
+ }
+}
+
+static void compute_weights_line_c(const uint32_t *const iia,
+ const uint32_t *const iib,
+ const uint32_t *const iid,
+ const uint32_t *const iie,
+ const uint8_t *const src,
+ float *total_weight,
+ float *sum,
+ const float *const weight_lut,
+ int max_meaningful_diff,
+ int startx, int endx)
+{
+ for (int x = startx; x < endx; x++) {
+ /*
+ * M is a discrete map where every entry contains the sum of all the entries
+ * in the rectangle from the top-left origin of M to its coordinate. In the
+ * following schema, "i" contains the sum of the whole map:
+ *
+ * M = +----------+-----------------+----+
+ * | | | |
+ * | | | |
+ * | a| b| c|
+ * +----------+-----------------+----+
+ * | | | |
+ * | | | |
+ * | | X | |
+ * | | | |
+ * | d| e| f|
+ * +----------+-----------------+----+
+ * | | | |
+ * | g| h| i|
+ * +----------+-----------------+----+
+ *
+ * The sum of the X box can be calculated with:
+ * X = e-d-b+a
+ *
+ * See https://en.wikipedia.org/wiki/Summed_area_table
+ *
+ * The compute*_ssd functions compute the integral image M where every entry
+ * contains the sum of the squared difference of every corresponding pixels of
+ * two input planes of the same size as M.
+ */
+ const uint32_t a = iia[x];
+ const uint32_t b = iib[x];
+ const uint32_t d = iid[x];
+ const uint32_t e = iie[x];
+ const uint32_t patch_diff_sq = FFMIN(e - d - b + a, max_meaningful_diff);
+ const float weight = weight_lut[patch_diff_sq]; // exp(-patch_diff_sq * s->pdiff_scale)
+
+ total_weight[x] += weight;
+ sum[x] += weight * src[x];
+ }
+}
+
+static av_unused void ff_nlmeans_init(NLMeansDSPContext *dsp)
+{
+ dsp->compute_safe_ssd_integral_image = compute_safe_ssd_integral_image_c;
+ dsp->compute_weights_line = compute_weights_line_c;
+
+ if (ARCH_AARCH64)
+ ff_nlmeans_init_aarch64(dsp);
+
+ if (ARCH_X86)
+ ff_nlmeans_init_x86(dsp);
+}
+
+#endif /* AVFILTER_NLMEANS_INIT_H */
diff --git a/tests/checkasm/vf_nlmeans.c b/tests/checkasm/vf_nlmeans.c
index 87474d6803..0f1f9fd403 100644
--- a/tests/checkasm/vf_nlmeans.c
+++ b/tests/checkasm/vf_nlmeans.c
@@ -19,7 +19,7 @@
*/
#include "checkasm.h"
-#include "libavfilter/vf_nlmeans.h"
+#include "libavfilter/vf_nlmeans_init.h"
#include "libavutil/avassert.h"
#define randomize_buffer(buf, size) do { \
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move ff_nlmeans_init into a header
2022-05-03 6:37 ` [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move ff_nlmeans_init " Andreas Rheinhardt
@ 2022-05-13 6:28 ` Soft Works
2022-05-13 8:27 ` Andreas Rheinhardt
0 siblings, 1 reply; 21+ messages in thread
From: Soft Works @ 2022-05-13 6:28 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Andreas Rheinhardt
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Andreas Rheinhardt
> Sent: Tuesday, May 3, 2022 8:38 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> Subject: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move
> ff_nlmeans_init into a header
>
> This removes a dependency of checkasm on lavfi/vf_nlmeans.o
> and also allows to inline ff_nlmeans_init() irrespectively of
> interposing.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
[..]
> +
> +static av_unused void ff_nlmeans_init(NLMeansDSPContext *dsp)
> +{
> + dsp->compute_safe_ssd_integral_image =
> compute_safe_ssd_integral_image_c;
> + dsp->compute_weights_line = compute_weights_line_c;
> +
> + if (ARCH_AARCH64)
> + ff_nlmeans_init_aarch64(dsp);
Hi Andreas,
the above breaks compilation for me:
1>libavfilterd.lib(libavfilter_vf_nlmeans.obj) : error LNK2019: unresolved external symbol ff_nlmeans_init_aarch64 referenced in function ff_nlmeans_init
The reason is that I'm (obviously) not compiling stuff from the
libavfilter\aarch64 subfolder.
It might need an #ifdef ?
I haven't taken a deeper look at it, though.
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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move ff_nlmeans_init into a header
2022-05-13 6:28 ` Soft Works
@ 2022-05-13 8:27 ` Andreas Rheinhardt
2022-05-13 9:00 ` Hendrik Leppkes
2022-05-13 9:01 ` Soft Works
0 siblings, 2 replies; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-05-13 8:27 UTC (permalink / raw)
To: Soft Works, FFmpeg development discussions and patches
Soft Works:
>
>
>> -----Original Message-----
>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
>> Andreas Rheinhardt
>> Sent: Tuesday, May 3, 2022 8:38 AM
>> To: ffmpeg-devel@ffmpeg.org
>> Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>> Subject: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move
>> ff_nlmeans_init into a header
>>
>> This removes a dependency of checkasm on lavfi/vf_nlmeans.o
>> and also allows to inline ff_nlmeans_init() irrespectively of
>> interposing.
>>
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>> ---
>
> [..]
>
>> +
>> +static av_unused void ff_nlmeans_init(NLMeansDSPContext *dsp)
>> +{
>> + dsp->compute_safe_ssd_integral_image =
>> compute_safe_ssd_integral_image_c;
>> + dsp->compute_weights_line = compute_weights_line_c;
>> +
>> + if (ARCH_AARCH64)
>> + ff_nlmeans_init_aarch64(dsp);
>
> Hi Andreas,
>
> the above breaks compilation for me:
>
> 1>libavfilterd.lib(libavfilter_vf_nlmeans.obj) : error LNK2019: unresolved external symbol ff_nlmeans_init_aarch64 referenced in function ff_nlmeans_init
>
> The reason is that I'm (obviously) not compiling stuff from the
> libavfilter\aarch64 subfolder.
>
> It might need an #ifdef ?
>
> I haven't taken a deeper look at it, though.
>
> Thanks,
> softworkz
>
>
That surprises me: The earlier code did exactly the same; in fact, using
if (ARCH_*) is our typical check for arches in dsp-init code.
Is this the only place where this happens?
#ifdef is certainly wrong: All ARCH_* are always defined; they are just
0 or 1.
Anyway, will send a patch with #if.
- Andreas
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move ff_nlmeans_init into a header
2022-05-13 8:27 ` Andreas Rheinhardt
@ 2022-05-13 9:00 ` Hendrik Leppkes
2022-05-13 9:03 ` Soft Works
2022-05-13 9:01 ` Soft Works
1 sibling, 1 reply; 21+ messages in thread
From: Hendrik Leppkes @ 2022-05-13 9:00 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Fri, May 13, 2022 at 10:27 AM Andreas Rheinhardt
<andreas.rheinhardt@outlook.com> wrote:
>
> Soft Works:
> >
> >
> >> -----Original Message-----
> >> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> >> Andreas Rheinhardt
> >> Sent: Tuesday, May 3, 2022 8:38 AM
> >> To: ffmpeg-devel@ffmpeg.org
> >> Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> >> Subject: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move
> >> ff_nlmeans_init into a header
> >>
> >> This removes a dependency of checkasm on lavfi/vf_nlmeans.o
> >> and also allows to inline ff_nlmeans_init() irrespectively of
> >> interposing.
> >>
> >> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> >> ---
> >
> > [..]
> >
> >> +
> >> +static av_unused void ff_nlmeans_init(NLMeansDSPContext *dsp)
> >> +{
> >> + dsp->compute_safe_ssd_integral_image =
> >> compute_safe_ssd_integral_image_c;
> >> + dsp->compute_weights_line = compute_weights_line_c;
> >> +
> >> + if (ARCH_AARCH64)
> >> + ff_nlmeans_init_aarch64(dsp);
> >
> > Hi Andreas,
> >
> > the above breaks compilation for me:
> >
> > 1>libavfilterd.lib(libavfilter_vf_nlmeans.obj) : error LNK2019: unresolved external symbol ff_nlmeans_init_aarch64 referenced in function ff_nlmeans_init
> >
> > The reason is that I'm (obviously) not compiling stuff from the
> > libavfilter\aarch64 subfolder.
> >
> > It might need an #ifdef ?
> >
> > I haven't taken a deeper look at it, though.
> >
> > Thanks,
> > softworkz
> >
> >
>
> That surprises me: The earlier code did exactly the same; in fact, using
> if (ARCH_*) is our typical check for arches in dsp-init code.
> Is this the only place where this happens?
> #ifdef is certainly wrong: All ARCH_* are always defined; they are just
> 0 or 1.
> Anyway, will send a patch with #if.
>
The inlining due to the code coming from a header probably breaks
dead-code-elimination in some compilers.
- Hendrik
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move ff_nlmeans_init into a header
2022-05-13 9:00 ` Hendrik Leppkes
@ 2022-05-13 9:03 ` Soft Works
0 siblings, 0 replies; 21+ messages in thread
From: Soft Works @ 2022-05-13 9:03 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Hendrik Leppkes
> Sent: Friday, May 13, 2022 11:00 AM
> To: FFmpeg development discussions and patches <ffmpeg-
> devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move
> ff_nlmeans_init into a header
>
> On Fri, May 13, 2022 at 10:27 AM Andreas Rheinhardt
> <andreas.rheinhardt@outlook.com> wrote:
> >
> > Soft Works:
> > >
> > >
> > >> -----Original Message-----
> > >> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> > >> Andreas Rheinhardt
> > >> Sent: Tuesday, May 3, 2022 8:38 AM
> > >> To: ffmpeg-devel@ffmpeg.org
> > >> Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> > >> Subject: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move
> > >> ff_nlmeans_init into a header
> > >>
> > >> This removes a dependency of checkasm on lavfi/vf_nlmeans.o
> > >> and also allows to inline ff_nlmeans_init() irrespectively of
> > >> interposing.
> > >>
> > >> Signed-off-by: Andreas Rheinhardt
> <andreas.rheinhardt@outlook.com>
> > >> ---
> > >
> > > [..]
> > >
> > >> +
> > >> +static av_unused void ff_nlmeans_init(NLMeansDSPContext *dsp)
> > >> +{
> > >> + dsp->compute_safe_ssd_integral_image =
> > >> compute_safe_ssd_integral_image_c;
> > >> + dsp->compute_weights_line = compute_weights_line_c;
> > >> +
> > >> + if (ARCH_AARCH64)
> > >> + ff_nlmeans_init_aarch64(dsp);
> > >
> > > Hi Andreas,
> > >
> > > the above breaks compilation for me:
> > >
> > > 1>libavfilterd.lib(libavfilter_vf_nlmeans.obj) : error LNK2019:
> unresolved external symbol ff_nlmeans_init_aarch64 referenced in
> function ff_nlmeans_init
> > >
> > > The reason is that I'm (obviously) not compiling stuff from the
> > > libavfilter\aarch64 subfolder.
> > >
> > > It might need an #ifdef ?
> > >
> > > I haven't taken a deeper look at it, though.
> > >
> > > Thanks,
> > > softworkz
> > >
> > >
> >
> > That surprises me: The earlier code did exactly the same; in fact,
> using
> > if (ARCH_*) is our typical check for arches in dsp-init code.
> > Is this the only place where this happens?
> > #ifdef is certainly wrong: All ARCH_* are always defined; they are
> just
> > 0 or 1.
> > Anyway, will send a patch with #if.
> >
>
> The inlining due to the code coming from a header probably breaks
> dead-code-elimination in some compilers.
Ah, that explains why that file with the empty stubs is named
dce_defs.c :-)
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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move ff_nlmeans_init into a header
2022-05-13 8:27 ` Andreas Rheinhardt
2022-05-13 9:00 ` Hendrik Leppkes
@ 2022-05-13 9:01 ` Soft Works
2022-05-13 9:13 ` Hendrik Leppkes
2022-05-13 9:25 ` Andreas Rheinhardt
1 sibling, 2 replies; 21+ messages in thread
From: Soft Works @ 2022-05-13 9:01 UTC (permalink / raw)
To: Andreas Rheinhardt, FFmpeg development discussions and patches
> -----Original Message-----
> From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> Sent: Friday, May 13, 2022 10:27 AM
> To: Soft Works <softworkz@hotmail.com>; FFmpeg development discussions
> and patches <ffmpeg-devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move
> ff_nlmeans_init into a header
>
> Soft Works:
> >
> >
> >> -----Original Message-----
> >> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> >> Andreas Rheinhardt
> >> Sent: Tuesday, May 3, 2022 8:38 AM
> >> To: ffmpeg-devel@ffmpeg.org
> >> Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> >> Subject: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move
> >> ff_nlmeans_init into a header
> >>
> >> This removes a dependency of checkasm on lavfi/vf_nlmeans.o
> >> and also allows to inline ff_nlmeans_init() irrespectively of
> >> interposing.
> >>
> >> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> >> ---
> >
> > [..]
> >
> >> +
> >> +static av_unused void ff_nlmeans_init(NLMeansDSPContext *dsp)
> >> +{
> >> + dsp->compute_safe_ssd_integral_image =
> >> compute_safe_ssd_integral_image_c;
> >> + dsp->compute_weights_line = compute_weights_line_c;
> >> +
> >> + if (ARCH_AARCH64)
> >> + ff_nlmeans_init_aarch64(dsp);
> >
> > Hi Andreas,
> >
> > the above breaks compilation for me:
> >
> > 1>libavfilterd.lib(libavfilter_vf_nlmeans.obj) : error LNK2019:
> unresolved external symbol ff_nlmeans_init_aarch64 referenced in
> function ff_nlmeans_init
> >
> > The reason is that I'm (obviously) not compiling stuff from the
> > libavfilter\aarch64 subfolder.
> >
> > It might need an #ifdef ?
> >
> > I haven't taken a deeper look at it, though.
> >
> > Thanks,
> > softworkz
> >
> >
>
> That surprises me: The earlier code did exactly the same; in fact,
> using
> if (ARCH_*) is our typical check for arches in dsp-init code.
I looked at this a bit further. It seems that the VS project
generation tool that I'm using is creating dummy definitions
for such cases. In the previous workspace it had generated
void ff_nlmeans_init_aarch64(NLMeansDSPContext *dsp) {return;}
in a separate code file for being able to work with the ffmpeg
code in VS without modifying any of the code.
Now that you have moved that code to a header file, this logic
doesn't work anymore.
> Is this the only place where this happens?
Yes.
> Anyway, will send a patch with #if.
Great, 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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move ff_nlmeans_init into a header
2022-05-13 9:01 ` Soft Works
@ 2022-05-13 9:13 ` Hendrik Leppkes
2022-05-13 9:25 ` Andreas Rheinhardt
1 sibling, 0 replies; 21+ messages in thread
From: Hendrik Leppkes @ 2022-05-13 9:13 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Fri, May 13, 2022 at 11:01 AM Soft Works <softworkz@hotmail.com> wrote:
>
>
>
> > -----Original Message-----
> > From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> > Sent: Friday, May 13, 2022 10:27 AM
> > To: Soft Works <softworkz@hotmail.com>; FFmpeg development discussions
> > and patches <ffmpeg-devel@ffmpeg.org>
> > Subject: Re: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move
> > ff_nlmeans_init into a header
> >
> > Soft Works:
> > >
> > >
> > >> -----Original Message-----
> > >> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> > >> Andreas Rheinhardt
> > >> Sent: Tuesday, May 3, 2022 8:38 AM
> > >> To: ffmpeg-devel@ffmpeg.org
> > >> Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> > >> Subject: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move
> > >> ff_nlmeans_init into a header
> > >>
> > >> This removes a dependency of checkasm on lavfi/vf_nlmeans.o
> > >> and also allows to inline ff_nlmeans_init() irrespectively of
> > >> interposing.
> > >>
> > >> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> > >> ---
> > >
> > > [..]
> > >
> > >> +
> > >> +static av_unused void ff_nlmeans_init(NLMeansDSPContext *dsp)
> > >> +{
> > >> + dsp->compute_safe_ssd_integral_image =
> > >> compute_safe_ssd_integral_image_c;
> > >> + dsp->compute_weights_line = compute_weights_line_c;
> > >> +
> > >> + if (ARCH_AARCH64)
> > >> + ff_nlmeans_init_aarch64(dsp);
> > >
> > > Hi Andreas,
> > >
> > > the above breaks compilation for me:
> > >
> > > 1>libavfilterd.lib(libavfilter_vf_nlmeans.obj) : error LNK2019:
> > unresolved external symbol ff_nlmeans_init_aarch64 referenced in
> > function ff_nlmeans_init
> > >
> > > The reason is that I'm (obviously) not compiling stuff from the
> > > libavfilter\aarch64 subfolder.
> > >
> > > It might need an #ifdef ?
> > >
> > > I haven't taken a deeper look at it, though.
> > >
> > > Thanks,
> > > softworkz
> > >
> > >
> >
> > That surprises me: The earlier code did exactly the same; in fact,
> > using
> > if (ARCH_*) is our typical check for arches in dsp-init code.
>
> I looked at this a bit further. It seems that the VS project
> generation tool that I'm using is creating dummy definitions
> for such cases. In the previous workspace it had generated
>
> void ff_nlmeans_init_aarch64(NLMeansDSPContext *dsp) {return;}
>
> in a separate code file for being able to work with the ffmpeg
> code in VS without modifying any of the code.
>
> Now that you have moved that code to a header file, this logic
> doesn't work anymore.
>
Nevermind my previous comment then, perhaps external tools should be
updated if they somehow work around our need for DCE (which is well
documented).
- Hendrik
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move ff_nlmeans_init into a header
2022-05-13 9:01 ` Soft Works
2022-05-13 9:13 ` Hendrik Leppkes
@ 2022-05-13 9:25 ` Andreas Rheinhardt
2022-05-13 9:27 ` Hendrik Leppkes
2022-05-13 9:32 ` Soft Works
1 sibling, 2 replies; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-05-13 9:25 UTC (permalink / raw)
To: Soft Works, FFmpeg development discussions and patches
Soft Works:
>
>
>> -----Original Message-----
>> From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>> Sent: Friday, May 13, 2022 10:27 AM
>> To: Soft Works <softworkz@hotmail.com>; FFmpeg development discussions
>> and patches <ffmpeg-devel@ffmpeg.org>
>> Subject: Re: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move
>> ff_nlmeans_init into a header
>>
>> Soft Works:
>>>
>>>
>>>> -----Original Message-----
>>>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
>>>> Andreas Rheinhardt
>>>> Sent: Tuesday, May 3, 2022 8:38 AM
>>>> To: ffmpeg-devel@ffmpeg.org
>>>> Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>>>> Subject: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move
>>>> ff_nlmeans_init into a header
>>>>
>>>> This removes a dependency of checkasm on lavfi/vf_nlmeans.o
>>>> and also allows to inline ff_nlmeans_init() irrespectively of
>>>> interposing.
>>>>
>>>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>>>> ---
>>>
>>> [..]
>>>
>>>> +
>>>> +static av_unused void ff_nlmeans_init(NLMeansDSPContext *dsp)
>>>> +{
>>>> + dsp->compute_safe_ssd_integral_image =
>>>> compute_safe_ssd_integral_image_c;
>>>> + dsp->compute_weights_line = compute_weights_line_c;
>>>> +
>>>> + if (ARCH_AARCH64)
>>>> + ff_nlmeans_init_aarch64(dsp);
>>>
>>> Hi Andreas,
>>>
>>> the above breaks compilation for me:
>>>
>>> 1>libavfilterd.lib(libavfilter_vf_nlmeans.obj) : error LNK2019:
>> unresolved external symbol ff_nlmeans_init_aarch64 referenced in
>> function ff_nlmeans_init
>>>
>>> The reason is that I'm (obviously) not compiling stuff from the
>>> libavfilter\aarch64 subfolder.
>>>
>>> It might need an #ifdef ?
>>>
>>> I haven't taken a deeper look at it, though.
>>>
>>> Thanks,
>>> softworkz
>>>
>>>
>>
>> That surprises me: The earlier code did exactly the same; in fact,
>> using
>> if (ARCH_*) is our typical check for arches in dsp-init code.
>
> I looked at this a bit further. It seems that the VS project
> generation tool that I'm using is creating dummy definitions
> for such cases. In the previous workspace it had generated
>
> void ff_nlmeans_init_aarch64(NLMeansDSPContext *dsp) {return;}
>
> in a separate code file for being able to work with the ffmpeg
> code in VS without modifying any of the code.
>
> Now that you have moved that code to a header file, this logic
> doesn't work anymore.
>
Why does your compiler not just eliminate dead code like all the others?
Is this MSVC -O0 behaviour?
I just sent the patch
https://ffmpeg.org/pipermail/ffmpeg-devel/2022-May/296380.html, but now
that I read this I have to agree with Hendrik: Why not update your tool
instead?
- Andreas
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move ff_nlmeans_init into a header
2022-05-13 9:25 ` Andreas Rheinhardt
@ 2022-05-13 9:27 ` Hendrik Leppkes
2022-05-13 9:34 ` Soft Works
2022-05-13 9:32 ` Soft Works
1 sibling, 1 reply; 21+ messages in thread
From: Hendrik Leppkes @ 2022-05-13 9:27 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Fri, May 13, 2022 at 11:26 AM Andreas Rheinhardt
<andreas.rheinhardt@outlook.com> wrote:
>
> Soft Works:
> >
> >
> >> -----Original Message-----
> >> From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> >> Sent: Friday, May 13, 2022 10:27 AM
> >> To: Soft Works <softworkz@hotmail.com>; FFmpeg development discussions
> >> and patches <ffmpeg-devel@ffmpeg.org>
> >> Subject: Re: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move
> >> ff_nlmeans_init into a header
> >>
> >> Soft Works:
> >>>
> >>>
> >>>> -----Original Message-----
> >>>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> >>>> Andreas Rheinhardt
> >>>> Sent: Tuesday, May 3, 2022 8:38 AM
> >>>> To: ffmpeg-devel@ffmpeg.org
> >>>> Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> >>>> Subject: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move
> >>>> ff_nlmeans_init into a header
> >>>>
> >>>> This removes a dependency of checkasm on lavfi/vf_nlmeans.o
> >>>> and also allows to inline ff_nlmeans_init() irrespectively of
> >>>> interposing.
> >>>>
> >>>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> >>>> ---
> >>>
> >>> [..]
> >>>
> >>>> +
> >>>> +static av_unused void ff_nlmeans_init(NLMeansDSPContext *dsp)
> >>>> +{
> >>>> + dsp->compute_safe_ssd_integral_image =
> >>>> compute_safe_ssd_integral_image_c;
> >>>> + dsp->compute_weights_line = compute_weights_line_c;
> >>>> +
> >>>> + if (ARCH_AARCH64)
> >>>> + ff_nlmeans_init_aarch64(dsp);
> >>>
> >>> Hi Andreas,
> >>>
> >>> the above breaks compilation for me:
> >>>
> >>> 1>libavfilterd.lib(libavfilter_vf_nlmeans.obj) : error LNK2019:
> >> unresolved external symbol ff_nlmeans_init_aarch64 referenced in
> >> function ff_nlmeans_init
> >>>
> >>> The reason is that I'm (obviously) not compiling stuff from the
> >>> libavfilter\aarch64 subfolder.
> >>>
> >>> It might need an #ifdef ?
> >>>
> >>> I haven't taken a deeper look at it, though.
> >>>
> >>> Thanks,
> >>> softworkz
> >>>
> >>>
> >>
> >> That surprises me: The earlier code did exactly the same; in fact,
> >> using
> >> if (ARCH_*) is our typical check for arches in dsp-init code.
> >
> > I looked at this a bit further. It seems that the VS project
> > generation tool that I'm using is creating dummy definitions
> > for such cases. In the previous workspace it had generated
> >
> > void ff_nlmeans_init_aarch64(NLMeansDSPContext *dsp) {return;}
> >
> > in a separate code file for being able to work with the ffmpeg
> > code in VS without modifying any of the code.
> >
> > Now that you have moved that code to a header file, this logic
> > doesn't work anymore.
> >
>
> Why does your compiler not just eliminate dead code like all the others?
> Is this MSVC -O0 behaviour?
MSVC does not do DCE when optimizations are disabled, yes. So this is
where this is coming from.
> I just sent the patch
> https://ffmpeg.org/pipermail/ffmpeg-devel/2022-May/296380.html, but now
> that I read this I have to agree with Hendrik: Why not update your tool
> instead?
>
Actually looking at the tool, it seems like it handles header files.
Did you actually re-run the generation tool after applying this patch?
- Hendrik
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move ff_nlmeans_init into a header
2022-05-13 9:27 ` Hendrik Leppkes
@ 2022-05-13 9:34 ` Soft Works
0 siblings, 0 replies; 21+ messages in thread
From: Soft Works @ 2022-05-13 9:34 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Hendrik Leppkes
> Sent: Friday, May 13, 2022 11:27 AM
> To: FFmpeg development discussions and patches <ffmpeg-
> devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move
> ff_nlmeans_init into a header
>
> On Fri, May 13, 2022 at 11:26 AM Andreas Rheinhardt
> <andreas.rheinhardt@outlook.com> wrote:
> >
> > Soft Works:
> > >
> > >
> > >> -----Original Message-----
> > >> From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> > >> Sent: Friday, May 13, 2022 10:27 AM
> > >> To: Soft Works <softworkz@hotmail.com>; FFmpeg development
> discussions
> > >> and patches <ffmpeg-devel@ffmpeg.org>
> > >> Subject: Re: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans:
> Move
> > >> ff_nlmeans_init into a header
> > >>
> > >> Soft Works:
> > >>>
> > >>>
> > >>>> -----Original Message-----
> > >>>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf
> Of
> > >>>> Andreas Rheinhardt
> > >>>> Sent: Tuesday, May 3, 2022 8:38 AM
> > >>>> To: ffmpeg-devel@ffmpeg.org
> > >>>> Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> > >>>> Subject: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move
> > >>>> ff_nlmeans_init into a header
> > >>>>
> > >>>> This removes a dependency of checkasm on lavfi/vf_nlmeans.o
> > >>>> and also allows to inline ff_nlmeans_init() irrespectively of
> > >>>> interposing.
> > >>>>
> > >>>> Signed-off-by: Andreas Rheinhardt
> <andreas.rheinhardt@outlook.com>
> > >>>> ---
> > >>>
> > >>> [..]
> > >>>
> > >>>> +
> > >>>> +static av_unused void ff_nlmeans_init(NLMeansDSPContext *dsp)
> > >>>> +{
> > >>>> + dsp->compute_safe_ssd_integral_image =
> > >>>> compute_safe_ssd_integral_image_c;
> > >>>> + dsp->compute_weights_line = compute_weights_line_c;
> > >>>> +
> > >>>> + if (ARCH_AARCH64)
> > >>>> + ff_nlmeans_init_aarch64(dsp);
> > >>>
> > >>> Hi Andreas,
> > >>>
> > >>> the above breaks compilation for me:
> > >>>
> > >>> 1>libavfilterd.lib(libavfilter_vf_nlmeans.obj) : error LNK2019:
> > >> unresolved external symbol ff_nlmeans_init_aarch64 referenced in
> > >> function ff_nlmeans_init
> > >>>
> > >>> The reason is that I'm (obviously) not compiling stuff from the
> > >>> libavfilter\aarch64 subfolder.
> > >>>
> > >>> It might need an #ifdef ?
> > >>>
> > >>> I haven't taken a deeper look at it, though.
> > >>>
> > >>> Thanks,
> > >>> softworkz
> > >>>
> > >>>
> > >>
> > >> That surprises me: The earlier code did exactly the same; in
> fact,
> > >> using
> > >> if (ARCH_*) is our typical check for arches in dsp-init code.
> > >
> > > I looked at this a bit further. It seems that the VS project
> > > generation tool that I'm using is creating dummy definitions
> > > for such cases. In the previous workspace it had generated
> > >
> > > void ff_nlmeans_init_aarch64(NLMeansDSPContext *dsp) {return;}
> > >
> > > in a separate code file for being able to work with the ffmpeg
> > > code in VS without modifying any of the code.
> > >
> > > Now that you have moved that code to a header file, this logic
> > > doesn't work anymore.
> > >
> >
> > Why does your compiler not just eliminate dead code like all the
> others?
> > Is this MSVC -O0 behaviour?
>
>
> MSVC does not do DCE when optimizations are disabled, yes. So this is
> where this is coming from.
>
> > I just sent the patch
> > https://ffmpeg.org/pipermail/ffmpeg-devel/2022-May/296380.html, but
> now
> > that I read this I have to agree with Hendrik: Why not update your
> tool
> > instead?
> >
>
> Actually looking at the tool, it seems like it handles header files.
> Did you actually re-run the generation tool after applying this patch?
Today I pulled HEAD and ran the tool (after I had pulled the latest
version of the tool and compiled it). It didn't detect the header
definition. That's why I wrote to Andreas.
Thanks a lot for your help!
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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move ff_nlmeans_init into a header
2022-05-13 9:25 ` Andreas Rheinhardt
2022-05-13 9:27 ` Hendrik Leppkes
@ 2022-05-13 9:32 ` Soft Works
1 sibling, 0 replies; 21+ messages in thread
From: Soft Works @ 2022-05-13 9:32 UTC (permalink / raw)
To: Andreas Rheinhardt, FFmpeg development discussions and patches
> -----Original Message-----
> From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> Sent: Friday, May 13, 2022 11:26 AM
> To: Soft Works <softworkz@hotmail.com>; FFmpeg development discussions
> and patches <ffmpeg-devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move
> ff_nlmeans_init into a header
>
> Soft Works:
> >
> >
> >> -----Original Message-----
> >> From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> >> Sent: Friday, May 13, 2022 10:27 AM
> >> To: Soft Works <softworkz@hotmail.com>; FFmpeg development
> discussions
> >> and patches <ffmpeg-devel@ffmpeg.org>
> >> Subject: Re: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move
> >> ff_nlmeans_init into a header
> >>
> >> Soft Works:
> >>>
> >>>
> >>>> -----Original Message-----
> >>>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> >>>> Andreas Rheinhardt
> >>>> Sent: Tuesday, May 3, 2022 8:38 AM
> >>>> To: ffmpeg-devel@ffmpeg.org
> >>>> Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> >>>> Subject: [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move
> >>>> ff_nlmeans_init into a header
> >>>>
> >>>> This removes a dependency of checkasm on lavfi/vf_nlmeans.o
> >>>> and also allows to inline ff_nlmeans_init() irrespectively of
> >>>> interposing.
> >>>>
> >>>> Signed-off-by: Andreas Rheinhardt
> <andreas.rheinhardt@outlook.com>
> >>>> ---
> >>>
> >>> [..]
> >>>
> >>>> +
> >>>> +static av_unused void ff_nlmeans_init(NLMeansDSPContext *dsp)
> >>>> +{
> >>>> + dsp->compute_safe_ssd_integral_image =
> >>>> compute_safe_ssd_integral_image_c;
> >>>> + dsp->compute_weights_line = compute_weights_line_c;
> >>>> +
> >>>> + if (ARCH_AARCH64)
> >>>> + ff_nlmeans_init_aarch64(dsp);
> >>>
> >>> Hi Andreas,
> >>>
> >>> the above breaks compilation for me:
> >>>
> >>> 1>libavfilterd.lib(libavfilter_vf_nlmeans.obj) : error LNK2019:
> >> unresolved external symbol ff_nlmeans_init_aarch64 referenced in
> >> function ff_nlmeans_init
> >>>
> >>> The reason is that I'm (obviously) not compiling stuff from the
> >>> libavfilter\aarch64 subfolder.
> >>>
> >>> It might need an #ifdef ?
> >>>
> >>> I haven't taken a deeper look at it, though.
> >>>
> >>> Thanks,
> >>> softworkz
> >>>
> >>>
> >>
> >> That surprises me: The earlier code did exactly the same; in fact,
> >> using
> >> if (ARCH_*) is our typical check for arches in dsp-init code.
> >
> > I looked at this a bit further. It seems that the VS project
> > generation tool that I'm using is creating dummy definitions
> > for such cases. In the previous workspace it had generated
> >
> > void ff_nlmeans_init_aarch64(NLMeansDSPContext *dsp) {return;}
> >
> > in a separate code file for being able to work with the ffmpeg
> > code in VS without modifying any of the code.
> >
> > Now that you have moved that code to a header file, this logic
> > doesn't work anymore.
> >
>
> Why does your compiler not just eliminate dead code like all the
> others?
> Is this MSVC -O0 behaviour?
> I just sent the patch
> https://ffmpeg.org/pipermail/ffmpeg-devel/2022-May/296380.html, but
> now
> that I read this I have to agree with Hendrik: Why not update your
> tool
> instead?
I'm using https://github.com/ShiftMediaProject/FFVS-Project-Generator
for years and I'm sure he will adapt.
When I had posted, the whole situation wasn't clear to me.
Thanks a lot for the patch!
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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 21+ messages in thread
* [FFmpeg-devel] [PATCH 08/10] avfilter/vf_threshold: Move ff_threshold_init into a header
2022-05-03 6:18 [FFmpeg-devel] [PATCH 01/10] avfilter/af_afir: Only keep DSP stuff in header Andreas Rheinhardt
` (5 preceding siblings ...)
2022-05-03 6:37 ` [FFmpeg-devel] [PATCH 07/10] avfilter/vf_nlmeans: Move ff_nlmeans_init " Andreas Rheinhardt
@ 2022-05-03 6:37 ` Andreas Rheinhardt
2022-05-03 6:37 ` [FFmpeg-devel] [PATCH 09/10] avcodec/v210_dec: Move ff_v210dec_init " Andreas Rheinhardt
` (2 subsequent siblings)
9 siblings, 0 replies; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-05-03 6:37 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
This removes a dependency of checkasm on lavfi/vf_threshold.o
and also allows to inline ff_threshold_init() irrespectively of
interposing.
With this patch checkasm no longer pulls all of lavfi and lavf in.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavfilter/threshold.h | 1 -
libavfilter/vf_threshold.c | 66 +-----------------------
libavfilter/vf_threshold_init.h | 91 +++++++++++++++++++++++++++++++++
tests/checkasm/vf_threshold.c | 2 +-
4 files changed, 93 insertions(+), 67 deletions(-)
create mode 100644 libavfilter/vf_threshold_init.h
diff --git a/libavfilter/threshold.h b/libavfilter/threshold.h
index 775a9f9cae..8b55ad6ba1 100644
--- a/libavfilter/threshold.h
+++ b/libavfilter/threshold.h
@@ -46,7 +46,6 @@ typedef struct ThresholdContext {
FFFrameSync fs;
} ThresholdContext;
-void ff_threshold_init(ThresholdContext *s);
void ff_threshold_init_x86(ThresholdContext *s);
#endif /* AVFILTER_THRESHOLD_H */
diff --git a/libavfilter/vf_threshold.c b/libavfilter/vf_threshold.c
index 2a0add4a8f..dc73c277d3 100644
--- a/libavfilter/vf_threshold.c
+++ b/libavfilter/vf_threshold.c
@@ -32,6 +32,7 @@
#include "internal.h"
#include "video.h"
#include "threshold.h"
+#include "vf_threshold_init.h"
#define OFFSET(x) offsetof(ThresholdContext, x)
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
@@ -150,57 +151,6 @@ static int process_frame(FFFrameSync *fs)
return ff_filter_frame(outlink, out);
}
-static void threshold8(const uint8_t *in, const uint8_t *threshold,
- const uint8_t *min, const uint8_t *max,
- uint8_t *out,
- ptrdiff_t ilinesize, ptrdiff_t tlinesize,
- ptrdiff_t flinesize, ptrdiff_t slinesize,
- ptrdiff_t olinesize,
- int w, int h)
-{
- int x, y;
-
- for (y = 0; y < h; y++) {
- for (x = 0; x < w; x++) {
- out[x] = in[x] < threshold[x] ? min[x] : max[x];
- }
-
- in += ilinesize;
- threshold += tlinesize;
- min += flinesize;
- max += slinesize;
- out += olinesize;
- }
-}
-
-static void threshold16(const uint8_t *iin, const uint8_t *tthreshold,
- const uint8_t *ffirst, const uint8_t *ssecond,
- uint8_t *oout,
- ptrdiff_t ilinesize, ptrdiff_t tlinesize,
- ptrdiff_t flinesize, ptrdiff_t slinesize,
- ptrdiff_t olinesize,
- int w, int h)
-{
- const uint16_t *in = (const uint16_t *)iin;
- const uint16_t *threshold = (const uint16_t *)tthreshold;
- const uint16_t *min = (const uint16_t *)ffirst;
- const uint16_t *max = (const uint16_t *)ssecond;
- uint16_t *out = (uint16_t *)oout;
- int x, y;
-
- for (y = 0; y < h; y++) {
- for (x = 0; x < w; x++) {
- out[x] = in[x] < threshold[x] ? min[x] : max[x];
- }
-
- in += ilinesize / 2;
- threshold += tlinesize / 2;
- min += flinesize / 2;
- max += slinesize / 2;
- out += olinesize / 2;
- }
-}
-
static int config_input(AVFilterLink *inlink)
{
AVFilterContext *ctx = inlink->dst;
@@ -223,20 +173,6 @@ static int config_input(AVFilterLink *inlink)
return 0;
}
-void ff_threshold_init(ThresholdContext *s)
-{
- if (s->depth == 8) {
- s->threshold = threshold8;
- s->bpc = 1;
- } else {
- s->threshold = threshold16;
- s->bpc = 2;
- }
-
- if (ARCH_X86)
- ff_threshold_init_x86(s);
-}
-
static int config_output(AVFilterLink *outlink)
{
AVFilterContext *ctx = outlink->src;
diff --git a/libavfilter/vf_threshold_init.h b/libavfilter/vf_threshold_init.h
new file mode 100644
index 0000000000..e79d2bb63d
--- /dev/null
+++ b/libavfilter/vf_threshold_init.h
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2016 Paul B Mahol
+ *
+ * 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
+ */
+
+#ifndef AVFILTER_THRESHOLD_INIT_H
+#define AVFILTER_THRESHOLD_INIT_H
+
+#include <stdint.h>
+#include <stddef.h>
+
+#include "config.h"
+#include "libavutil/attributes.h"
+#include "threshold.h"
+
+static void threshold8(const uint8_t *in, const uint8_t *threshold,
+ const uint8_t *min, const uint8_t *max,
+ uint8_t *out,
+ ptrdiff_t ilinesize, ptrdiff_t tlinesize,
+ ptrdiff_t flinesize, ptrdiff_t slinesize,
+ ptrdiff_t olinesize,
+ int w, int h)
+{
+ for (int y = 0; y < h; y++) {
+ for (int x = 0; x < w; x++)
+ out[x] = in[x] < threshold[x] ? min[x] : max[x];
+
+ in += ilinesize;
+ threshold += tlinesize;
+ min += flinesize;
+ max += slinesize;
+ out += olinesize;
+ }
+}
+
+static void threshold16(const uint8_t *iin, const uint8_t *tthreshold,
+ const uint8_t *ffirst, const uint8_t *ssecond,
+ uint8_t *oout,
+ ptrdiff_t ilinesize, ptrdiff_t tlinesize,
+ ptrdiff_t flinesize, ptrdiff_t slinesize,
+ ptrdiff_t olinesize,
+ int w, int h)
+{
+ const uint16_t *in = (const uint16_t *)iin;
+ const uint16_t *threshold = (const uint16_t *)tthreshold;
+ const uint16_t *min = (const uint16_t *)ffirst;
+ const uint16_t *max = (const uint16_t *)ssecond;
+ uint16_t *out = (uint16_t *)oout;
+
+ for (int y = 0; y < h; y++) {
+ for (int x = 0; x < w; x++)
+ out[x] = in[x] < threshold[x] ? min[x] : max[x];
+
+ in += ilinesize / 2;
+ threshold += tlinesize / 2;
+ min += flinesize / 2;
+ max += slinesize / 2;
+ out += olinesize / 2;
+ }
+}
+
+static av_unused void ff_threshold_init(ThresholdContext *s)
+{
+ if (s->depth == 8) {
+ s->threshold = threshold8;
+ s->bpc = 1;
+ } else {
+ s->threshold = threshold16;
+ s->bpc = 2;
+ }
+
+ if (ARCH_X86)
+ ff_threshold_init_x86(s);
+}
+
+#endif /* AVFILTER_THRESHOLD_INIT_H */
diff --git a/tests/checkasm/vf_threshold.c b/tests/checkasm/vf_threshold.c
index 2c5cc807ee..e6a425edfe 100644
--- a/tests/checkasm/vf_threshold.c
+++ b/tests/checkasm/vf_threshold.c
@@ -18,7 +18,7 @@
#include <string.h>
#include "checkasm.h"
-#include "libavfilter/threshold.h"
+#include "libavfilter/vf_threshold_init.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem_internal.h"
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 21+ messages in thread
* [FFmpeg-devel] [PATCH 09/10] avcodec/v210_dec: Move ff_v210dec_init into a header
2022-05-03 6:18 [FFmpeg-devel] [PATCH 01/10] avfilter/af_afir: Only keep DSP stuff in header Andreas Rheinhardt
` (6 preceding siblings ...)
2022-05-03 6:37 ` [FFmpeg-devel] [PATCH 08/10] avfilter/vf_threshold: Move ff_threshold_init " Andreas Rheinhardt
@ 2022-05-03 6:37 ` Andreas Rheinhardt
2022-05-03 6:37 ` [FFmpeg-devel] [PATCH 10/10] avcodec/v210_enc: Move ff_v210enc_init " Andreas Rheinhardt
2022-05-05 1:55 ` [FFmpeg-devel] [PATCH 01/10] avfilter/af_afir: Only keep DSP stuff in header Andreas Rheinhardt
9 siblings, 0 replies; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-05-03 6:37 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
This removes a dependency of checkasm on lavc/v210_dec.o
and also allows to inline ff_v210dec_init() irrespectively of
interposing.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/v210dec.c | 29 +------------------
libavcodec/v210dec.h | 1 -
libavcodec/v210dec_init.h | 61 +++++++++++++++++++++++++++++++++++++++
tests/checkasm/v210dec.c | 2 +-
4 files changed, 63 insertions(+), 30 deletions(-)
create mode 100644 libavcodec/v210dec_init.h
diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
index b5e1d728a7..6c10ef6a7c 100644
--- a/libavcodec/v210dec.c
+++ b/libavcodec/v210dec.c
@@ -24,45 +24,18 @@
#include "avcodec.h"
#include "codec_internal.h"
#include "v210dec.h"
+#include "v210dec_init.h"
#include "libavutil/bswap.h"
#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "thread.h"
-#define READ_PIXELS(a, b, c) \
- do { \
- val = av_le2ne32(*src++); \
- *a++ = val & 0x3FF; \
- *b++ = (val >> 10) & 0x3FF; \
- *c++ = (val >> 20) & 0x3FF; \
- } while (0)
-
typedef struct ThreadData {
AVFrame *frame;
uint8_t *buf;
int stride;
} ThreadData;
-static void v210_planar_unpack_c(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *v, int width)
-{
- uint32_t val;
- int i;
-
- for( i = 0; i < width-5; i += 6 ){
- READ_PIXELS(u, y, v);
- READ_PIXELS(y, u, y);
- READ_PIXELS(v, y, u);
- READ_PIXELS(y, v, y);
- }
-}
-
-av_cold void ff_v210dec_init(V210DecContext *s)
-{
- s->unpack_frame = v210_planar_unpack_c;
- if (ARCH_X86)
- ff_v210_x86_init(s);
-}
-
static av_cold int decode_init(AVCodecContext *avctx)
{
V210DecContext *s = avctx->priv_data;
diff --git a/libavcodec/v210dec.h b/libavcodec/v210dec.h
index 662e266315..87ba38e151 100644
--- a/libavcodec/v210dec.h
+++ b/libavcodec/v210dec.h
@@ -32,7 +32,6 @@ typedef struct {
void (*unpack_frame)(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *v, int width);
} V210DecContext;
-void ff_v210dec_init(V210DecContext *s);
void ff_v210_x86_init(V210DecContext *s);
#endif /* AVCODEC_V210DEC_H */
diff --git a/libavcodec/v210dec_init.h b/libavcodec/v210dec_init.h
new file mode 100644
index 0000000000..305ab3911e
--- /dev/null
+++ b/libavcodec/v210dec_init.h
@@ -0,0 +1,61 @@
+/*
+ * V210 decoder DSP init
+ *
+ * Copyright (C) 2009 Michael Niedermayer <michaelni@gmx.at>
+ * Copyright (c) 2009 Baptiste Coudurier <baptiste dot coudurier at gmail dot com>
+ *
+ * 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
+ */
+
+#ifndef AVCODEC_V210DEC_INIT_H
+#define AVCODEC_V210DEC_INIT_H
+
+#include <stdint.h>
+
+#include "config.h"
+#include "libavutil/attributes.h"
+#include "libavutil/bswap.h"
+#include "v210dec.h"
+
+#define READ_PIXELS(a, b, c) \
+ do { \
+ val = av_le2ne32(*src++); \
+ *a++ = val & 0x3FF; \
+ *b++ = (val >> 10) & 0x3FF; \
+ *c++ = (val >> 20) & 0x3FF; \
+ } while (0)
+
+static void v210_planar_unpack_c(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *v, int width)
+{
+ uint32_t val;
+
+ for (int i = 0; i < width - 5; i += 6) {
+ READ_PIXELS(u, y, v);
+ READ_PIXELS(y, u, y);
+ READ_PIXELS(v, y, u);
+ READ_PIXELS(y, v, y);
+ }
+}
+
+static av_unused av_cold void ff_v210dec_init(V210DecContext *s)
+{
+ s->unpack_frame = v210_planar_unpack_c;
+ if (ARCH_X86)
+ ff_v210_x86_init(s);
+}
+
+#endif /* AVCODEC_V210DEC_INIT_H */
diff --git a/tests/checkasm/v210dec.c b/tests/checkasm/v210dec.c
index 7dd50a8271..6aef519cc5 100644
--- a/tests/checkasm/v210dec.c
+++ b/tests/checkasm/v210dec.c
@@ -20,7 +20,7 @@
#include <string.h>
#include "checkasm.h"
-#include "libavcodec/v210dec.h"
+#include "libavcodec/v210dec_init.h"
static uint32_t get_v210(void)
{
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 21+ messages in thread
* [FFmpeg-devel] [PATCH 10/10] avcodec/v210_enc: Move ff_v210enc_init into a header
2022-05-03 6:18 [FFmpeg-devel] [PATCH 01/10] avfilter/af_afir: Only keep DSP stuff in header Andreas Rheinhardt
` (7 preceding siblings ...)
2022-05-03 6:37 ` [FFmpeg-devel] [PATCH 09/10] avcodec/v210_dec: Move ff_v210dec_init " Andreas Rheinhardt
@ 2022-05-03 6:37 ` Andreas Rheinhardt
2022-05-05 1:55 ` [FFmpeg-devel] [PATCH 01/10] avfilter/af_afir: Only keep DSP stuff in header Andreas Rheinhardt
9 siblings, 0 replies; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-05-03 6:37 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
This removes a dependency of checkasm on lavc/v210_enc.o
and also allows to inline ff_v210enc_init() irrespectively of
interposing.
This dependency pulled basically all of libavcodec into checkasm,
in particular all codecs.
This also makes checkasm work when using shared Windows builds:
On Windows, it needs to be known to the compiler whether a data
symbol is external to the library/executable or not; hence the
need for av_export_avutil. checkasm needs access to the internals
of the libraries it tests and is therefore linked statically to all
the libraries. This means that the users of avpriv_cga_font and
avpriv_vga16_font in libavcodec (namely ansi.o, bintext.o, tmv.o)
end up in the same executable as the symbols, although they have
been compiled as if these symbols were external, leading to linker
errors. With this commit said files are discarded by the linker,
bypassing this problem.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/v210_template.c | 10 -----
libavcodec/v210enc.c | 48 +-------------------
libavcodec/v210enc.h | 2 -
libavcodec/v210enc_init.h | 90 ++++++++++++++++++++++++++++++++++++++
tests/checkasm/v210enc.c | 2 +-
5 files changed, 92 insertions(+), 60 deletions(-)
create mode 100644 libavcodec/v210enc_init.h
diff --git a/libavcodec/v210_template.c b/libavcodec/v210_template.c
index 9e1d9f9cd3..9f40bfe97c 100644
--- a/libavcodec/v210_template.c
+++ b/libavcodec/v210_template.c
@@ -22,16 +22,6 @@
#include "bytestream.h"
#include "internal.h"
-#define CLIP(v, depth) av_clip(v, 1<<(depth-8), ((1<<depth)-(1<<(depth-8))-1))
-#define WRITE_PIXELS(a, b, c, depth) \
- do { \
- val = CLIP(*a++, depth) << (10-depth); \
- val |= (CLIP(*b++, depth) << (20-depth)) | \
- (CLIP(*c++, depth) << (30-depth)); \
- AV_WL32(dst, val); \
- dst += 4; \
- } while (0)
-
static void RENAME(v210_enc)(AVCodecContext *avctx,
uint8_t *dst, const AVFrame *pic)
{
diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c
index 9ac923571c..f63093fdbf 100644
--- a/libavcodec/v210enc.c
+++ b/libavcodec/v210enc.c
@@ -25,8 +25,8 @@
#include "bytestream.h"
#include "codec_internal.h"
#include "encode.h"
-#include "internal.h"
#include "v210enc.h"
+#include "v210enc_init.h"
#define TYPE uint8_t
#define DEPTH 8
@@ -48,52 +48,6 @@
#undef BYTES_PER_PIXEL
#undef TYPE
-static void v210_planar_pack_8_c(const uint8_t *y, const uint8_t *u,
- const uint8_t *v, uint8_t *dst,
- ptrdiff_t width)
-{
- uint32_t val;
- int i;
-
- /* unroll this to match the assembly */
- for (i = 0; i < width - 11; i += 12) {
- WRITE_PIXELS(u, y, v, 8);
- WRITE_PIXELS(y, u, y, 8);
- WRITE_PIXELS(v, y, u, 8);
- WRITE_PIXELS(y, v, y, 8);
- WRITE_PIXELS(u, y, v, 8);
- WRITE_PIXELS(y, u, y, 8);
- WRITE_PIXELS(v, y, u, 8);
- WRITE_PIXELS(y, v, y, 8);
- }
-}
-
-static void v210_planar_pack_10_c(const uint16_t *y, const uint16_t *u,
- const uint16_t *v, uint8_t *dst,
- ptrdiff_t width)
-{
- uint32_t val;
- int i;
-
- for (i = 0; i < width - 5; i += 6) {
- WRITE_PIXELS(u, y, v, 10);
- WRITE_PIXELS(y, u, y, 10);
- WRITE_PIXELS(v, y, u, 10);
- WRITE_PIXELS(y, v, y, 10);
- }
-}
-
-av_cold void ff_v210enc_init(V210EncContext *s)
-{
- s->pack_line_8 = v210_planar_pack_8_c;
- s->pack_line_10 = v210_planar_pack_10_c;
- s->sample_factor_8 = 2;
- s->sample_factor_10 = 1;
-
- if (ARCH_X86)
- ff_v210enc_init_x86(s);
-}
-
static av_cold int encode_init(AVCodecContext *avctx)
{
V210EncContext *s = avctx->priv_data;
diff --git a/libavcodec/v210enc.h b/libavcodec/v210enc.h
index 51305c1a20..b74fd33db5 100644
--- a/libavcodec/v210enc.h
+++ b/libavcodec/v210enc.h
@@ -32,8 +32,6 @@ typedef struct V210EncContext {
int sample_factor_10;
} V210EncContext;
-void ff_v210enc_init(V210EncContext *s);
-
void ff_v210enc_init_x86(V210EncContext *s);
#endif /* AVCODEC_V210ENC_H */
diff --git a/libavcodec/v210enc_init.h b/libavcodec/v210enc_init.h
new file mode 100644
index 0000000000..6d81cac319
--- /dev/null
+++ b/libavcodec/v210enc_init.h
@@ -0,0 +1,90 @@
+/*
+ * V210 encoder DSP init
+ *
+ * Copyright (C) 2009 Michael Niedermayer <michaelni@gmx.at>
+ * Copyright (c) 2009 Baptiste Coudurier <baptiste dot coudurier at gmail dot com>
+ *
+ * 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
+ */
+
+#ifndef AVCODEC_V210ENC_INIT_H
+#define AVCODEC_V210ENC_INIT_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include "config.h"
+#include "libavutil/attributes.h"
+#include "libavutil/common.h"
+#include "libavutil/intreadwrite.h"
+#include "v210enc.h"
+
+#define CLIP(v, depth) av_clip(v, 1<<(depth-8), ((1<<depth)-(1<<(depth-8))-1))
+#define WRITE_PIXELS(a, b, c, depth) \
+ do { \
+ val = CLIP(*a++, depth) << (10-depth); \
+ val |= (CLIP(*b++, depth) << (20-depth)) | \
+ (CLIP(*c++, depth) << (30-depth)); \
+ AV_WL32(dst, val); \
+ dst += 4; \
+ } while (0)
+
+static void v210_planar_pack_8_c(const uint8_t *y, const uint8_t *u,
+ const uint8_t *v, uint8_t *dst,
+ ptrdiff_t width)
+{
+ uint32_t val;
+
+ /* unroll this to match the assembly */
+ for (int i = 0; i < width - 11; i += 12) {
+ WRITE_PIXELS(u, y, v, 8);
+ WRITE_PIXELS(y, u, y, 8);
+ WRITE_PIXELS(v, y, u, 8);
+ WRITE_PIXELS(y, v, y, 8);
+ WRITE_PIXELS(u, y, v, 8);
+ WRITE_PIXELS(y, u, y, 8);
+ WRITE_PIXELS(v, y, u, 8);
+ WRITE_PIXELS(y, v, y, 8);
+ }
+}
+
+static void v210_planar_pack_10_c(const uint16_t *y, const uint16_t *u,
+ const uint16_t *v, uint8_t *dst,
+ ptrdiff_t width)
+{
+ uint32_t val;
+
+ for (int i = 0; i < width - 5; i += 6) {
+ WRITE_PIXELS(u, y, v, 10);
+ WRITE_PIXELS(y, u, y, 10);
+ WRITE_PIXELS(v, y, u, 10);
+ WRITE_PIXELS(y, v, y, 10);
+ }
+}
+
+static av_cold av_unused void ff_v210enc_init(V210EncContext *s)
+{
+ s->pack_line_8 = v210_planar_pack_8_c;
+ s->pack_line_10 = v210_planar_pack_10_c;
+ s->sample_factor_8 = 2;
+ s->sample_factor_10 = 1;
+
+ if (ARCH_X86)
+ ff_v210enc_init_x86(s);
+}
+
+#endif /* AVCODEC_V210ENC_INIT_H */
diff --git a/tests/checkasm/v210enc.c b/tests/checkasm/v210enc.c
index c3d5cc5145..9942e08137 100644
--- a/tests/checkasm/v210enc.c
+++ b/tests/checkasm/v210enc.c
@@ -20,7 +20,7 @@
#include <string.h>
#include "checkasm.h"
-#include "libavcodec/v210enc.h"
+#include "libavcodec/v210enc_init.h"
#include "libavutil/common.h"
#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [FFmpeg-devel] [PATCH 01/10] avfilter/af_afir: Only keep DSP stuff in header
2022-05-03 6:18 [FFmpeg-devel] [PATCH 01/10] avfilter/af_afir: Only keep DSP stuff in header Andreas Rheinhardt
` (8 preceding siblings ...)
2022-05-03 6:37 ` [FFmpeg-devel] [PATCH 10/10] avcodec/v210_enc: Move ff_v210enc_init " Andreas Rheinhardt
@ 2022-05-05 1:55 ` Andreas Rheinhardt
9 siblings, 0 replies; 21+ messages in thread
From: Andreas Rheinhardt @ 2022-05-05 1:55 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Andreas Rheinhardt:
> Only the AudioFIRDSPContext and the functions for its initialization
> are needed outside of lavfi/af_afir.c.
> Also rename the header to af_afirdsp.h to reflect the change.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavfilter/af_afir.c | 71 +++++++++++++++++++++-
> libavfilter/af_afir.h | 108 ---------------------------------
> libavfilter/af_afirdsp.h | 34 +++++++++++
> libavfilter/x86/af_afir_init.c | 2 +-
> tests/checkasm/af_afir.c | 2 +-
> 5 files changed, 106 insertions(+), 111 deletions(-)
> delete mode 100644 libavfilter/af_afir.h
> create mode 100644 libavfilter/af_afirdsp.h
>
> diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c
> index 72e77eda19..d7ae468428 100644
> --- a/libavfilter/af_afir.c
> +++ b/libavfilter/af_afir.c
> @@ -30,8 +30,11 @@
> #include "libavutil/channel_layout.h"
> #include "libavutil/common.h"
> #include "libavutil/float_dsp.h"
> +#include "libavutil/frame.h"
> #include "libavutil/intreadwrite.h"
> +#include "libavutil/log.h"
> #include "libavutil/opt.h"
> +#include "libavutil/rational.h"
> #include "libavutil/xga_font_data.h"
>
> #include "audio.h"
> @@ -39,7 +42,73 @@
> #include "filters.h"
> #include "formats.h"
> #include "internal.h"
> -#include "af_afir.h"
> +#include "af_afirdsp.h"
> +
> +typedef struct AudioFIRSegment {
> + int nb_partitions;
> + int part_size;
> + int block_size;
> + int fft_length;
> + int coeff_size;
> + int input_size;
> + int input_offset;
> +
> + int *output_offset;
> + int *part_index;
> +
> + AVFrame *sumin;
> + AVFrame *sumout;
> + AVFrame *blockin;
> + AVFrame *blockout;
> + AVFrame *buffer;
> + AVFrame *coeff;
> + AVFrame *input;
> + AVFrame *output;
> +
> + AVTXContext **tx, **itx;
> + av_tx_fn tx_fn, itx_fn;
> +} AudioFIRSegment;
> +
> +typedef struct AudioFIRContext {
> + const AVClass *class;
> +
> + float wet_gain;
> + float dry_gain;
> + float length;
> + int gtype;
> + float ir_gain;
> + int ir_format;
> + float max_ir_len;
> + int response;
> + int w, h;
> + AVRational frame_rate;
> + int ir_channel;
> + int minp;
> + int maxp;
> + int nb_irs;
> + int selir;
> +
> + float gain;
> +
> + int eof_coeffs[32];
> + int have_coeffs;
> + int nb_taps;
> + int nb_channels;
> + int nb_coef_channels;
> + int one2many;
> +
> + AudioFIRSegment seg[1024];
> + int nb_segments;
> +
> + AVFrame *in;
> + AVFrame *ir[32];
> + AVFrame *video;
> + int min_part_size;
> + int64_t pts;
> +
> + AudioFIRDSPContext afirdsp;
> + AVFloatDSPContext *fdsp;
> +} AudioFIRContext;
>
> static void fcmul_add_c(float *sum, const float *t, const float *c, ptrdiff_t len)
> {
> diff --git a/libavfilter/af_afir.h b/libavfilter/af_afir.h
> deleted file mode 100644
> index cf00dbfc66..0000000000
> --- a/libavfilter/af_afir.h
> +++ /dev/null
> @@ -1,108 +0,0 @@
> -/*
> - * Copyright (c) 2017 Paul B Mahol
> - *
> - * 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
> - */
> -
> -#ifndef AVFILTER_AFIR_H
> -#define AVFILTER_AFIR_H
> -
> -#include <stddef.h>
> -#include <stdint.h>
> -
> -#include "libavutil/tx.h"
> -#include "libavutil/float_dsp.h"
> -#include "libavutil/frame.h"
> -#include "libavutil/log.h"
> -#include "libavutil/rational.h"
> -
> -typedef struct AudioFIRSegment {
> - int nb_partitions;
> - int part_size;
> - int block_size;
> - int fft_length;
> - int coeff_size;
> - int input_size;
> - int input_offset;
> -
> - int *output_offset;
> - int *part_index;
> -
> - AVFrame *sumin;
> - AVFrame *sumout;
> - AVFrame *blockin;
> - AVFrame *blockout;
> - AVFrame *buffer;
> - AVFrame *coeff;
> - AVFrame *input;
> - AVFrame *output;
> -
> - AVTXContext **tx, **itx;
> - av_tx_fn tx_fn, itx_fn;
> -} AudioFIRSegment;
> -
> -typedef struct AudioFIRDSPContext {
> - void (*fcmul_add)(float *sum, const float *t, const float *c,
> - ptrdiff_t len);
> -} AudioFIRDSPContext;
> -
> -typedef struct AudioFIRContext {
> - const AVClass *class;
> -
> - float wet_gain;
> - float dry_gain;
> - float length;
> - int gtype;
> - float ir_gain;
> - int ir_format;
> - float max_ir_len;
> - int response;
> - int w, h;
> - AVRational frame_rate;
> - int ir_channel;
> - int minp;
> - int maxp;
> - int nb_irs;
> - int selir;
> -
> - float gain;
> -
> - int eof_coeffs[32];
> - int have_coeffs;
> - int nb_taps;
> - int nb_channels;
> - int nb_coef_channels;
> - int one2many;
> -
> - AudioFIRSegment seg[1024];
> - int nb_segments;
> -
> - AVFrame *in;
> - AVFrame *ir[32];
> - AVFrame *video;
> - int min_part_size;
> - int64_t pts;
> -
> - AudioFIRDSPContext afirdsp;
> - AVFloatDSPContext *fdsp;
> -
> -} AudioFIRContext;
> -
> -void ff_afir_init(AudioFIRDSPContext *s);
> -void ff_afir_init_x86(AudioFIRDSPContext *s);
> -
> -#endif /* AVFILTER_AFIR_H */
> diff --git a/libavfilter/af_afirdsp.h b/libavfilter/af_afirdsp.h
> new file mode 100644
> index 0000000000..f72ab7cd02
> --- /dev/null
> +++ b/libavfilter/af_afirdsp.h
> @@ -0,0 +1,34 @@
> +/*
> + * Copyright (c) 2017 Paul B Mahol
> + *
> + * 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
> + */
> +
> +#ifndef AVFILTER_AFIRDSP_H
> +#define AVFILTER_AFIRDSP_H
> +
> +#include <stddef.h>
> +
> +typedef struct AudioFIRDSPContext {
> + void (*fcmul_add)(float *sum, const float *t, const float *c,
> + ptrdiff_t len);
> +} AudioFIRDSPContext;
> +
> +void ff_afir_init(AudioFIRDSPContext *s);
> +void ff_afir_init_x86(AudioFIRDSPContext *s);
> +
> +#endif /* AVFILTER_AFIRDSP_H */
> diff --git a/libavfilter/x86/af_afir_init.c b/libavfilter/x86/af_afir_init.c
> index c37212c381..e53817b9c0 100644
> --- a/libavfilter/x86/af_afir_init.c
> +++ b/libavfilter/x86/af_afir_init.c
> @@ -20,7 +20,7 @@
> #include "libavutil/attributes.h"
> #include "libavutil/cpu.h"
> #include "libavutil/x86/cpu.h"
> -#include "libavfilter/af_afir.h"
> +#include "libavfilter/af_afirdsp.h"
>
> void ff_fcmul_add_sse3(float *sum, const float *t, const float *c,
> ptrdiff_t len);
> diff --git a/tests/checkasm/af_afir.c b/tests/checkasm/af_afir.c
> index b8a845db82..08c55dacfc 100644
> --- a/tests/checkasm/af_afir.c
> +++ b/tests/checkasm/af_afir.c
> @@ -21,7 +21,7 @@
> #include <float.h>
> #include <stdint.h>
>
> -#include "libavfilter/af_afir.h"
> +#include "libavfilter/af_afirdsp.h"
> #include "libavutil/internal.h"
> #include "libavutil/mem_internal.h"
> #include "checkasm.h"
Will apply this patchset tonight unless there are objections.
- Andreas
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 21+ messages in thread