summaryrefslogtreecommitdiff
path: root/libavfilter/vf_crop.c
Commit message (Collapse)AuthorAgeFilesLines
* lavu/frame: deprecate AVFrame.pkt_{pos,size}Anton Khirnov2023-03-201-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* 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/formats: Make ff_formats_pixdesc_filter return AVFilterFormats*Andreas Rheinhardt2021-09-261-6/+2
| | | | | | | | | | | | | | | | Up until now, it has returned the AVFilterFormats list via an AVFilterFormats** parameter; the actual return value was an int that was always AVERROR(ENOMEM) on error. The AVFilterFormats** argument was a pure output parameter which was only documented by naming the parameter rfmts. Yet nevertheless all callers initialized the underlying AVFilterFormats* to NULL. This commit changes this to return a pointer to AVFilterFormats directly. This is more in line with the API in general, as it allows to avoid checks for intermediate values. 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: 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>
* avutil/pixdesc: Remove deprecated AV_PIX_FMT_FLAG_PSEUDOPALAndreas Rheinhardt2021-04-271-1/+1
| | | | | | | Deprecated in d6fc031caf64eed921bbdef86d79d56bfc2633b0. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* lavfi/vf_crop: use ff_formats_pixdesc_filter().Nicolas George2020-05-231-17/+4
|
* remove CHAR_MIN/CHAR_MAX usagePaul B Mahol2020-03-171-6/+6
| | | | It is not needed at all.
* lavfi/crop: enable runtime change flagJun Zhao2020-01-131-6/+7
| | | | | | enable runtime change flag. Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* avfilter/crop: avoid premature eval errorGyan Doshi2019-12-061-4/+3
| | | | | | Width and height expressions can refer to each other. Width is evaluated twice to allow for reference to output height. So we should not error out upon failure of first evaluation of width.
* avfilter/vf_crop: add logging context to logSteven Liu2019-10-081-1/+1
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* vf_crop: Add support for cropping hardware framesMark Thompson2019-06-021-23/+50
| | | | Set the cropping fields in the AVFrame.
* avutil/pixdesc: deprecate AV_PIX_FMT_FLAG_PSEUDOPALwm42018-04-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PSEUDOPAL pixel formats are not paletted, but carried a palette with the intention of allowing code to treat unpaletted formats as paletted. The palette simply mapped the byte values to the resulting RGB values, making it some sort of LUT for RGB conversion. It was used for 1 byte formats only: RGB4_BYTE, BGR4_BYTE, RGB8, BGR8, GRAY8. The first 4 are awfully obscure, used only by some ancient bitmap formats. The last one, GRAY8, is more common, but its treatment is grossly incorrect. It considers full range GRAY8 only, so GRAY8 coming from typical Y video planes was not mapped to the correct RGB values. This cannot be fixed, because AVFrame.color_range can be freely changed at runtime, and there is nothing to ensure the pseudo palette is updated. Also, nothing actually used the PSEUDOPAL palette data, except xwdenc (trivially changed in the previous commit). All other code had to treat it as a special case, just to ignore or to propagate palette data. In conclusion, this was just a very strange old mechnaism that has no real justification to exist anymore (although it may have been nice and useful in the past). Now it's an artifact that makes the API harder to use: API users who allocate their own pixel data have to be aware that they need to allocate the palette, or FFmpeg will crash on them in _some_ situations. On top of this, there was no API to allocate the pseuo palette outside of av_frame_get_buffer(). This patch not only deprecates AV_PIX_FMT_FLAG_PSEUDOPAL, but also makes the pseudo palette optional. Nothing accesses it anymore, though if it's set, it's propagated. It's still allocated and initialized for compatibility with API users that rely on this feature. But new API users do not need to allocate it. This was an explicit goal of this patch. Most changes replace AV_PIX_FMT_FLAG_PSEUDOPAL with FF_PSEUDOPAL. I first tried #ifdefing all code, but it was a mess. The FF_PSEUDOPAL macro reduces the mess, and still allows defining FF_API_PSEUDOPAL to 0. Passes FATE with FF_API_PSEUDOPAL enabled and disabled. In addition, FATE passes with FF_API_PSEUDOPAL set to 1, but with allocation functions manually changed to not allocating a palette.
* 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: do not use AVFrame accessorMuhammad Faiz2017-04-231-2/+2
| | | | | Reviewed-by: wm4 <nfxjfg@googlemail.com> Signed-off-by: Muhammad Faiz <mfcc64@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.
* avfilter/vf_crop: make possible to do exact cropping for subsampled videosPaul B Mahol2016-08-211-6/+15
|
* lavfi/vf_crop: replace round by lrintGanesh Ajjanagadde2015-12-211-1/+1
| | | | | | | lrint is at least as fast, avoids an implicit cast, and uses a superior rounding mode. Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* avfilter/all: propagate errors of functions from avfilter/formatsGanesh Ajjanagadde2015-10-141-3/+4
| | | | | | | | | | | | | | | | | | 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/crop: use AV_OPT_TYPE_BOOL for keep_aspect optionClément Bœsch2015-09-081-1/+1
|
* libavfilter/vf_crop: implement process_commandBernd Bleßmann2015-07-211-8/+45
| | | | | Signed-off-by: Bernd Bleßmann <bb@it-entwicklung.de> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* Merge commit '1a3eb042c704dea190c644def5b32c9cee8832b8'Michael Niedermayer2015-04-201-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
| * Replace av_dlog with normal av_log at trace levelVittorio Giovara2015-04-191-1/+1
| | | | | | | | This applies to every library where performance is not critical.
* | avfilter: handle error in query_formats() in bunch of filtersPaul B Mahol2015-04-081-2/+1
| | | | | | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* | avfilter/crop: Avoid using non public AV_PIX_FMT_NBMichael Niedermayer2014-05-271-1/+1
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit '58400ac133bcfb6bf8196b4e5208bc178307739b'Michael Niedermayer2014-04-191-1/+1
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-191-1/+1
| |
* | Merge remote-tracking branch 'qatar/master'Michael Niedermayer2013-10-291-1/+1
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-281-1/+1
| |
* | lavfi/pad,crop,scale: remove options description from filter descriptionPaul B Mahol2013-09-211-1/+1
| | | | | | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* | avfilter: various cosmeticsPaul B Mahol2013-09-121-14/+11
| | | | | | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* | avfilter: remove redundant .get_(audio/video)_buffer initializationsPaul B Mahol2013-09-071-1/+0
| | | | | | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* | lavfi/crop: support more pixel formatsPaul B Mahol2013-07-041-27/+10
| | | | | | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* | Merge commit '3fb29588a27a711132106b924e27b53789a58dcb'Michael Niedermayer2013-05-171-0/+3
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | * commit '3fb29588a27a711132106b924e27b53789a58dcb': vf_drawtext: don't leak the expressions. vf_crop: make config_props work properly when called multiple times. vf_setdar: make config_props work properly when called multiple times. Conflicts: libavfilter/vf_aspect.c libavfilter/vf_drawtext.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * vf_crop: make config_props work properly when called multiple times.Anton Khirnov2013-05-171-0/+3
| | | | | | | | Do not leak the x/y expressions.
* | Merge commit 'ba09675f44612fad9f7169f71b8276beb50a0dcd'Michael Niedermayer2013-05-161-3/+7
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | * 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_crop: cosmetics, break linesAnton Khirnov2013-05-161-3/+7
| |
* | Merge commit '7f83959598b6565baa0091e5739dd9091ab7a990'Michael Niedermayer2013-05-161-82/+88
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | * commit '7f83959598b6565baa0091e5739dd9091ab7a990': vf_crop: use the name 's' for the pointer to the private context vf_boxblur: use the name 's' for the pointer to the private context vf_blackframe: use the name 's' for the pointer to the private context Conflicts: libavfilter/vf_blackframe.c libavfilter/vf_boxblur.c libavfilter/vf_crop.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * vf_crop: use the name 's' for the pointer to the private contextAnton Khirnov2013-05-161-73/+79
| | | | | | | | This is shorter and consistent across filters.
* | Merge commit 'b3ea76624ad1baab0b6bcc13f3f856be2f958110'Michael Niedermayer2013-05-161-2/+0
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit 'b3ea76624ad1baab0b6bcc13f3f856be2f958110': vf_aspect: use the name 's' for the pointer to the private context Remove commented-out debug #define cruft Conflicts: libavcodec/4xm.c libavcodec/dvdsubdec.c libavcodec/ituh263dec.c libavcodec/mpeg12.c libavfilter/avfilter.c libavfilter/vf_aspect.c libavfilter/vf_fieldorder.c libavformat/rtmpproto.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * Remove commented-out debug #define cruftDiego Biurrun2013-05-161-2/+0
| |
* | Merge remote-tracking branch 'qatar/master'Michael Niedermayer2013-05-151-1/+1
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
| * pixdesc: rename PIX_FMT_* flags to AV_PIX_FMT_FLAG_*Anton Khirnov2013-05-151-1/+1
| |
* | lavfi: add frame counter into AVFilterLink and use it in filters.Clément Bœsch2013-04-231-2/+1
| |
* | lavfi/crop: log pos in debug messageStefano Sabatini2013-04-121-3/+3
| |
* | lavfi/crop: restore pos constant, and fix "t" variable misplacement in ↵Stefano Sabatini2013-04-121-0/+4
| | | | | | | | | | | | variable array Fix evaluation of expressions containing the t variable.
* | lavfi: remove double .priv_class initializersPaul B Mahol2013-04-111-1/+0
| | | | | | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* | Merge commit 'fba0156af77b11ec99edf4ee8f511b7aaa6b1891'Michael Niedermayer2013-04-101-27/+25
|\ \ | |/ | | | | | | | | | | | | | | | | | | * commit 'fba0156af77b11ec99edf4ee8f511b7aaa6b1891': vf_crop: switch to an AVOptions-based system. Conflicts: doc/filters.texi libavfilter/vf_crop.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * vf_crop: switch to an AVOptions-based system.Anton Khirnov2013-04-091-17/+23
| |
* | lavfi/vf_crop: use standard options parsing.Nicolas George2013-03-201-13/+3
| |