1+ From 2cafb7afd5117fa168c254f337b35336bd938600 Mon Sep 17 00:00:00 2001
2+ From: Matthias Reichl <hias@horus.com>
3+ Date: Sat, 28 Mar 2026 12:25:00 +0100
4+ Subject: [PATCH] add sourcepluin-libpostproc from michaelni
5+
6+ Rebased version of
7+ https://github.com/michaelni/FFmpeg/tree/sourceplugin-libpostproc-8.0
8+
9+ Signed-off-by: Matthias Reichl <hias@horus.com>
10+ ---
11+ LICENSE.md | 2 +
12+ MAINTAINERS | 2 +
13+ Makefile | 2 +
14+ configure | 13 +-
15+ doc/filters.texi | 175 ++
16+ fftools/ffprobe.c | 3 +
17+ fftools/opt_common.c | 3 +
18+ libavfilter/Makefile | 1 +
19+ libavfilter/allfilters.c | 1 +
20+ libavfilter/vf_pp.c | 191 ++
21+ libavutil/avutil.h | 1 +
22+ libpostproc/Makefile | 23 +
23+ libpostproc/libpostproc.v | 7 +
24+ libpostproc/postprocess.c | 992 ++++++
25+ libpostproc/postprocess.h | 109 +
26+ libpostproc/postprocess_altivec_template.c | 1214 ++++++++
27+ libpostproc/postprocess_internal.h | 185 ++
28+ libpostproc/postprocess_template.c | 3293 ++++++++++++++++++++
29+ libpostproc/postprocres.rc | 55 +
30+ libpostproc/tests/.gitignore | 3 +
31+ libpostproc/tests/blocktest.c | 113 +
32+ libpostproc/tests/stripetest.c | 115 +
33+ libpostproc/tests/temptest.c | 106 +
34+ libpostproc/tests/test_utils.c | 38 +
35+ libpostproc/tests/test_utils.h | 27 +
36+ libpostproc/version.c | 45 +
37+ libpostproc/version.h | 48 +
38+ libpostproc/version_major.h | 33 +
39+ tests/Makefile | 1 +
40+ tests/fate/filter-video.mak | 16 +
41+ tests/fate/libpostproc.mak | 14 +
42+ tests/ref/fate/blocktest | 1800 +++++++++++
43+ tests/ref/fate/filter-pp | 10 +
44+ tests/ref/fate/filter-pp1 | 1 +
45+ tests/ref/fate/filter-pp2 | 1 +
46+ tests/ref/fate/filter-pp3 | 1 +
47+ tests/ref/fate/filter-pp4 | 1 +
48+ tests/ref/fate/filter-pp5 | 1 +
49+ tests/ref/fate/filter-pp6 | 1 +
50+ tests/ref/fate/filter-qp | 1 +
51+ tests/ref/fate/stripetest | 360 +++
52+ tests/ref/fate/temptest | 336 ++
53+ tools/gen-rc | 1 +
54+ 43 files changed, 9344 insertions(+), 1 deletion(-)
55+ create mode 100644 libavfilter/vf_pp.c
56+ create mode 100644 libpostproc/Makefile
57+ create mode 100644 libpostproc/libpostproc.v
58+ create mode 100644 libpostproc/postprocess.c
59+ create mode 100644 libpostproc/postprocess.h
60+ create mode 100644 libpostproc/postprocess_altivec_template.c
61+ create mode 100644 libpostproc/postprocess_internal.h
62+ create mode 100644 libpostproc/postprocess_template.c
63+ create mode 100644 libpostproc/postprocres.rc
64+ create mode 100644 libpostproc/tests/.gitignore
65+ create mode 100644 libpostproc/tests/blocktest.c
66+ create mode 100644 libpostproc/tests/stripetest.c
67+ create mode 100644 libpostproc/tests/temptest.c
68+ create mode 100644 libpostproc/tests/test_utils.c
69+ create mode 100644 libpostproc/tests/test_utils.h
70+ create mode 100644 libpostproc/version.c
71+ create mode 100644 libpostproc/version.h
72+ create mode 100644 libpostproc/version_major.h
73+ create mode 100644 tests/fate/libpostproc.mak
74+ create mode 100644 tests/ref/fate/blocktest
75+ create mode 100644 tests/ref/fate/filter-pp
76+ create mode 100644 tests/ref/fate/filter-pp1
77+ create mode 100644 tests/ref/fate/filter-pp2
78+ create mode 100644 tests/ref/fate/filter-pp3
79+ create mode 100644 tests/ref/fate/filter-pp4
80+ create mode 100644 tests/ref/fate/filter-pp5
81+ create mode 100644 tests/ref/fate/filter-pp6
82+ create mode 100644 tests/ref/fate/filter-qp
83+ create mode 100644 tests/ref/fate/stripetest
84+ create mode 100644 tests/ref/fate/temptest
85+
186diff --git a/LICENSE.md b/LICENSE.md
287index 371b0913ce7c..613070e1b631 100644
388--- a/LICENSE.md
@@ -19,10 +104,10 @@ index 371b0913ce7c..613070e1b631 100644
19104 - `vf_pullup.c`
20105 - `vf_repeatfields.c`
21106diff --git a/MAINTAINERS b/MAINTAINERS
22- index d1d87752b919..c410293c323c 100644
107+ index e47f6c98e9b8..708872f8ef9e 100644
23108--- a/MAINTAINERS
24109+++ b/MAINTAINERS
25- @@ -135 ,6 +135 ,8 @@ Generic Parts:
110+ @@ -138 ,6 +138 ,8 @@ Generic Parts:
26111 ratecontrol.c [2] Michael Niedermayer
27112 simple IDCT:
28113 simple_idct.c, simple_idct.h [2] Michael Niedermayer
@@ -32,18 +117,18 @@ index d1d87752b919..c410293c323c 100644
32117 tableprint.c, tableprint.h Reimar Doeffinger
33118 fixed point FFT:
34119diff --git a/Makefile b/Makefile
35- index 877b0071f6cc..d7b5a360a4d9 100644
120+ index f296e87ed4fc..c45c886a122b 100644
36121--- a/Makefile
37122+++ b/Makefile
38- @@ -25 ,6 +25 ,7 @@ ALLFFLIBS = \
123+ @@ -27 ,6 +27 ,7 @@ ALLFFLIBS = \
39124 avfilter \
40125 avformat \
41126 avutil \
42127+ postproc \
43128 swscale \
44129 swresample \
45130
46- @@ -33 ,6 +34 ,7 @@ FFLIBS-$(CONFIG_AVDEVICE) += avdevice
131+ @@ -35 ,6 +36 ,7 @@ FFLIBS-$(CONFIG_AVDEVICE) += avdevice
47132 FFLIBS-$(CONFIG_AVFILTER) += avfilter
48133 FFLIBS-$(CONFIG_AVFORMAT) += avformat
49134 FFLIBS-$(CONFIG_AVCODEC) += avcodec
@@ -52,43 +137,43 @@ index 877b0071f6cc..d7b5a360a4d9 100644
52137 FFLIBS-$(CONFIG_SWSCALE) += swscale
53138
54139diff --git a/configure b/configure
55- index ae74efc09f41..625a09ad385b 100755
140+ index 17596942749a..9d8db691a460 100755
56141--- a/configure
57142+++ b/configure
58- @@ -130 ,6 +130 ,7 @@ Component options:
143+ @@ -131 ,6 +131 ,7 @@ Component options:
59144 --disable-avformat disable libavformat build
60145 --disable-swresample disable libswresample build
61146 --disable-swscale disable libswscale build
62147+ --disable-postproc disable libpostproc build
63148 --disable-avfilter disable libavfilter build
64149 --disable-pthreads disable pthreads [autodetect]
65150 --disable-w32threads disable Win32 threads [autodetect]
66- @@ -2072 ,6 +2073 ,7 @@ LIBRARY_LIST="
151+ @@ -2191 ,6 +2192 ,7 @@ LIBRARY_LIST="
67152 avdevice
68153 avfilter
69154 swscale
70155+ postproc
71156 avformat
72157 avcodec
73158 swresample
74- @@ -3969 ,6 +3971 ,7 @@ pan_filter_deps="swresample"
159+ @@ -4183 ,6 +4185 ,7 @@ pan_filter_deps="swresample"
75160 perspective_filter_deps="gpl"
76161 phase_filter_deps="gpl"
77162 pp7_filter_deps="gpl"
78163+ pp_filter_deps="gpl postproc"
79164 prewitt_opencl_filter_deps="opencl"
80165 procamp_vaapi_filter_deps="vaapi"
81166 program_opencl_filter_deps="opencl"
82- @@ -4085 ,6 +4088 ,8 @@ avfilter_suggest="libm stdatomic spirv_compiler "
167+ @@ -4301 ,6 +4304 ,8 @@ avfilter_suggest="libm stdatomic zlib spirv_library "
83168 avformat_deps="avcodec avutil"
84169 avformat_suggest="libm network zlib stdatomic"
85- avutil_suggest="clock_gettime ffnvcodec gcrypt libm libdrm libmfx opencl openssl user32 vaapi vulkan videotoolbox corefoundation corevideo coremedia bcrypt stdatomic"
170+ avutil_suggest="clock_gettime ffnvcodec gcrypt libm zlib libdrm libmfx opencl openssl user32 vaapi vulkan videotoolbox corefoundation corevideo coremedia bcrypt stdatomic"
86171+ postproc_deps="avutil gpl"
87172+ postproc_suggest="libm stdatomic"
88173 swresample_deps="avutil"
89174 swresample_suggest="libm libsoxr stdatomic"
90175 swscale_deps="avutil"
91- @@ -7535 ,7 +7540 ,7 @@ void (^block)(void);
176+ @@ -7914 ,7 +7919 ,7 @@ void (^block)(void);
92177 EOF
93178
94179 # add some linker flags
@@ -97,15 +182,15 @@ index ae74efc09f41..625a09ad385b 100755
97182 enabled rpath && add_ldexeflags -Wl,-rpath,$libdir && add_ldsoflags -Wl,-rpath,$libdir
98183 test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic
99184
100- @@ -7900 ,6 +7905 ,7 @@ enabled fsync_filter && prepend avfilter_deps "avformat"
185+ @@ -8300 ,6 +8305 ,7 @@ enabled fsync_filter && prepend avfilter_deps "avformat"
101186 enabled mcdeint_filter && prepend avfilter_deps "avcodec"
102187 enabled movie_filter && prepend avfilter_deps "avformat avcodec"
103188 enabled pan_filter && prepend avfilter_deps "swresample"
104189+ enabled pp_filter && prepend avfilter_deps "postproc"
105190 enabled qrencode_filter && prepend avfilter_deps "swscale"
106191 enabled qrencodesrc_filter && prepend avfilter_deps "swscale"
107192 enabled removelogo_filter && prepend avfilter_deps "avformat avcodec swscale"
108- @@ -7951 ,6 +7957 ,9 @@ expand_deps(){
193+ @@ -8351 ,6 +8357 ,9 @@ expand_deps(){
109194 reorder_by ${1}_deps LIBRARY_LIST # linking order is expected later
110195 }
111196
@@ -115,15 +200,15 @@ index ae74efc09f41..625a09ad385b 100755
115200 map 'expand_deps $v' $LIBRARY_LIST
116201
117202 if test "$quiet" != "yes"; then
118- @@ -8041 ,6 +8050 ,7 @@ echo "optimize for size ${small-no}"
203+ @@ -8443 ,6 +8452 ,7 @@ echo "optimize for size ${small-no}"
119204 echo "optimizations ${optimizations-no}"
120205 echo "static ${static-no}"
121206 echo "shared ${shared-no}"
122207+ echo "postprocessing support ${postproc-no}"
123208 echo "network support ${network-no}"
124209 echo "threading support ${thread_type-no}"
125210 echo "safe bitstream reader ${safe_bitstream_reader-no}"
126- @@ -8417 ,6 +8427 ,7 @@ extralibs_avcodec="$avcodec_extralibs"
211+ @@ -8828 ,6 +8838 ,7 @@ extralibs_avcodec="$avcodec_extralibs"
127212 extralibs_avformat="$avformat_extralibs"
128213 extralibs_avdevice="$avdevice_extralibs"
129214 extralibs_avfilter="$avfilter_extralibs"
@@ -132,10 +217,10 @@ index ae74efc09f41..625a09ad385b 100755
132217 extralibs_swresample="$swresample_extralibs"
133218 EOF
134219diff --git a/doc/filters.texi b/doc/filters.texi
135- index 6d2df075083c..47ca7000ca37 100644
220+ index 5d222c6b96fd..5a8bf1e18f01 100644
136221--- a/doc/filters.texi
137222+++ b/doc/filters.texi
138- @@ -19409 ,6 +19409 ,181 @@ Set window Y position, relative offset on Y axis.
223+ @@ -19976 ,6 +19976 ,181 @@ Set window Y position, relative offset on Y axis.
139224
140225 This filter supports same @ref{commands} as options.
141226
@@ -318,10 +403,10 @@ index 6d2df075083c..47ca7000ca37 100644
318403 Apply Postprocessing filter 7. It is variant of the @ref{spp} filter,
319404 similar to spp = 6 with 7 point DCT, where only the center sample is
320405diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
321- index 80ce38e73bd2..e6f8b16e1eaa 100644
406+ index 3c29fc255791..731cfd362050 100644
322407--- a/fftools/ffprobe.c
323408+++ b/fftools/ffprobe.c
324- @@ -62 ,6 +62 ,8 @@
409+ @@ -63 ,6 +63 ,8 @@
325410 #include "libswscale/version.h"
326411 #include "libswresample/swresample.h"
327412 #include "libswresample/version.h"
@@ -330,7 +415,7 @@ index 80ce38e73bd2..e6f8b16e1eaa 100644
330415 #include "libavfilter/version.h"
331416 #include "textformat/avtextformat.h"
332417 #include "cmdutils.h"
333- @@ -2571 ,6 +2573 ,7 @@ static void ffprobe_show_library_versions(AVTextFormatContext *tfc)
418+ @@ -2697 ,6 +2699 ,7 @@ static void ffprobe_show_library_versions(AVTextFormatContext *tfc)
334419 SHOW_LIB_VERSION(avfilter, AVFILTER);
335420 SHOW_LIB_VERSION(swscale, SWSCALE);
336421 SHOW_LIB_VERSION(swresample, SWRESAMPLE);
@@ -339,10 +424,10 @@ index 80ce38e73bd2..e6f8b16e1eaa 100644
339424 }
340425
341426diff --git a/fftools/opt_common.c b/fftools/opt_common.c
342- index c2f6b9de2a75..2ac3fd4fb364 100644
427+ index 2c1f956551db..57de4b7b89fd 100644
343428--- a/fftools/opt_common.c
344429+++ b/fftools/opt_common.c
345- @@ -60 ,6 +60 ,8 @@
430+ @@ -61 ,6 +61 ,8 @@
346431 #include "libswresample/swresample.h"
347432 #include "libswresample/version.h"
348433
@@ -351,7 +436,7 @@ index c2f6b9de2a75..2ac3fd4fb364 100644
351436
352437 enum show_muxdemuxers {
353438 SHOW_DEFAULT,
354- @@ -189 ,6 +191 ,7 @@ static void print_all_libs_info(int flags, int level)
439+ @@ -190 ,6 +192 ,7 @@ static void print_all_libs_info(int flags, int level)
355440 PRINT_LIB_INFO(avfilter, AVFILTER, flags, level);
356441 PRINT_LIB_INFO(swscale, SWSCALE, flags, level);
357442 PRINT_LIB_INFO(swresample, SWRESAMPLE, flags, level);
@@ -360,29 +445,29 @@ index c2f6b9de2a75..2ac3fd4fb364 100644
360445
361446 static void print_program_info(int flags, int level)
362447diff --git a/libavfilter/Makefile b/libavfilter/Makefile
363- index 0effe4127ffd..7c0d879ec9c4 100644
448+ index a530cfae29be..de6f6aaea1b7 100644
364449--- a/libavfilter/Makefile
365450+++ b/libavfilter/Makefile
366- @@ -431 ,6 +431 ,7 @@ OBJS-$(CONFIG_PHOTOSENSITIVITY_FILTER) += vf_photosensitivity.o
451+ @@ -440 ,6 +440 ,7 @@ OBJS-$(CONFIG_PHOTOSENSITIVITY_FILTER) += vf_photosensitivity.o
367452 OBJS-$(CONFIG_PIXDESCTEST_FILTER) += vf_pixdesctest.o
368453 OBJS-$(CONFIG_PIXELIZE_FILTER) += vf_pixelize.o
369454 OBJS-$(CONFIG_PIXSCOPE_FILTER) += vf_datascope.o
370455+ OBJS-$(CONFIG_PP_FILTER) += vf_pp.o qp_table.o
371456 OBJS-$(CONFIG_PP7_FILTER) += vf_pp7.o qp_table.o
457+ OBJS-$(CONFIG_PREMULTIPLY_DYNAMIC_FILTER) += vf_premultiply.o framesync.o
372458 OBJS-$(CONFIG_PREMULTIPLY_FILTER) += vf_premultiply.o framesync.o
373- OBJS-$(CONFIG_PREWITT_FILTER) += vf_convolution.o
374459diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
375- index 5ea33cdf01b9..740d9ab265cc 100644
460+ index e26859e15914..154ea71d97c0 100644
376461--- a/libavfilter/allfilters.c
377462+++ b/libavfilter/allfilters.c
378- @@ -404 ,6 +404 ,7 @@ extern const FFFilter ff_vf_photosensitivity;
463+ @@ -412 ,6 +412 ,7 @@ extern const FFFilter ff_vf_photosensitivity;
379464 extern const FFFilter ff_vf_pixdesctest;
380465 extern const FFFilter ff_vf_pixelize;
381466 extern const FFFilter ff_vf_pixscope;
382467+ extern const FFFilter ff_vf_pp;
383468 extern const FFFilter ff_vf_pp7;
384469 extern const FFFilter ff_vf_premultiply;
385- extern const FFFilter ff_vf_prewitt ;
470+ extern const FFFilter ff_vf_premultiply_dynamic ;
386471diff --git a/libavfilter/vf_pp.c b/libavfilter/vf_pp.c
387472new file mode 100644
388473index 000000000000..9e9903eb9746
@@ -7101,10 +7186,10 @@ index 000000000000..b9946912db38
71017186+
71027187+ #endif /* POSTPROC_VERSION_MAJOR_H */
71037188diff --git a/tests/Makefile b/tests/Makefile
7104- index 505d7f9c6d6d..c2043310207f 100644
7189+ index 4b3fa6a54ab7..c81a0e7df5bf 100644
71057190--- a/tests/Makefile
71067191+++ b/tests/Makefile
7107- @@ -208 ,6 +208 ,7 @@ include $(SRC_PATH)/tests/fate/libavformat.mak
7192+ @@ -214 ,6 +214 ,7 @@ include $(SRC_PATH)/tests/fate/libavformat.mak
71087193 include $(SRC_PATH)/tests/fate/libavutil.mak
71097194 include $(SRC_PATH)/tests/fate/libswresample.mak
71107195 include $(SRC_PATH)/tests/fate/libswscale.mak
@@ -7113,10 +7198,10 @@ index 505d7f9c6d6d..c2043310207f 100644
71137198 include $(SRC_PATH)/tests/fate/lossless-video.mak
71147199 include $(SRC_PATH)/tests/fate/matroska.mak
71157200diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
7116- index df8a9327506c..2ae7aed88dab 100644
7201+ index 07b8632c6f0d..4436f14a4f64 100644
71177202--- a/tests/fate/filter-video.mak
71187203+++ b/tests/fate/filter-video.mak
7119- @@ -533 ,6 +533 ,19 @@ fate-filter-idet: CMD = framecrc -flags bitexact -idct simple -i $(SRC) -vf idet
7204+ @@ -555 ,6 +555 ,19 @@ fate-filter-idet: CMD = framecrc -flags bitexact -idct simple -i $(SRC) -vf idet
71207205 FATE_FILTER_VSYNTH_VIDEO_FILTER-$(CONFIG_PAD_FILTER) += fate-filter-pad
71217206 fate-filter-pad: CMD = video_filter "pad=iw*1.5:ih*1.5:iw*0.3:ih*0.2"
71227207
@@ -7136,7 +7221,7 @@ index df8a9327506c..2ae7aed88dab 100644
71367221 FATE_FILTER_VSYNTH1_MPEG4_QPRD-$(call FILTERDEMDEC, PP7, AVI, MPEG4) += pp7
71377222 fate-filter-pp7: CMD = framecrc -flags bitexact -export_side_data venc_params -idct simple -i $(TARGET_PATH)/tests/data/fate/vsynth1-mpeg4-qprd.avi -frames:v 5 -flags +bitexact -vf "pp7"
71387223
7139- @@ -550 ,6 +563 ,9 @@ FATE_FILTER_VSYNTH-yes += $(FATE_FILTER_VSYNTH1_MPEG4_QPRD)
7224+ @@ -572 ,6 +585 ,9 @@ FATE_FILTER_VSYNTH-yes += $(FATE_FILTER_VSYNTH1_MPEG4_QPRD)
71407225 $(FATE_FILTER_VSYNTH1_MPEG4_QPRD): fate-vsynth1-mpeg4-qprd
71417226 fate-vsynth1-mpeg4-qprd: KEEP_FILES ?= 1
71427227
0 commit comments