Commit Graph

48 Commits

Author SHA1 Message Date
Andreas Rheinhardt
40e6575aa3 all: Replace if (ARCH_FOO) checks by #if ARCH_FOO
This is more spec-compliant because it does not rely
on dead-code elimination by the compiler. Especially
MSVC has problems with this, as can be seen in
https://ffmpeg.org/pipermail/ffmpeg-devel/2022-May/296373.html
or
https://ffmpeg.org/pipermail/ffmpeg-devel/2022-May/297022.html

This commit does not eliminate every instance where we rely
on dead code elimination: It only tackles branching to
the initialization of arch-specific dsp code, not e.g. all
uses of CONFIG_ and HAVE_ checks. But maybe it is already
enough to compile FFmpeg with MSVC with whole-programm-optimizations
enabled (if one does not disable too many components).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-06-15 04:56:37 +02:00
Andreas Rheinhardt
31a373ce71 avfilter: Reindentation after query_formats changes
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-05 18:58:29 +02:00
Andreas Rheinhardt
fb1a3d05a9 avfilter/vf_spp: Use formats list instead of query function
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-05 18:58:25 +02:00
Andreas Rheinhardt
b4f5201967 avfilter: Replace query_formats callback with union of list and callback
If one looks at the many query_formats callbacks in existence,
one will immediately recognize that there is one type of default
callback for video and a slightly different default callback for
audio: It is "return ff_set_common_formats_from_list(ctx, pix_fmts);"
for video with a filter-specific pix_fmts list. For audio, it is
the same with a filter-specific sample_fmts list together with
ff_set_common_all_samplerates() and ff_set_common_all_channel_counts().

This commit allows to remove the boilerplate query_formats callbacks
by replacing said callback with a union consisting the old callback
and pointers for pixel and sample format arrays. For the not uncommon
case in which these lists only contain a single entry (besides the
sentinel) enum AVPixelFormat and enum AVSampleFormat fields are also
added to the union to store them directly in the AVFilter,
thereby avoiding a relocation.

The state of said union will be contained in a new, dedicated AVFilter
field (the nb_inputs and nb_outputs fields have been shrunk to uint8_t
in order to create a hole for this new field; this is no problem, as
the maximum of all the nb_inputs is four; for nb_outputs it is only
two).

The state's default value coincides with the earlier default of
query_formats being unset, namely that the filter accepts all formats
(and also sample rates and channel counts/layouts for audio)
provided that these properties agree coincide for all inputs and
outputs.

By using different union members for audio and video filters
the type-unsafety of using the same functions for audio and video
lists will furthermore be more confined to formats.c than before.

When the new fields are used, they will also avoid allocations:
Currently something nearly equivalent to ff_default_query_formats()
is called after every successful call to a query_formats callback;
yet in the common case that the newly allocated AVFilterFormats
are not used at all (namely if there are no free links) these newly
allocated AVFilterFormats are freed again without ever being used.
Filters no longer using the callback will not exhibit this any more.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-05 17:48:25 +02:00
Andreas Rheinhardt
e424d1f557 avfilter/vf_spp: Add dummy element to array to avoid shift
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-19 04:47:17 +02:00
Andreas Rheinhardt
a85d2de45f avfilter/vf_spp: Use preinit instead of init_dict
By using preinit, the AVDCT already exists directly after
allocating the filter, so that the filter's AVClass's child_next
becomes usable for setting options with the AV_OPT_SEARCH_CHILDREN
search flag. This means that it is no longer necessary to use
the init_dict callback for this filter.

Furthermore, the earlier code did not abide by the documentation
of the init_dict callback at all: Instead of only returning the
options that have not been recognized it always returned all options
on any av_opt_set() error and errored out in this case, even if it
is just an unrecognized option. This behaviour has been inherited by
avfilter_init_dict(), contradicting its documentation. This is also
fixed in this commit.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-19 04:45:34 +02:00
Andreas Rheinhardt
8be701d9f7 avfilter/avfilter: Add numbers of (in|out)pads directly to AVFilter
Up until now, an AVFilter's lists of input and output AVFilterPads
were terminated by a sentinel and the only way to get the length
of these lists was by using avfilter_pad_count(). This has two
drawbacks: first, sizeof(AVFilterPad) is not negligible
(i.e. 64B on 64bit systems); second, getting the size involves
a function call instead of just reading the data.

This commit therefore changes this. The sentinels are removed and new
private fields nb_inputs and nb_outputs are added to AVFilter that
contain the number of elements of the respective AVFilterPad array.

Given that AVFilter.(in|out)puts are the only arrays of zero-terminated
AVFilterPads an API user has access to (AVFilterContext.(in|out)put_pads
are not zero-terminated and they already have a size field) the argument
to avfilter_pad_count() is always one of these lists, so it just has to
find the filter the list belongs to and read said number. This is slower
than before, but a replacement function that just reads the internal numbers
that users are expected to switch to will be added soon; and furthermore,
avfilter_pad_count() is probably never called in hot loops anyway.

This saves about 49KiB from the binary; notice that these sentinels are
not in .bss despite being zeroed: they are in .data.rel.ro due to the
non-sentinels.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-20 12:53:58 +02:00
Andreas Rheinhardt
18ec426a86 avfilter/formats: Factor common function combinations out
Several combinations of functions happen quite often in query_format
functions; e.g. ff_set_common_formats(ctx, ff_make_format_list(sample_fmts))
is very common. This commit therefore adds functions that are equivalent
to commonly used function combinations in order to reduce code
duplication.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-13 17:36:22 +02:00
Andreas Rheinhardt
2934a4b9a5 Remove unnecessary avassert.h inclusions
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 15:02:30 +02:00
Andreas Rheinhardt
a04ad248a0 avfilter: Constify all AVFilters
This is possible now that the next-API is gone.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 11:48:05 -03:00
James Almer
0bf3a7361d avutil: remove deprecated AVClass.child_class_next
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 11:48:04 -03:00
Anton Khirnov
775707aba9 lavfi/vf_spp: convert to the video_enc_params API
Re-enable fate-filter-spp
2021-01-01 14:25:02 +01:00
Anton Khirnov
e15371061d lavu/mem: move the DECLARE_ALIGNED macro family to mem_internal on next+1 bump
They are not properly namespaced and not intended for public use.
2021-01-01 14:14:57 +01:00
Anton Khirnov
c7d8d8d8d9 vf_spp: switch to child_class_iterate() 2020-06-10 12:36:44 +02:00
Martin Storsjö
353aecbb28 pixblockdsp, avdct: Add get_pixels_unaligned
Use this in vf_spp.c, where the get_pixels operation is done on
unaligned source addresses.

Hook up the x86 (mmx and sse) versions of get_pixels to this
function pointer, as those implementations seem to support unaligned
use.

This fixes fate-filter-spp on armv7.

Signed-off-by: Martin Storsjö <martin@martin.st>
2020-05-13 13:20:08 +03:00
Michael Niedermayer
52cc86cae1 avfilter/vf_spp: Fix endian-dependance in add_block()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-12 01:00:28 +02:00
Michael Niedermayer
dde86d0ddf avfilter/vf_spp: Remove unused AVCodecContext
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-12 01:00:28 +02:00
Jun Zhao
94004a8b65 lavfi/spp: enable runtime change flag
enable runtime change flag.

Reviewe-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2020-01-13 09:25:18 +08:00
Jun Zhao
692f0519bb lavfi/spp: add "quality" option in runtime change path
it's stranage to use option "level" in runtime change path but used
"quality" in option, add "quality" in runtime change path, it's more
intuitive and keep the "level" for compatibility.

Reviewe-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2020-01-13 09:25:18 +08:00
Derek Buitenhuis
21f9468402 avutil: Rename FF_CEIL_COMPAT to AV_CEIL_COMPAT
Libav, for some reason, merged this as a public API function. This will
aid in future merges.

A define is left for backwards compat, just in case some person
used it, since it is in a public header.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-01-27 16:36:46 +00:00
Clément Bœsch
9b8e514c14 avfilter/spp: use AV_OPT_TYPE_BOOL for use_bframe_qp option 2015-09-09 00:43:06 +02:00
Hendrik Leppkes
5d8e836d0e Replace all remaining occurances of step/depth_minus1 and offset_plus1 2015-09-08 17:10:48 +02:00
Ganesh Ajjanagadde
d79c200000 avfilter/vf_spp: use the name 's' for the pointer to the private context
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-09-01 12:02:56 +00:00
Paul B Mahol
a0854c084e avfilter: handle error in query_formats() in bunch of filters
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-04-08 13:05:06 +00:00
Michael Niedermayer
0f16dfda50 Replace PixelFormats which sneaked in over time or where forgotten by AVPixelFormats
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-18 01:18:40 +01:00
Stefano Sabatini
57ede2a507 lavfi: use ff_norm_qscale(), factorize 2015-01-13 13:12:58 +01:00
Michael Niedermayer
6706a2986c avfilter/vf_spp: Fix overflow in 8bit store slice
Fixes regression with
ffplay -f lavfi -i testsrc=640x480  -vf format=gray,boxblur=20:10,geq="'mod(lum(X,Y),16)*15'",boxblur=10,geq="'abs(mod(lum(X,Y),15)-7)*32'",spp=4:40

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-21 01:48:19 +01:00
Michael Niedermayer
1ac5abb1d0 avfilter/vf_spp: fix overflows with depth > 8
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-20 20:39:13 +01:00
Michael Niedermayer
988ca9bd53 avfilter/vf_spp: add support for 9bit YUV and GBR as well as GBRP10
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-20 18:33:52 +01:00
Michael Niedermayer
19ecd675c5 avfilter/vf_spp: add gbrp support
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-18 17:46:35 +01:00
Michael Niedermayer
4a06215c1a avfilter/vf_spp: add gray8 support
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-18 17:43:10 +01:00
Michael Niedermayer
3ff8ef62bb avfilter/vf_spp: Fix pointer type warning
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-18 16:54:18 +01:00
Michael Niedermayer
838aa08d75 avfilter/vf_spp: support 10bit per sample
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-15 18:49:35 +01:00
Michael Niedermayer
2a8eb0d156 avfilter/vf_spp: The qp array width is qp_stride not stride/16
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-12 18:14:15 +01:00
Michael Niedermayer
e8dbecb995 avfilter/vf_spp: Allocate qp storage after qp_stride is known
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-12 18:13:13 +01:00
Michael Niedermayer
30d2ac4bf9 avfilter/vf_spp: change temporary to unsigned
More consistent with uspp and allows for future 10bit support

Found-by: ubitux
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-12 13:34:18 +01:00
Michael Niedermayer
a7e87fef21 avfilter/vf_spp: Use dct->get_pixels()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-03 23:36:01 +02:00
Michael Niedermayer
a06c14a48e avfilter/vf_spp: support setting dct avoptions from the filter graph string
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-28 05:16:03 +02:00
Michael Niedermayer
e3fac20824 avfilter/vf_spp: use AVDCT
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-27 17:21:40 +02:00
Michael Niedermayer
3a2d1465c8 Merge commit '2d60444331fca1910510038dd3817bea885c2367'
* commit '2d60444331fca1910510038dd3817bea885c2367':
  dsputil: Split motion estimation compare bits off into their own context

Conflicts:
	configure
	libavcodec/Makefile
	libavcodec/arm/Makefile
	libavcodec/dvenc.c
	libavcodec/error_resilience.c
	libavcodec/h264.h
	libavcodec/h264_slice.c
	libavcodec/me_cmp.c
	libavcodec/me_cmp.h
	libavcodec/motion_est.c
	libavcodec/motion_est_template.c
	libavcodec/mpeg4videoenc.c
	libavcodec/mpegvideo.c
	libavcodec/mpegvideo_enc.c
	libavcodec/x86/Makefile
	libavcodec/x86/me_cmp_init.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-17 23:27:40 +02:00
Michael Niedermayer
2d5e9451de Merge commit 'f46bb608d9d76c543e4929dc8cffe36b84bd789e'
* commit 'f46bb608d9d76c543e4929dc8cffe36b84bd789e':
  dsputil: Split off pixel block routines into their own context

Conflicts:
	configure
	libavcodec/dsputil.c
	libavcodec/mpegvideo_enc.c
	libavcodec/pixblockdsp_template.c
	libavcodec/x86/dsputilenc.asm
	libavcodec/x86/dsputilenc_mmx.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-10 01:22:14 +02:00
Michael Niedermayer
14e2406de7 Merge commit 'a9aee08d900f686e966c64afec5d88a7d9d130a3'
* commit 'a9aee08d900f686e966c64afec5d88a7d9d130a3':
  dsputil: Split off FDCT bits into their own context

Conflicts:
	configure
	libavcodec/Makefile
	libavcodec/asvenc.c
	libavcodec/dnxhdenc.c
	libavcodec/dsputil.c
	libavcodec/mpegvideo.h
	libavcodec/mpegvideo_enc.c
	libavcodec/x86/Makefile
	libavcodec/x86/dsputilenc_mmx.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-08 03:19:06 +02:00
Michael Niedermayer
581b5f0b9b Merge commit 'e3fcb14347466095839c2a3c47ebecff02da891e'
* commit 'e3fcb14347466095839c2a3c47ebecff02da891e':
  dsputil: Split off IDCT bits into their own context

Conflicts:
	configure
	libavcodec/aic.c
	libavcodec/arm/Makefile
	libavcodec/arm/dsputil_init_arm.c
	libavcodec/arm/dsputil_init_armv6.c
	libavcodec/asvdec.c
	libavcodec/dnxhdenc.c
	libavcodec/dsputil.c
	libavcodec/dvdec.c
	libavcodec/dxva2_mpeg2.c
	libavcodec/intrax8.c
	libavcodec/mdec.c
	libavcodec/mjpegdec.c
	libavcodec/mjpegenc_common.h
	libavcodec/mpegvideo.c
	libavcodec/ppc/dsputil_altivec.h
	libavcodec/ppc/dsputil_ppc.c
	libavcodec/ppc/idctdsp.c
	libavcodec/x86/Makefile
	libavcodec/x86/dsputil_init.c
	libavcodec/x86/dsputil_mmx.c
	libavcodec/x86/dsputil_x86.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-01 15:22:11 +02:00
Michael Niedermayer
eb0fc73dcc avfilter/vf_spp: Use av_malloc_array()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-18 00:07:30 +02:00
Michael Niedermayer
325f6e0a97 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  lavfi: do not export the filters from shared objects

Conflicts:
	libavfilter/af_amix.c
	libavfilter/af_anull.c
	libavfilter/asrc_anullsrc.c
	libavfilter/f_select.c
	libavfilter/f_settb.c
	libavfilter/split.c
	libavfilter/src_movie.c
	libavfilter/vf_aspect.c
	libavfilter/vf_blackframe.c
	libavfilter/vf_colorbalance.c
	libavfilter/vf_copy.c
	libavfilter/vf_crop.c
	libavfilter/vf_cropdetect.c
	libavfilter/vf_drawbox.c
	libavfilter/vf_format.c
	libavfilter/vf_framestep.c
	libavfilter/vf_frei0r.c
	libavfilter/vf_hflip.c
	libavfilter/vf_libopencv.c
	libavfilter/vf_lut.c
	libavfilter/vf_null.c
	libavfilter/vf_overlay.c
	libavfilter/vf_scale.c
	libavfilter/vf_transpose.c
	libavfilter/vf_unsharp.c
	libavfilter/vf_vflip.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-29 11:58:11 +01:00
Clément Bœsch
493ebbd7eb Update copyrights where my email appears with the new one. 2013-09-03 20:42:24 +02:00
Clément Bœsch
147adf2c4f lavfi/spp: fix description. 2013-06-14 06:53:52 +02:00
Clément Bœsch
a2c547ffec lavfi: add spp filter. 2013-06-14 01:27:22 +02:00