summaryrefslogtreecommitdiff
path: root/libavfilter/af_amix.c
Commit message (Collapse)AuthorAge
* avfilter/af_amix: Use formats list instead of query functionAndreas Rheinhardt2021-10-05
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avfilter: Replace query_formats callback with union of list and callbackAndreas Rheinhardt2021-10-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Replace all occurences of av_mallocz_array() by av_calloc()Andreas Rheinhardt2021-09-20
| | | | | | | They do the same. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avfilter/af_amix: Free inpads' names genericallyAndreas Rheinhardt2021-08-22
| | | | | Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avfilter/avfilter: Add numbers of (in|out)pads directly to AVFilterAndreas Rheinhardt2021-08-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* avfilter/avfilter: Remove unused feature to add pads in the middleAndreas Rheinhardt2021-08-17
| | | | | Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avfilter/formats: Factor common function combinations outAndreas Rheinhardt2021-08-13
| | | | | | | | | | | 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>
* avfilter: Constify all AVFiltersAndreas Rheinhardt2021-04-27
| | | | | | | 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>
* avfilter/af_amix: rename sum option to normalizePaul B Mahol2021-02-12
| | | | It makes more sense to still use provided weights.
* avfilter/af_amix: add sum optionPaul B Mahol2021-02-04
|
* avfilter/af_amix: do not leave unset PTS for frames after first stream is overPaul B Mahol2020-09-14
| | | | First stream is used only to get number of samples to put into each output frame.
* avfilter/af_amix: Fix double-free of AVFilterChannelLayouts on errorAndreas Rheinhardt2020-08-23
| | | | | | | | | | | | | | | | | | | | | | | | | The query_formats function of the amix filter tries to allocate a list of channel layouts which are attached to more permanent objects (an AVFilter's links) for storage afterwards on success. If attaching a list to a link succeeds, the link becomes one of the common owners of the list. Yet if a list has been successfully attached to links (or if there were no links to attach it to in which case ff_set_common_channel_layouts() already frees the list) and an error happens lateron, the list was manually freed, which is wrong, because the list has either already been freed or it is owned by its links in which case these links' pointers to their list will become dangling and there will be double-frees/uses-after-free when these links are cleaned up automatically. This commit fixes this by removing the custom freeing code; this is made possible by using the list in ff_set_common_channel_layouts() directly after its allocation (without anything that can fail in between). Notice that ff_set_common_channel_layouts() is buggy itself which can lead to double-frees on error. This is not fixed in this commit. Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avfilter/af_amix: Don't needlessly reallocate tableAndreas Rheinhardt2020-08-23
| | | | | | | | | | | Replace using ff_add_format() repeatedly by a single call to ff_make_format_list(). (Right now this also fixes a memleak: If the first ff_add_format() succeeds and a subsequent call fails, the list leaks.) Reviewed-by: Paul B Mahol <onemda@gmail.com> Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avfilter/af_amix: make weights option runtime configuredPaul B Mahol2020-04-29
|
* avfilter/af_amix: unbreak FATE, increase iterator when breaking from loopPaul B Mahol2020-04-14
|
* avfilter/af_amix: use av_strtod() for weightsPaul B Mahol2020-04-14
|
* avfilter/af_amix: change the max range of the number of inputsLimin Wang2020-01-11
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avfilter/af_amix: fix filtering if specified weights are negativePaul B Mahol2019-10-03
|
* avfilter: forward status back in some filters that missed itPaul B Mahol2018-05-05
| | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* avfilter/af_amix: add weights optionPaul B Mahol2018-04-01
| | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* avfilter/af_amix: make use of av_asprintf()Paul B Mahol2017-11-24
| | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* avfilter/af_amix: do not request samples if inlink reached EOFPaul B Mahol2017-08-27
| | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* avfilter/af_amix: simplify const entries for duration in amix_options[]Paul B Mahol2017-08-26
| | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* avfilter/af_amix: switch to activatePaul B Mahol2017-08-26
| | | | | | Really fixes hangs and infinite loops. Signed-off-by: Paul B Mahol <onemda@gmail.com>
* avfilter/af_amix: check ff_insert_inpad() for failurePaul B Mahol2017-08-25
|
* af_amix: Add missing error checkDerek Buitenhuis2017-07-07
| | | | Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* avfilter/af_amix: fix possible hangPaul B Mahol2017-06-18
| | | | | | Fixes #6424. Signed-off-by: Paul B Mahol <onemda@gmail.com>
* avfilter/af_amix: add double sample format supportPaul B Mahol2017-04-10
| | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* libavfilter/af_amix.c Increase sources from 32 to 1024Warblefly2017-04-09
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avfilter/af_amix: use ff_all_channel_counts() instead of ↵Paul B Mahol2016-09-10
| | | | | | | | ff_all_channel_layouts() Adds support for filtering frames with unknown channel layouts. Signed-off-by: Paul B Mahol <onemda@gmail.com>
* avfilter/af_amix: make independent of the channel layoutMichael Niedermayer2016-09-06
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avfilter/af_amix: dont fail if there are no samples in output_frame()Michael Niedermayer2016-06-06
| | | | | | Fixes Ticket5326 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavfi/af_amix: fix memory leakGanesh Ajjanagadde2015-12-09
| | | | | | | | | | | | | | | | | Recent commits 6aaac24d72a7da631173209841a3944fcb4a3309 and 3835554bf8ed78539a3492c239f979c0ab03a15f made progress towards cleaning up usage of the formats API, and in particular fixed possible NULL pointer dereferences. This commit addresses the issue of possible resource leaks when some intermediate call fails. Tested with valgrind --leak-check=full --show-leak-kinds=all, and manual simulation of malloc/realloc failures. Fixes: CID 1250334. Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* lavfi/af_amix: mostly fix scheduling.Nicolas George2015-11-07
|
* avfilter/all: propagate errors of functions from avfilter/formatsGanesh Ajjanagadde2015-10-14
| | | | | | | | | | | | | | | | | | 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>
* avfilter: handle error in query_formats() in bunch of filtersPaul B Mahol2015-04-08
| | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* avfilter/af_amix: Use av_mallocz_array()Michael Niedermayer2015-04-06
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* lavfi: check av_strdup() return valuePaul B Mahol2015-01-06
| | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* avfilter/af_amix: Use avpriv_float_dsp_alloc()Michael Niedermayer2014-11-18
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* libavfilter/af_amix: avoid derreferencing possible nullReynaldo H. Verdejo Pinochet2014-09-26
| | | | | | | | ff_all_channel_layouts() might return null on alloc failure. Fixes CID1241516 Signed-off-by: Reynaldo H. Verdejo Pinochet <reynaldo@osg.samsung.com>
* Drop remaining unneeded != NULLMichael Niedermayer2014-08-15
| | | | | Reviewed-by: Clément Bœsch <u@pkh.me> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* avfilter/af_amix: Use av_mallocz_array()Michael Niedermayer2014-06-07
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* Merge remote-tracking branch 'qatar/master'Michael Niedermayer2013-10-29
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
| * lavfi: do not export the filters from shared objectsAnton Khirnov2013-10-28
| |
* | avfilter: various cosmeticsPaul B Mahol2013-09-12
| | | | | | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* | Reinstate proper FFmpeg license for all files.Thilo Borgmann2013-08-30
| |
* | Merge commit '093804a93cc5da3f95f98265a5df116912443cec'Michael Niedermayer2013-05-05
|\| | | | | | | | | | | | | | | | | | | | | | | | | * commit '093804a93cc5da3f95f98265a5df116912443cec': avfilter: Add av_cold attributes to init/uninit functions Conflicts: libavfilter/af_ashowinfo.c libavfilter/af_volume.c libavfilter/src_movie.c libavfilter/vf_lut.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * avfilter: Add av_cold attributes to init/uninit functionsDiego Biurrun2013-05-04
| |
* | Merge commit '7cdd737ba81b5c2c9521c4509edf0ac315fabc65'Michael Niedermayer2013-04-12
|\| | | | | | | | | | | | | * commit '7cdd737ba81b5c2c9521c4509edf0ac315fabc65': lavfi: mark filters with dynamic number of inputs or outputs with special flags Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * lavfi: mark filters with dynamic number of inputs or outputs with special flagsAnton Khirnov2013-04-11
| | | | | | | | | | This will be useful in avtools in the following commits. Any other caller might also want to know this information.