summaryrefslogtreecommitdiff
path: root/libavfilter/vf_delogo.c
Commit message (Collapse)AuthorAge
* avfilter: Reindentation after query_formats changesAndreas Rheinhardt2021-10-05
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avfilter/vf_delogo: 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>
* 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/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: add D2TS, TS2D, TS2T as a common macro in internal.hLimin Wang2020-06-19
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avfilter/delogo: correct indentation for option show.Gyan Doshi2020-04-11
|
* avfilter/delogo: remove deprecated optionsGyan Doshi2020-04-11
| | | | Deprecated in 2015 in 8bc708fcee1
* remove CHAR_MIN/CHAR_MAX usagePaul B Mahol2020-03-17
| | | | It is not needed at all.
* avfilter/vf_delogo: make the interp value compute method simpleSteven Liu2019-10-10
| | | | | | | because the interp >= 0UL comparison of an unsigned value is always true fix CID: 1454642 Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avfilter/vf_delogo: add auto set the area inside of the frameSteven Liu2019-10-10
| | | | | | | when the area outside of the frame, then use expr should give user warning message and auto set to the area inside of the frame. Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avfilter: add av_cold where it is missingPaul B Mahol2019-10-03
|
* avfilter/vf_delogo: unbreak fatePaul B Mahol2019-09-02
| | | | | | | | | It is not clear what was real intention of previous commit to this filter. It was not working correctly, hopefully this is fixed now. It never checked that new x/y/w/h are actually valid, hopeffully this is fixed now. It uses named variables in expressions that are never set, still not fixed. It does not set named variables that uses actual frame widht/height, making actual expressions less usable for our users, still now fixed.
* avfilter/vf_delogo: support expr in delogo filterSteven Liu2019-09-02
| | | | Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avfilter/delogo: Check that logo area is inside the pictureJean Delvare2016-05-10
| | | | | | | | | | | We can only remove the logo if it is inside the picture. We need at least one pixel around the logo area for interpolation. Fixes ticket #5527 (Delogo crash with x=0 and/or y=0). Signed-off-by: Jean Delvare <jdelvare@suse.com> Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avutil: Rename FF_CEIL_COMPAT to AV_CEIL_COMPATDerek Buitenhuis2016-01-27
| | | | | | | | | | 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>
* avfilter/vf_delogo: change the definition of logo_x2 and logo_y2Jean Delvare2015-12-19
| | | | | | | | | In the code we keep using logo_x2-1 and logo_y2-1 rather than logo_x2 and logo_y2 themselves. Define them to be what we need instead, to avoid the repeated subtractions. Signed-off-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avfilter/vf_delogo: fix show option when clippingJean Delvare2015-12-14
| | | | | | | | The show option did not take clipping into account, so the borders on the clipped side wouldn't show up. Fix it. Signed-off-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avfilter/vf_delogo: Use AVPixFmtDescriptor.nb_componentsJean Delvare2015-12-12
| | | | | | | | | Relying on AVPixFmtDescriptor.nb_components is cleaner and faster than checking data and linesize for every possible plane. Signed-off-by: Jean Delvare <jdelvare@suse.de> Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avfilter/vf_delogo: round to the closest valueJean Delvare2015-12-09
| | | | | | | | | | | | | When the interpolated value is divided by the sum of weights, no rounding is done, which means the value is truncated. This results in a slight bias towards dark green in the interpolated area. Rounding properly removes the bias. I measured this change to reduce the interpolation error by 1 to 2 % on average on a number of sample input and logo area combinations. Signed-off-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avfilter/delogo: Set default band to 1Jean Delvare2015-10-08
| | | | | | | | | | | | | | | | | | | | | | | | | | The original interpolation algorithm behaved poorly on the borders and did not even guarantee continuity at the borders. For this reason, a second interpolation/blending pass was required on the borders to make them seamless. However, since the interpolation algorithm was improved in June 2013, the border issues no longer exist. The new algorithm does guarantee continuity at the borders, making the second pass useless. A larger band always increases the cumulated interpolation error. In most cases it also increases the average interpolation error, even though the samples in the band are only partially interpolated. For this reason I would like to get rid of the "band" parameter. As a first step, let's change its default value from 4 to 1 and document it as deprecated. I have benchmarked this change on a combination of input sources and realistic logo areas. Lowering the band value from 4 to 1 resulted in 8 to 39 % less interpolation error per frame (or 1 to 34 % less interpolation error per luma sample.) Signed-off-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Stefano Sabatini <stefasab@gmail.com>
* avfilter/delogo: Fix show option when band is smallJean Delvare2015-09-28
| | | | | | | | | | | | | | | | | | The code assumed that the outermost interpolated pixels were always in the fuzzy area defined by the band option. However if the band value is small, there may be no fuzzy area on a given plane. In that case, option show did not work, no rectangle was drawn (or only on the luma plane, depending on the band value and chroma plane subsampling factors.) Fix the problem by not making any assumption on where the outermost interpolated pixels will be. The new code was verified to produce the same result as the original code when the band value is not small. Signed-off-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* Update my email addressJean Delvare2015-09-22
| | | | | | My old address no longer works. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avfilter/delogo: use AV_OPT_TYPE_BOOL for show optionClément Bœsch2015-09-08
|
* avfilter: handle error in query_formats() of a bunch of random video filtersClément Bœsch2015-03-16
|
* Merge commit '58400ac133bcfb6bf8196b4e5208bc178307739b'Michael Niedermayer2014-04-19
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
| * lavfi: name anonymous structsVittorio Giovara2014-04-19
| |
* | 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>
* | avfilter: remove redundant .get_(audio/video)_buffer initializationsPaul B Mahol2013-09-07
| | | | | | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* | avfilter: fix plane validity checksMichael Niedermayer2013-08-03
| | | | | | | | | | | | Fixes out of array accesses Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | lavfi/delogo: Fix sign extension issueJean Delvare2013-07-13
| | | | | | | | | | | | | | | | | | | | | | | | Coverity complains about a possible sign extension issue in apply_delogo(). While it is extremely unlikely to happen, it is easy to fix so let's just do that. Using unsigned variables even makes the binary code smaller. Fixes Coverity CID 1046439. Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | lavfi/delogo: band width must be at least 1Jean Delvare2013-07-05
| | | | | | | | | | | | | | | | | | | | We need at least one pixel around the logo to use as known points to interpolate from. So properly declare the band/t attribute has having a minimum value of 1. Signed-off-by: Jean Delvare <khali@linux-fr.org> Reviewed-by: Stefano Sabatini <stefasab@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | lavfi/delogo: option show shouldn't affect bandJean Delvare2013-07-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Options "show" and "band" are unrelated and should thus be independent. However, setting "show" to 1 currently resets "band" to its default value of 4. While this is documented, this still surprising and confusing IMHO. Change this behavior and make "show" and "band" independent from each other. Update the documentation accordingly. Signed-off-by: Jean Delvare <khali@linux-fr.org> Reviewed-by: Stefano Sabatini <stefasab@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | lavfi/delogo: remember left and right samples when interpolatingJean Delvare2013-07-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The left and right samples are the same for the whole line, so store their values and don't recompute them for every iteration of "y". This simple optimization results in a speed improvement between 15% and 20% in my tests (depending on the logo geometry.) Result is obviously the same. Signed-off-by: Jean Delvare <khali@linux-fr.org> Reviewed-by: Stefano Sabatini <stefasab@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | lavfi/delogo: don't recompute the same difference again and againJean Delvare2013-07-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The top left hand corner pixel coordinates are already stored in logo_x1 and logo_y1 so don't recompute each of them 6 times for every iteration. This is a simple code optimization, result is obviously the same. The performance gain is small (about 2% in my tests) but still good to have, and the new code is clearer. Signed-off-by: Jean Delvare <khali@linux-fr.org> Reviewed-by; Stefano Sabatini <stefasab@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | lavfi/delogo: avoid propagation of rounding errors in chroma planesJean Delvare2013-07-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When operating on subsampled chroma planes, some rounding is taking place. The left and top borders are rounded down while the width and height are rounded up, so all rounding is done outward to guarantee the logo area is fully covered. The problem is that the width and height are counted from the unrounded left and top borders, respectively. So if the left or top border position has indeed been rounded down, and the width or height needs no rounding (up), the position of the the right or bottom border will be effectively rounded down, i.e. inward. The issue can easily be seen with a yuv240p input and -vf delogo=45:45:60:40:show=1 -vframes 1 delogo-bug.png (or virtually any logo area with odd x and y and even width and height.) The right and bottom chroma borders (in green) are clearly off. In order to fix this, the width and height must be adjusted to include the bits lost in the rounding of the left and top border positions, respectively, prior to being themselves rounded up. Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | lavfi/delogo: take SAR into accountJean Delvare2013-07-03
| | | | | | | | | | | | | | | | | | | | | | When interpolating, weights are based on relative distances, which assume square pixels. If a non-1:1 sample aspect ratio is used, it should be taken into account when comparing distances, because the human eye and brain care about the picture as it is displayed, not stored. Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | lavfi/delogo: use weighted interpolationJean Delvare2013-07-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The original delogo algorithm interpolates both horizontally and vertically and uses the average to compute the resulting sample. This works reasonably well when the logo area is almost square. However when the logo area is significantly larger than high or higher than large, the result is largely suboptimal. The issue can be clearly seen by testing the delogo filter with a fake logo area that is 200 pixels large and 2 pixels high. Vertical interpolation gives a very good result in that case, horizontal interpolation gives a very bad result, and the overall result is poor, because both are given the same weight. Even when the logo is roughly square, the current algorithm gives poor results on the borders of the logo area, because it always gives horizontal and vertical interpolations an equal weight, and this is suboptimal on borders. For example, in the middle of the left hand side border of the logo, you want to trust the left known point much more than the right known point (which the current algorithm already does) but also much more than the top and bottom known points (which the current algorithm doesn't do.) By properly weighting each known point when computing the value of each interpolated pixel, the visual result is much better, especially on borders and/or for high or large logo areas. The algorithm I implemented guarantees that the weight of each of the 4 known points directly depends on its distance to the interpolated point. It is largely inspired from the original algorithm, the key difference being that it computes the relative weights globally instead of separating the vertical and horizontal interpolations and combining them afterward. Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Stefano Sabatini <stefasab@gmail.com>
* | delogo: Fix function descriptionJean Delvare2013-06-19
| | | | | | | | | | | | | | | | The algorithm works on src and writes to dst, not the other way around. Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit 'ba09675f44612fad9f7169f71b8276beb50a0dcd'Michael Niedermayer2013-05-16
|\| | | | | | | | | | | | | | | | | | | | | | | * commit 'ba09675f44612fad9f7169f71b8276beb50a0dcd': vf_delogo: use the name 's' for the pointer to the private context vf_cropdetect: use the name 's' for the pointer to the private context vf_crop: cosmetics, break lines Conflicts: libavfilter/vf_delogo.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * vf_delogo: use the name 's' for the pointer to the private contextAnton Khirnov2013-05-16
| | | | | | | | This is shorter and consistent across filters.
| * lavfi: remove now unused args parameter from AVFilter.initAnton Khirnov2013-04-09
| |
* | lavfi: replace passthrough_filter_frame with a flag.Clément Bœsch2013-05-12
| | | | | | | | | | | | | | | | | | | | With the introduction of AVFilterContext->is_disabled, we can simplify the custom passthrough mode in filters. This commit is technically a small compat break, but the timeline was introduced very recently. Doxy by Stefano Sabatini.
* | lavfi: use ceil right shift for chroma width/height.Clément Bœsch2013-05-10
| | | | | | | | | | | | | | This should fix several issues with odd dimensions inputs. lut, vflip, pad and crop video filters also need to be checked for such issues. It's possible sws is also affected.
* | lavfi: add timeline support in {de,remove}logo.Clément Bœsch2013-04-24
| | | | | | | | Both don't change anything in the context between frames.
* | lavfi: remove now unused args parameter from AVFilter.initAnton Khirnov2013-04-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge commit '63e58c55c17d7f8b5eec9c082fe0f8edc305a24e'Michael Niedermayer2013-04-10
|\| | | | | | | | | | | | | | | | | | | * commit '63e58c55c17d7f8b5eec9c082fe0f8edc305a24e': vf_delogo: switch to an AVOptions-based system. Conflicts: libavfilter/vf_delogo.c Merged-by: Michael Niedermayer <michaelni@gmx.at>