Commit Graph

85 Commits

Author SHA1 Message Date
James Almer 65ddc74988 avutil: remove deprecated FF_API_OLD_CHANNEL_LAYOUT
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-07 08:53:30 -03:00
Anton Khirnov 08bebeb1be Revert "all: Don't set AVClass.item_name to its default value"
Some callers assume that item_name is always set, so this may be
considered an API break.

This reverts commit 0c6203c97a.
2024-01-20 10:34:48 +01:00
Andreas Rheinhardt 0c6203c97a all: Don't set AVClass.item_name to its default value
Unnecessary since acf63d5350adeae551d412db699f8ca03f7e76b9;
also avoids relocations.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-12-22 15:12:33 +01:00
Andreas Rheinhardt 19af142d45 avfilter/internal: Don't include formats.h
internal.h doesn't rely on it; instead include it directly
in every user that needs it (a filter needing it is basically
equivalent to it using FILTER_QUERY_FUNC, i.e. a majority of
filters doesn't need it).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-07 09:21:13 +02:00
Andreas Rheinhardt 50ea7389ec avfilter: Deduplicate default audio inputs/outputs
Lots of audio filters use very simple inputs or outputs:
An array with a single AVFilterPad whose name is "default"
and whose type is AVMEDIA_TYPE_AUDIO; 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 (4784B here) as well as relocations.

*: In fact, several filters (like the filters in af_biquads.c)
already use the same inputs; 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
Paul B Mahol a196d02e86 avfilter/af_aresample: switch to activate 2023-07-05 21:42:22 +02:00
James Almer 1f96db959c avfilter: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-15 09:42:46 -03: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 0c34cf899d avfilter/af_aresample: Use preinit instead of init_dict
By using preinit, the SwrContext 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; yet if
the error was just caused by an unrecognized option, it should not
error out at all and instead return said option.

This behaviour has been inherited by avfilter_init_dict(),
contradicting its documentation. This is also fixed by this commit.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-19 04:44:27 +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
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
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
Andreas Rheinhardt ae5026c905 avfilter/formats: Schedule avfilter_make_format64_list() for removal
Despite its name, this function is not part of the public API, as
formats.h, the header containing its declaration, is a private header.
The formats API was once public API, but that changed long ago
(b74a1da49d, the commit scheduling it to
become private, is from 2012). That avfilter_make_format64_list() was
forgotten is probably a result of the confusion resulting from the
libav-ffmpeg split.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-08-12 21:10:59 +02:00
Anton Khirnov 3dd324427a af_aresample: switch to child_class_iterate() 2020-06-10 12:36:44 +02:00
Paul B Mahol c90b88090c avfilter: do not leak AVFrame on failed buffer allocation
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-06-24 19:15:57 +02:00
Paul B Mahol ed93ed5ee3 avfilter: don't anonymously typedef structs
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-05-13 11:39:28 +02:00
Muhammad Faiz 6af050d7d0 avfilter: do not use AVFrame accessor
Reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
2017-04-23 14:40:30 +07: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
Nicolas George 4982130d5a lavfi/af_aresample: remove looping on request_frame(). 2015-10-07 19:00:22 +02:00
Ronald S. Bultje ad45121d56 options: mark av_get_{int,double,q} as deprecated.
Convert last users to av_opt_get_*() counterparts.
2015-08-18 12:05:17 -04:00
Michael Niedermayer 2ea8a48083 avfilter/af_aresample: Check ff_all_* for allocation failures
Fixes: signal_sigabrt_7ffff70eccc9_498_divx502.avi with memlimit 1572864

Found-by: Samuel Groß, Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-17 21:13:56 +02:00
Michael Niedermayer d70e503ebc avfilter/af_aresample: remove unused variable
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-06 15:58:28 +01:00
Michael Niedermayer 09024fe681 avfilter/af_aresample: Limit data per inserted packet
This avoids creating unwieldy large packets, which is allowed but
does not seem to be a good idea

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-04 17:17:24 +01:00
Michael Niedermayer 97da68172a avfilter/af_aresample: split flushing code out
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-04 17:17:23 +01:00
Derek Buitenhuis 1dbc3e8ac8 avfilter/aresample: Check for memory alloc failure for out sample rates
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2014-10-02 12:22:37 +01:00
Reimar Döffinger 3cc0f335fe af_aresample: remove only use of array compound literals with non-const initializers in FFmpeg.
Some older compilers might have particular trouble with them,
and they do not really seem worth it to me.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
2013-12-30 12:38:04 +01:00
Alex Sukhanov 86b3435fc0 af_aresample: Fix timestamp of first padded PCM audio packet
Problem:
ffmpeg generated video file which had two audio packets with the same timestamp: last original audio packet and first padded audio packet.

Timestamp of first added audio packet by 'apad' fitler had the same value as last original audio packet. The problem was in 'aresample' fitler, which used next pts instead of current one.
As long as 'apad' and 'aresample' filters have separate mechanisms of timestamp calculation, they got the same values.

Command line:
ffmpeg -i <input_filename> -shortest -apad 512 -af asetnsamples=n=512 -b:a 1058400 -ac 1 -ar 44100 -async 0 -acodec pcm_s16le -sn -f matroska -y <output_file>

Fix:
Call swr_next_pts() function before swr_convert()

Tested:
FATE tests passed.
Fix has been tested in our Transcoder regression framework on ~10k test videos. It's about ~500k transcodes.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-11-15 11:54:02 +01:00
Michael Niedermayer ea6331b2c6 avfilter/af_aresample: Calculate output buffer size more precisely.
Fixes accumulation of data in case of significant silence injections

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-11-06 23:54:02 +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
Paul B Mahol b211607b5c avfilter: various cosmetics
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-09-12 14:01:43 +00:00
Michael Niedermayer ec0e0eb4c1 avfilter/vf_scale+aresample: minor simpification
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-08-16 04:26:59 +02:00
Michael Niedermayer 4f43e9b4af avfilter/aresample: use init_dict system and set child AVOption context correctly
Parts of this commit are based on: 4fa1f52e

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-04-11 20:40:59 +02:00
Michael Niedermayer cd5f50a255 avfilter: avoid direct access to AVFrame.channels
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-03-15 16:13:53 +01:00
Clément Bœsch c82bb2815b lavfi/aresample: raise filter_frame() error. 2013-03-13 19:00:08 +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
Nicolas George 3d2adeb6f8 lavfi/af_aresample: fix info log for unknown layouts. 2013-02-28 19:23:12 +01:00
Nicolas George 2bd104c72a lavfi/af_aresample: fix layout consistency check.
If the channel layout is unknown, lswr will internally use
the default one for the corresponding number of channels.
2013-02-28 19:23:12 +01:00
Nicolas George b00502457a lavfi/af_aresample: accept unknown channel layouts. 2013-01-26 11:15:38 +01:00
Stefano Sabatini e06c147581 lavfi/aresample: fix style
Improve overall consistency/improve readability.
2012-12-26 11:56:35 +01:00
Nicolas George 238edd2fe3 lavfi: add a channels field to AVFilterLink.
Also: fix af_pan and af_aresample, that forgot to update
audio->channels.
2012-12-20 13:03:41 +01:00
Michael Niedermayer 616e6ffac6 aresample: increase n_out buffer size a bit to reduce delay in some corner cases
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-12-13 18:17:48 +01:00
Clément Bœsch 2d9d444051 lavfi: convert remaining input/output list compound literals to named objects.
This is following 568c70e79e.
2012-11-28 23:19:20 +01:00
Michael Niedermayer cd7febd33f lavfi: replace filter_samples by filter_frame
Based on patch by Anton Khirnov
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-11-28 16:43:34 +01:00
Michael Niedermayer 8d231e37af af_aresample: consistently use ROUNDED_DIV
This fixes issues with negative timestamps

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-11-26 21:09:15 +01:00
Michael Niedermayer 4b5a12a2cb af_aresample: fix rounding of negative timestamps
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-11-26 16:25:47 +01:00
Michael Niedermayer 014058abea af_aresample: check ff_get_audio_buffer() failure
Fixes null pointer dereference

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-11-24 17:33:32 +01:00
Michael Niedermayer c44a028e19 af_aresample: allocate at least 1 sample buffer. Fix null ptr dereference.
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-11-19 15:55:54 +01:00
Paul B Mahol 1acd2f6ba7 Replace rest of libavutil/audioconvert.h with libavutil/channel_layout.h
Also remove it in once case when it is not needed.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2012-11-13 13:21:21 +00:00
Michael Niedermayer 9ba2484ece af_aresample: fix leak on alloc failure
Fixes CID733798
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-10-11 16:48:25 +02:00