Commit Graph

85 Commits

Author SHA1 Message Date
Anton Khirnov 1e7d2007c3 all: use designated initializers for AVOption.unit
Makes it robust against adding fields before it, which will be useful in
following commits.

Majority of the patch generated by the following Coccinelle script:

@@
typedef AVOption;
identifier arr_name;
initializer list il;
initializer list[8] il1;
expression tail;
@@
AVOption arr_name[] = { il, { il1,
- tail
+ .unit = tail
}, ...  };

with some manual changes, as the script:
* has trouble with options defined inside macros
* sometimes does not handle options under an #else branch
* sometimes swallows whitespace
2024-02-14 14:53:41 +01:00
Andreas Rheinhardt 2f62a433f2 avfilter: Deduplicate default video inputs/outputs
Lots of video filters use a very simple input or output:
An array with a single AVFilterPad whose name is "default"
and whose type is AVMEDIA_TYPE_VIDEO; everything else is unset.

Given that we never use pointer equality for inputs or outputs*,
we can simply use a single AVFilterPad instead of dozens; this
even saves .data.rel.ro (8312B here) as well as relocations.

*: In fact, several filters (like the filters in vf_lut.c)
already use the same outputs; furthermore, ff_filter_alloc()
duplicates the input and output pads so that we do not even
work with the pads directly.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-07 09:21:13 +02:00
James Almer 599abc0f3a avutil/frame: deprecate interlaced_frame and top_field_first
Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-04 18:15:00 -03:00
James Almer 36827ea783 avfilter: use the new AVFrame interlace flags in all filters
Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-04 18:14:11 -03: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 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 628b30e886 avfilter/vf_fieldorder: Remove always-true check
A filter's formats.query callback is only called after all
the inputs and outputs have already been created.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-05 17:30:40 +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 4049b34aca avfilter/vf_fieldorder: Simplify setting common pixel formats
by using ff_set_common_formats().

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-15 23:18:57 +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
Nicolas George 2f76476549 lavfi: regroup formats lists in a single structure.
It will allow to refernce it as a whole without clunky macros.

Most of the changes have been automatically made with sed:

sed -i '
  s/-> *in_formats/->incfg.formats/g;
  s/-> *out_formats/->outcfg.formats/g;
  s/-> *in_channel_layouts/->incfg.channel_layouts/g;
  s/-> *out_channel_layouts/->outcfg.channel_layouts/g;
  s/-> *in_samplerates/->incfg.samplerates/g;
  s/-> *out_samplerates/->outcfg.samplerates/g;
  ' src/libavfilter/*(.)
2020-09-08 14:02:40 +02:00
Paul B Mahol 07050d7bdc avfilter/vf_fieldorder: fix heap-buffer overflow
Fixes #8264
2019-10-13 23:10:16 +02: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
Michael Niedermayer 40d552dae6 Merge commit '1a3eb042c704dea190c644def5b32c9cee8832b8'
* commit '1a3eb042c704dea190c644def5b32c9cee8832b8':
  Replace av_dlog with normal av_log at trace level

Conflicts:
	ffplay.c
	libavdevice/fbdev_dec.c
	libavfilter/avfilter.c
	libavfilter/internal.h
	libavfilter/setpts.c
	libavfilter/src_movie.c
	libavfilter/vf_crop.c
	libavfilter/vf_drawtext.c
	libavfilter/vf_fieldorder.c
	libavformat/assdec.c
	libavformat/avidec.c
	libavformat/flvdec.c
	libavformat/http.c
	libavformat/ipmovie.c
	libavformat/isom.c
	libavformat/mov.c
	libavformat/mpegenc.c
	libavformat/mpegts.c
	libavformat/mpegtsenc.c
	libavformat/mux.c
	libavformat/mxfdec.c
	libavformat/nsvdec.c
	libavformat/oggdec.c
	libavformat/r3d.c
	libavformat/rtspdec.c
	libavformat/utils.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-20 03:19:47 +02:00
Vittorio Giovara 1a3eb042c7 Replace av_dlog with normal av_log at trace level
This applies to every library where performance is not critical.
2015-04-19 12:41:59 +01:00
Michael Niedermayer cdf6a9441d Merge commit 'a7d070acb55c3ebbdd5e93e3366f32865732b8a3'
* commit 'a7d070acb55c3ebbdd5e93e3366f32865732b8a3':
  vf_fieldorder: avoid using AV_PIX_FMT_NB

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-27 03:02:37 +02:00
Anton Khirnov a7d070acb5 vf_fieldorder: avoid using AV_PIX_FMT_NB
That hardcodes the number of pixel formats into lavfi and will break
when a shared lavu is updated, adding new pixel formats.
2014-05-26 22:25:26 +02:00
Michael Niedermayer 74a8dbe1c4 Merge commit '58400ac133bcfb6bf8196b4e5208bc178307739b'
* commit '58400ac133bcfb6bf8196b4e5208bc178307739b':
  lavfi: name anonymous structs

Conflicts:
	libavfilter/buffersink.c
	libavfilter/f_select.c
	libavfilter/src_movie.c
	libavfilter/vf_drawbox.c
	libavfilter/vf_drawtext.c
	libavfilter/vf_overlay.c
	libavfilter/vf_showinfo.c
	libavfilter/vf_unsharp.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-19 18:20:17 +02:00
Vittorio Giovara 58400ac133 lavfi: name anonymous structs 2014-04-19 16:20:57 +02:00
Vittorio Giovara 446e37dc97 vf_fieldorder: remove superfluous get_video_buffer 2013-11-04 14:37:06 +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 f94124c23e Merge commit '00d7369de06a16f7c8770a899fcb16bcb94b1e20'
* commit '00d7369de06a16f7c8770a899fcb16bcb94b1e20':
  vf_fieldorder: log when processing is skipped

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-22 19:26:42 +02:00
Vittorio Giovara 00d7369de0 vf_fieldorder: log when processing is skipped
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2013-10-22 10:58:25 +02:00
Michael Niedermayer 4bc7a2a64b avfilter: remove duplicate includes
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-21 15:36:33 +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 6770fa4df8 lavfi/fieldorder: work with non writtable frames too
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-09-06 18:34:37 +00:00
Paul B Mahol 33dacda40b lavfi/fieldorder: remove pal8 format
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-09-06 18:34:37 +00:00
Paul B Mahol 86cb986ce1 lavfi/fieldorder: add timeline support
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-09-06 17:45:31 +00:00
Paul B Mahol df7e3572c3 lavfi/fieldorder: use av_image_fill_linesizes()
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-09-06 17:45:31 +00:00
Paul B Mahol 9b35bee696 lavfi/fieldorder: remove redundant get_video_buffer()
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-09-06 17:45:31 +00:00
Michael Niedermayer e43a0a232d avfilter: fix plane validity checks
Fixes out of array accesses

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-08-03 19:15: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
Anton Khirnov d64cf54b34 vf_fieldorder: use the name 's' for the pointer to the private context
This is shorter and consistent across filters.
2013-05-16 07:33:07 +02:00
Anton Khirnov 9bbf6c681a vf_fieldorder: cosmetics, remove an extra linebreak 2013-05-16 07:32:49 +02:00
Diego Biurrun 2832ea26f3 Remove commented-out debug #define cruft 2013-05-16 00:23:30 +02:00
Michael Niedermayer ff4680922f Merge remote-tracking branch 'qatar/master'
* qatar/master:
  pixdesc: rename PIX_FMT_* flags to AV_PIX_FMT_FLAG_*

Conflicts:
	doc/APIchanges
	libavcodec/avpicture.c
	libavcodec/ffv1dec.c
	libavcodec/ffv1enc.c
	libavcodec/imgconvert.c
	libavcodec/tiffenc.c
	libavfilter/vf_pixdesctest.c
	libavfilter/vf_scale.c
	libavutil/imgutils.c
	libavutil/pixdesc.c
	libavutil/version.h
	libswscale/swscale_internal.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-15 11:10:09 +02:00
Anton Khirnov e6c4ac7b5f pixdesc: rename PIX_FMT_* flags to AV_PIX_FMT_FLAG_* 2013-05-15 07:46:51 +02:00
Michael Niedermayer b8a1f8b4e2 Merge commit 'a39c154049a2d0c4fb02a5c74f58d6986ec21cec'
* commit 'a39c154049a2d0c4fb02a5c74f58d6986ec21cec':
  vf_fieldorder: switch to an AVOptions-based system.

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

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-04-10 19:03:30 +02:00
Anton Khirnov a39c154049 vf_fieldorder: switch to an AVOptions-based system. 2013-04-09 19:03:56 +02:00
Clément Bœsch cb0fb4d04d lavfi/fieldorder: use standard options parsing. 2013-03-24 12:26:24 +01:00
Stefano Sabatini aeac1dae29 lavfi/fieldorder: add support to named options 2013-03-13 00:37:13 +01:00
Stefano Sabatini a3233e9d7a lavfi/fieldorder: remove unused headers and commented define 2013-03-13 00:34:51 +01: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
Anton Khirnov 7e350379f8 lavfi: switch to AVFrame.
Deprecate AVFilterBuffer/AVFilterBufferRef and everything related to it
and use AVFrame instead.
2013-03-08 07:37:18 +01:00
Michael Niedermayer 1eb8809a41 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  vf_fieldorder: require write permissions
  vf_fieldorder: reindent

Conflicts:
	libavfilter/vf_fieldorder.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-11-29 02:54:50 +01:00
Anton Khirnov e67fdbffe5 vf_fieldorder: switch to filter_frame, this filter did not support real slices
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-11-28 19:23:32 +01:00
Anton Khirnov 4c973de9a5 vf_fieldorder: require write permissions
This filter modifies the input frame.
2012-11-28 08:50:24 +01:00
Anton Khirnov 49dd71a6f1 vf_fieldorder: reindent 2012-11-28 08:50:24 +01:00
Anton Khirnov 565e4993c6 lavfi: merge start_frame/draw_slice/end_frame
Any alleged performance benefits gained from the split are purely
mythological and do not justify added code complexity.
2012-11-28 08:50:19 +01:00