Commit Graph

113 Commits

Author SHA1 Message Date
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
Timo Rothenpieler
06de593303 avfilter/frei0r: use win32dlfcn wrapper 2021-09-15 12:37:02 +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
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
Paul B Mahol
593817f51d avfilter/vf_frei0r: add timeline support 2021-02-05 13:18:21 +01:00
Paul B Mahol
381ab69042 avfilter/vf_frei0r: add support for commands 2020-11-19 11:55:47 +01:00
Andrew Rodland
04340e5e01 lavfi/frei0r: Remove duplicated pix_fmt entry
Fixes e.g. 'ffmpeg -i input.mp4 -vf frei0r=pixeliz0r output.mp4':

    [Parsed_frei0r_0 @ 0x5585b8093280] Duplicated pixel format
    Error reinitializing filters!
    Failed to inject frame into filter network: Invalid argument
    Error while processing the decoded data for stream #0:0
    Conversion failed!

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2020-11-16 19:32:32 +00:00
Carl Eugen Hoyos
1ae5a64457 lavfi/frei0r: Fix a union member type and remove an unneeded cast. 2019-04-25 00:29:09 +02:00
Jun Zhao
b272d5b9b6 lavfi/frei0r: Fixes the compilation warnings
Fixes the compilation warnings

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2019-04-21 21:20:16 +08:00
Michael Niedermayer
6b1b5af024 avfilter/vf_frei0r: Remove duplicate }, fix build
Fixes regression from a3c6b7ff59

Reported-by: qq2225936589
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-08-30 17:12:25 +02:00
Raphael Graf
a3c6b7ff59 frei0r: handle string params
This is needed for some of the frei0r filters (facebl0r and facedetect) which accept string parameters.

Fixes the issue described here:
http://www.ffmpeg-archive.org/Unable-to-set-ffmpeg-frei0r-facedetect-filter-parameter-td4680190.html

Signed-off-by: Raphael Graf <r@undefined.ch>
2018-08-30 09:57:25 +02:00
Clément Bœsch
d0d9dbec2f Merge commit 'def03d14687b9d089950ba8e45083e666de4eb68'
* commit 'def03d14687b9d089950ba8e45083e666de4eb68':
  vf_frei0r: Drop overly verbose and broken debug output

Merged-by: Clément Bœsch <u@pkh.me>
2016-06-21 22:00:12 +02:00
Michael Niedermayer
f2c8b666be avfilter: Fix max value of AV_OPT_TYPE_VIDEO_RATE
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-06-09 10:35:13 +02:00
Diego Biurrun
def03d1468 vf_frei0r: Drop overly verbose and broken debug output 2016-05-04 18:40:50 +02:00
Michael Niedermayer
11f87ca71e vf_frei0r: also set AVFilterLink.frame_rate
(cherry picked from ffmpeg commit 353cf95f94)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2015-11-09 08:09:42 +01:00
Ganesh Ajjanagadde
430f943e63 avfilter/vf_frei0r: use av_strtod instead of strtod for added flexibility
This converts the usage of strtod to av_strtod in order to unify and
make number parsing more consistent. This also adds support for SI
postfixes.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-11-02 06:50:18 -05:00
Ganesh Ajjanagadde
6aaac24d72 avfilter/all: propagate errors of functions from avfilter/formats
Many of the functions from avfilter/formats can return errors, usually AVERROR(ENOMEM).
This propagates the return values.

All of these were found by using av_warn_unused_result, demonstrating its utility.

Tested with FATE. I am least sure of the changes to avfilter/filtergraph,
since I don't know what/how reduce_format is intended to behave and how it should
react to errors.

Fixes: CID 1325680, 1325679, 1325678.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Previous version Reviewed-by: Nicolas George <george@nsup.org>
Previous version Reviewed-by: Clément Bœsch <u@pkh.me>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-14 10:04:01 -04: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
e0623953e1 avfilter/vf_frei0r: fix build with DEBUG enabled
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-01-17 15:41:23 +01:00
Michael Niedermayer
353cf95f94 avfilter/vf_frei0r: also set AVFilterLink.frame_rate
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-01-17 14:46:21 +01:00
Vittorio Giovara
d0b224054f vf_frei0r: do not increment string if it reached the end
Bug-Id: 778
CC: libav-stable@libav.org
2014-12-08 13:30:38 +00:00
Vittorio Giovara
4c41a7a179 vf_frei0r: fix missing end of line character
Error introduced in 61b323ce7c.
2014-03-04 18:27:09 +01:00
Michael Niedermayer
bfe03205a8 Merge commit '4e0be9c86f2003dd3ba2eb8fad01e8d0e538075e'
* commit '4e0be9c86f2003dd3ba2eb8fad01e8d0e538075e':
  vf_frei0r: prevent a segfault when filter parameters are not set

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-04 13:17:25 +01:00
Michael Niedermayer
2b0ff8d642 Merge commit '8accddeb5806cd98e3803b4ddf2a2ef576d0e4d9'
* commit '8accddeb5806cd98e3803b4ddf2a2ef576d0e4d9':
  vf_frei0r: adjust error messages

Conflicts:
	libavfilter/vf_frei0r.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-04 12:41:31 +01:00
Vittorio Giovara
61b323ce7c vf_frei0r: refactor library loading from env variable
strtok_r is not needed any more, so remove it from configure.
2014-03-04 11:39:02 +01:00
Vittorio Giovara
4e0be9c86f vf_frei0r: prevent a segfault when filter parameters are not set 2014-03-04 11:19:03 +01:00
Vittorio Giovara
8accddeb58 vf_frei0r: adjust error messages 2014-03-04 11:19:03 +01:00
Marton Balint
ead0dd3cf6 lavfi/frei0r: factorize plugin loading with static path
Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Marton Balint <cus@passwd.hu>
2014-02-26 22:48:37 +01:00
Marton Balint
35ead1f281 lavfi/frei0r: search plugins in lib64 dirs on all architectures
As Reimar Döffinger pointed out there are non-x86 64bit architectures as well.

Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Marton Balint <cus@passwd.hu>
2014-02-26 22:46:15 +01:00
Marton Balint
8e41240047 lavfi/frei0r: load plugins from lib64 folders as well on 64bit builds
Signed-off-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-02-11 03:25:00 +01: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
Anton Khirnov
cd43ca0443 lavfi: do not export the filters from shared objects 2013-10-28 15:29:54 +01:00
Michael Niedermayer
02a6ee5168 avfilter/vf_frei0r: fix out of array read
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-04 11:16:35 +02:00
Paul B Mahol
b211607b5c avfilter: various cosmetics
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-09-12 14:01:43 +00:00
Paul B Mahol
be7d6710b4 lavfi/frei0r: use AV_OPT_TYPE_IMAGE_SIZE
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-07-26 17:16:26 +00:00
Paul B Mahol
7ac736afbd lavfi/frei0r: use AV_OPT_TYPE_VIDEO_RATE
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-07-26 15:24:55 +00:00
Paul B Mahol
229d5bfdc8 lavfi/frei0r: make use of AVFILTER_DEFINE_CLASS
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-05-27 11:31:52 +00:00
Michael Niedermayer
d5e5e73c52 Merge commit 'd371c3c2e2830d9783465ecfe1ab7d93351083b7'
* commit 'd371c3c2e2830d9783465ecfe1ab7d93351083b7':
  vf_frei0r: make config_props work properly when called multiple times.
  vf_gradfun: make config_props work properly when called multiple times.
  vf_lut: make config_props work properly when called multiple times.

Conflicts:
	libavfilter/vf_lut.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-17 10:51:59 +02:00
Anton Khirnov
d371c3c2e2 vf_frei0r: make config_props work properly when called multiple times.
Do not leak the initialized filter instance.
2013-05-17 07:42:46 +02:00
Michael Niedermayer
e55092b12b Merge commit 'f6b6d6ac42c0ee427fcd3fae4c398b2103b491b8'
* commit 'f6b6d6ac42c0ee427fcd3fae4c398b2103b491b8':
  vf_frei0r: use the name 's' for the pointer to the private context
  vf_format: use the name 's' for the pointer to the private context
  vf_fieldorder: use the name 's' for the pointer to the private context
  vf_fieldorder: cosmetics, remove an extra linebreak

Conflicts:
	libavfilter/vf_frei0r.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-16 15:21:31 +02:00
Michael Niedermayer
efc08e00cc Merge commit 'b3ea76624ad1baab0b6bcc13f3f856be2f958110'
* commit 'b3ea76624ad1baab0b6bcc13f3f856be2f958110':
  vf_aspect: use the name 's' for the pointer to the private context
  Remove commented-out debug #define cruft

Conflicts:
	libavcodec/4xm.c
	libavcodec/dvdsubdec.c
	libavcodec/ituh263dec.c
	libavcodec/mpeg12.c
	libavfilter/avfilter.c
	libavfilter/vf_aspect.c
	libavfilter/vf_fieldorder.c
	libavformat/rtmpproto.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-16 09:56:43 +02:00
Anton Khirnov
f6b6d6ac42 vf_frei0r: use the name 's' for the pointer to the private context
This is shorter and consistent across filters.
2013-05-16 07:33:23 +02:00
Diego Biurrun
2832ea26f3 Remove commented-out debug #define cruft 2013-05-16 00:23:30 +02:00
Clément Bœsch
e85ea7d387 lavfi/frei0r: fix crash when parameters are not set. 2013-05-03 17:08:33 +02:00
Michael Niedermayer
3dedcef8b8 avfilter: add missing AV_OPT_FLAG_FILTERING_PARAM
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-04-12 15:47:16 +02:00
Anton Khirnov
d69a4177b9 lavfi: remove now unused args parameter from AVFilter.init
Conflicts:

	libavfilter/avfilter.c
	libavfilter/vf_drawtext.c
	libavfilter/vf_lut.c
	libavfilter/vf_select.c
	libavfilter/vf_setpts.c
	libavfilter/vsrc_color.c
	libavfilter/vsrc_movie.c

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-04-12 11:54:39 +02:00
Michael Niedermayer
da3f89988f Merge commit '5aa1a668cfae7f617e1a06efad20f87283badd8a'
* commit '5aa1a668cfae7f617e1a06efad20f87283badd8a':
  vf_frei0r: switch to an AVOptions-based system.

Conflicts:
	doc/filters.texi
	libavfilter/vf_frei0r.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-04-10 19:51:02 +02:00
Anton Khirnov
c43a7ecad9 lavfi: remove now unused args parameter from AVFilter.init 2013-04-09 19:12:38 +02:00
Anton Khirnov
5aa1a668cf vf_frei0r: switch to an AVOptions-based system. 2013-04-09 19:04:28 +02:00
Michael Niedermayer
a05a44e205 Merge commit '7e350379f87e7f74420b4813170fe808e2313911'
* commit '7e350379f87e7f74420b4813170fe808e2313911':
  lavfi: switch to AVFrame.

Conflicts:
	doc/filters.texi
	libavfilter/af_ashowinfo.c
	libavfilter/audio.c
	libavfilter/avfilter.c
	libavfilter/avfilter.h
	libavfilter/buffersink.c
	libavfilter/buffersrc.c
	libavfilter/buffersrc.h
	libavfilter/f_select.c
	libavfilter/f_setpts.c
	libavfilter/fifo.c
	libavfilter/split.c
	libavfilter/src_movie.c
	libavfilter/version.h
	libavfilter/vf_aspect.c
	libavfilter/vf_bbox.c
	libavfilter/vf_blackframe.c
	libavfilter/vf_delogo.c
	libavfilter/vf_drawbox.c
	libavfilter/vf_drawtext.c
	libavfilter/vf_fade.c
	libavfilter/vf_fieldorder.c
	libavfilter/vf_fps.c
	libavfilter/vf_frei0r.c
	libavfilter/vf_gradfun.c
	libavfilter/vf_hqdn3d.c
	libavfilter/vf_lut.c
	libavfilter/vf_overlay.c
	libavfilter/vf_pad.c
	libavfilter/vf_scale.c
	libavfilter/vf_showinfo.c
	libavfilter/vf_transpose.c
	libavfilter/vf_vflip.c
	libavfilter/vf_yadif.c
	libavfilter/video.c
	libavfilter/vsrc_testsrc.c
	libavfilter/yadif.h

Following are notes about the merge authorship and various technical details.

Michael Niedermayer:
  * Main merge operation, notably avfilter.c and video.c
  * Switch to AVFrame:
    - afade
    - anullsrc
    - apad
    - aresample
    - blackframe
    - deshake
    - idet
    - il
    - mandelbrot
    - mptestsrc
    - noise
    - setfield
    - smartblur
    - tinterlace
  * various merge changes and fixes in:
    - ashowinfo
    - blackdetect
    - field
    - fps
    - select
    - testsrc
    - yadif

Nicolas George:
  * Switch to AVFrame:
    - make rawdec work with refcounted frames. Adapted from commit
      759001c534 by Anton Khirnov.
      Also, fix the use of || instead of | in a flags check.
    - make buffer sink and src, audio and video work all together

Clément Bœsch:
  * Switch to AVFrame:
    - aevalsrc
    - alphaextract
    - blend
    - cellauto
    - colormatrix
    - concat
    - earwax
    - ebur128
    - edgedetect
    - geq
    - histeq
    - histogram
    - hue
    - kerndeint
    - life
    - movie
    - mp (with the help of Michael)
    - overlay
    - pad
    - pan
    - pp
    - pp
    - removelogo
    - sendcmd
    - showspectrum
    - showwaves
    - silencedetect
    - stereo3d
    - subtitles
    - super2xsai
    - swapuv
    - thumbnail
    - tile

Hendrik Leppkes:
  * Switch to AVFrame:
    - aconvert
    - amerge
    - asetnsamples
    - atempo
    - biquads

Matthieu Bouron:
  * Switch to AVFrame
    - alphamerge
    - decimate
    - volumedetect

Stefano Sabatini:
  * Switch to AVFrame:
    - astreamsync
    - flite
    - framestep

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Nicolas George <nicolas.george@normalesup.org>
Signed-off-by: Clément Bœsch <ubitux@gmail.com>
Signed-off-by: Hendrik Leppkes <h.leppkes@gmail.com>
Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com>
Signed-off-by: Stefano Sabatini <stefasab@gmail.com>

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-03-10 01:40:35 +01:00