summaryrefslogtreecommitdiff
path: root/libavfilter/vf_overlay.c
Commit message (Collapse)AuthorAgeFilesLines
* lavu/frame: deprecate AVFrame.pkt_{pos,size}Anton Khirnov2023-03-201-4/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | These fields are supposed to store information about the packet the frame was decoded from, specifically the byte offset it was stored at and its size. However, - the fields are highly ad-hoc - there is no strong reason why specifically those (and not any other) packet properties should have a dedicated field in AVFrame; unlike e.g. the timestamps, there is no fundamental link between coded packet offset/size and decoded frames - they only make sense for frames produced by decoding demuxed packets, and even then it is not always the case that the encoded data was stored in the file as a contiguous sequence of bytes (in order for pos to be well-defined) - pkt_pos was added without much explanation, apparently to allow passthrough of this information through lavfi in order to handle byte seeking in ffplay. That is now implemented using arbitrary user data passthrough in AVFrame.opaque_ref. - several filters use pkt_pos as a variable available to user-supplied expressions, but there seems to be no established motivation for using them. - pkt_size was added for use in ffprobe, but that too is now handled without using this field. Additonally, the values of this field produced by libavcodec are flawed, as described in the previous ffprobe conversion commit. In summary - these fields are ill-defined and insufficiently motivated, so deprecate them.
* all: Replace if (ARCH_FOO) checks by #if ARCH_FOOAndreas Rheinhardt2022-06-151-3/+4
| | | | | | | | | | | | | | | | | | 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>
* avfilter/vf_overlay: improve premultiplied alpha overlay for YUVPaul B Mahol2022-05-011-2/+3
|
* avfilter/vf_overlay: unbreak alpha composition with negative y and threads > 1Paul B Mahol2021-10-141-7/+8
|
* avfilter: Replace query_formats callback with union of list and callbackAndreas Rheinhardt2021-10-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* avfilter/avfilter: Add numbers of (in|out)pads directly to AVFilterAndreas Rheinhardt2021-08-201-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/internal: Factor out executing a filter's execute_funcAndreas Rheinhardt2021-08-151-2/+2
| | | | | | | The current way of doing it involves writing the ctx parameter twice. 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-131-1/+1
| | | | | | | | | | | 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-271-1/+1
| | | | | | | 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>
* lavfi: regroup formats lists in a single structure.Nicolas George2020-09-081-3/+3
| | | | | | | | | | | | | | | 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/*(.)
* avfilter/vf_overlay: Fix double-free of AVFilterFormats on errorAndreas Rheinhardt2020-08-231-61/+23
| | | | | | | | | | | | | | | | | | | | | | | | | The query_formats function of the overlay filter tries to allocate two lists (only one in a special case) of formats which on success are attached to more permanent objects (AVFilterLinks) for storage afterwards. If attaching a list to an AVFilterLink succeeds, it is in turn owned by the AVFilterLink (or more exactly, the AVFilterLink becomes one of the common owners of the list). Yet if attaching a list to one of its links succeeds and an error happens lateron, both lists were manually freed, whic is wrong if the list is already owned by one or more links; these links' pointers to their lists will become dangling and there will be a double-free/use-after-free when these links are cleaned up automatically. This commit fixes this by removing the custom freeing code; this will temporarily add a leaking codepath (if attaching a list not already owned by a link to a link fails, the list will leak), but this will be fixed soon by making sure that an AVFilterFormats without owner will be automatically freed when attaching it to an AVFilterLink fails. Notice that at most one list leaks because a new list is only allocated after the old list has been successfully attached to a link. Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avfilter/vf_overlay: Remove superfluous ;Andreas Rheinhardt2020-08-211-6/+6
| | | | | | | | | | | | | | | | In a function body, a redundant ; is just a null statement that does nothing. Yet outside a function body, a superfluous ';' like one that exists if one adds a ';' immediately after a function body's closing brace is actually invalid C that compilers happen to accept. Yet when compiled in -pedantic mode, both GCC as well as Clang emit warnings for this like "ISO C does not allow extra ‘;’ outside of a function [-Wpedantic]". The scenario described above existed in vf_overlay.c as a result of macro expansion. This commit fixes it. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avfilter/vf_overlay: add yuv420p10 and yuv422p10 10bit format supportLimin Wang2020-06-191-0/+79
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avfilter/vf_overlay: support for 8bit and 10bit overlay with macro-based ↵Limin Wang2020-06-191-197/+220
| | | | | | function Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* remove CHAR_MIN/CHAR_MAX usagePaul B Mahol2020-03-171-2/+2
| | | | It is not needed at all.
* avfilter/vf_overlay: fix filtering with negative yPaul B Mahol2018-12-031-16/+16
|
* avfilter/vf_overlay: fix crash with negative yPaul B Mahol2018-11-201-4/+4
|
* avfilter/vf_overlay: exclude nv12/nv21 formats from x86 asm checkPaul B Mahol2018-05-031-1/+2
| | | | | | They are yet to be supported, Signed-off-by: Paul B Mahol <onemda@gmail.com>
* avfilter/vf_overlay: add x86 SIMDPaul B Mahol2018-05-021-56/+19
| | | | | | | Specifically for yuv444, yuv422, yuv420 format when main stream has no alpha, and alpha is straight. Signed-off-by: Paul B Mahol <onemda@gmail.com>
* avfilter/vf_overlay: use slice_end in alpha_composite()Paul B Mahol2018-04-291-1/+1
| | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* avfilter/vf_overlay: add slice threadingPaul B Mahol2018-04-281-91/+191
| | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* avfilter: add comments for duplicate lineSteven Liu2018-02-011-0/+1
| | | | | | | | | comment about the looks like a duplicate line. but that is used to reason x is expressed from y Suggested-by: Paul B Mahol Suggested-by: Michael Niedermayer Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avfilter/vf_overlay: fix packed_rgb caseMateusz2017-12-181-7/+10
| | | | Signed-off-by: Mateusz Brzostek <mateuszb@poczta.onet.pl>
* avfilter/vf_overlay: add premultiplied alpha modePaul B Mahol2017-12-161-25/+137
| | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* lavfi: rename framesync2 to framesync.Nicolas George2017-09-121-6/+6
|
* avfilter/vf_overlay: Restore shorthand option orderMichael Niedermayer2017-09-051-0/+8
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavfi/vf_overlay: use framesync2 options.Nicolas George2017-08-291-41/+4
|
* lavfi/vf_overlay: move to framesync2.Nicolas George2017-08-291-32/+38
|
* avfilter/vf_overlay: fix alpha blending for planar formats with a ↵Marton Balint2017-08-101-12/+16
| | | | | | | | | | | | | | | | transparent background When the background had an alpha channel, the old code in blend_plane calculated premultiplied alpha from the destination plane colors instead of the destination alpha. Also the calculation of the output alpha should only happen after the color planes are already finished. Fixes output of: ffplay -f lavfi "testsrc2=alpha=32[a];color=black[b];[b][a]overlay[out0]" Signed-off-by: Marton Balint <cus@passwd.hu>
* avfilter/vf_overlay: separate functions with main alphaPaul B Mahol2017-06-251-25/+46
| | | | | | ~5-15% faster overall with main input without alpha. Signed-off-by: Paul B Mahol <onemda@gmail.com>
* avfilter/vf_overlay: remove rgb optionPaul B Mahol2017-06-241-7/+0
| | | | | | Its been deprecated for over 3 years. Signed-off-by: Paul B Mahol <onemda@gmail.com>
* avfilter/vf_overlay: add auto format modePaul B Mahol2017-06-241-9/+48
| | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* avfilter: do not use AVFrame accessorMuhammad Faiz2017-04-231-1/+1
| | | | | Reviewed-by: wm4 <nfxjfg@googlemail.com> Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
* avfilter/overlay: add gbrp output formatPaul B Mahol2017-01-311-10/+61
| | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* lavfi: split frame_count between input and output.Nicolas George2016-11-131-1/+1
| | | | | | | | | | | | AVFilterLink.frame_count is supposed to count the number of frames that were passed on the link, but with min_samples, that number is not always the same for the source and destination filters. With the addition of a FIFO on the link, the difference will become more significant. Split the variable in two: frame_count_in counts the number of frames that entered the link, frame_count_out counts the number of frames that were sent to the destination filter.
* lavfi/vf_overlay: support NV12 and NV21Rodger Combs2016-10-261-5/+17
| | | | Tested-by: Michael on x86-32/64 linux, mingw, mips/arm qemu linux
* avfilter/vf_overlay: add YUVA422P to alpha_pix_fmtsPaul B Mahol2016-09-171-1/+1
| | | | | | Now yuv422 output format gives similar expected output as other output formats. Signed-off-by: Paul B Mahol <onemda@gmail.com>
* avfilter/vf_overlay: support J formats tooPaul B Mahol2016-09-171-3/+3
| | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* avfilter/vf_overlay: inline yuv output formatsPaul B Mahol2016-09-111-104/+147
| | | | | | Overall speedup ~10-20% Tested-by: Michael on mingw32 mingw64 linux32 mips and arm
* avfilter/vf_overlay: split blend_image into functions for each overlay formatPaul B Mahol2016-09-111-166/+186
| | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* Merge commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb'Clément Bœsch2016-06-211-1/+1
|\ | | | | | | | | | | | | * commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb': cosmetics: Fix spelling mistakes Merged-by: Clément Bœsch <u@pkh.me>
| * cosmetics: Fix spelling mistakesVittorio Giovara2016-05-041-1/+1
| | | | | | | | Signed-off-by: Diego Biurrun <diego@biurrun.de>
* | avutil: Rename FF_CEIL_COMPAT to AV_CEIL_COMPATDerek Buitenhuis2016-01-271-4/+4
| | | | | | | | | | | | | | | | | | | | 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>
* | vf_overlay: handles expression evaluation of frame size change in ↵Bela Bodecs2016-01-191-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | frame-by-frame evalutaion mode vf_overlay video filter accepts expressions in its parameters. In 'frame-by-frame' evaluation mode it recalculates them regularly, but incoming video frame size changes did not reflect in their values. So if you used width or height of any source videos in expressions as parameters, they stayed on their initial values. This patch corrects this bug. Signed-off-by: Bela Bodecs <bodecsb@vivanet.hu> Reviewed-by: Paul B Mahol <onemda@gmail.com Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | lavfi/vf_overlay: fix unitialized pointersGanesh Ajjanagadde2015-12-101-2/+2
| | | | | | | | | | | | | | Missed in commit 301c2784b35036945cd9a7049808deecce149916. Found-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* | lavfi/vf_overlay: fix memory leaksGanesh Ajjanagadde2015-12-091-9/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 1338327. Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* | avfilter/all: propagate errors of functions from avfilter/formatsGanesh Ajjanagadde2015-10-141-11/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/overlay: use AV_OPT_TYPE_BOOL for rgb, shortest and repeatlast optionsClément Bœsch2015-09-091-3/+3
| |
* | avfilter/vf_overlay: Change enums to int, which are accessed via AVOption as intMichael Niedermayer2015-03-201-3/+17
| | | | | | | | | | | | This fixes depending on implementation defined behavior Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Add missing "const" all over the place.Reimar Döffinger2014-08-291-1/+1
| | | | | | | | | | | | Only "./configure --enable-gpl" on x86 was tested. Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>