summaryrefslogtreecommitdiff
path: root/libavfilter/vf_drawtext.c
Commit message (Collapse)AuthorAgeFilesLines
* lavu/frame: deprecate AVFrame.pkt_{pos,size}Anton Khirnov2023-03-201-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* lavfi: use AVFrame.duration instead of AVFrame.pkt_durationAnton Khirnov2022-07-191-0/+16
|
* lavfi/drawtext: Add %N for drawing fractions of a secondThilo Borgmann2022-03-081-3/+67
| | | | Suggested-By: ffmpeg@fb.com
* avfilter/drawtext: change reload value to an intervalGyan Doshi2022-03-021-3/+3
| | | | Allows user to specify a frame interval at which textfile is reloaded.
* 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: Replace AVFilterPad.needs_writable by flagsAndreas Rheinhardt2021-08-171-1/+1
| | | | | | | It will be useful in the future when more flags are added. Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavfi/vf_drawtext.c: fix CID 1485003Ting Fu2021-06-091-1/+1
| | | | | | | CID 1485003: Memory - illegal accesses (UNINIT) Using uninitialized value "sd". Signed-off-by: Ting Fu <ting.fu@intel.com>
* libavfilter: vf_drawtext filter support draw text with detection bounding ↵Ting Fu2021-05-261-6/+71
| | | | | | | | | | | | | | | boxes in side_data This feature can be used with dnn detection by setting vf_drawtext's option text_source=side_data_detection_bboxes, for example: ./ffmpeg -i face.jpeg -vf dnn_detect=dnn_backend=openvino:model=face-detection-adas-0001.xml:\ input=data:output=detection_out:labels=face-detection-adas-0001.label,drawbox=box_source= side_data_detection_bboxes,drawtext=text_source=side_data_detection_bboxes:fontcolor=green:\ fontsize=40, -y face_detect.jpeg Please note, the default fontsize of vf_drawtext is 12, which may be too small to be seen clearly. Signed-off-by: Ting Fu <ting.fu@intel.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/drawtext: ignore final LF of textfile.Nicolas George2021-02-171-5/+7
| | | | | | | | | | A standard text file ends with a final LF. Without this change, it is interpreted as an empty final line, and visible with the box option. The current behavior can be achieved by actually having an empty line at the end of the file. Fix trac ticket #7948.
* avfilter/vf_drawtext: only test available exceptionsRosen Penev2020-04-091-0/+2
| | | | | | | | soft float systems do not define these macros under musl. Fixes: Ticket7102 Signed-off-by: Rosen Penev <rosenp@gmail.com>
* remove CHAR_MIN/CHAR_MAX usagePaul B Mahol2020-03-171-12/+12
| | | | It is not needed at all.
* avfilter/vf_drawtext: do not overread text if the last UTF8 sequence is invalidMarton Balint2020-01-311-3/+3
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avfilter/vf_drawtext: use replacement chars for invalid UTF8 sequencesMarton Balint2020-01-311-3/+6
| | | | | | | continue is explicitly disallowed for GET_UTF8, so let's fix that as well. Fixes crash with invalid UTF8 sequences. Signed-off-by: Marton Balint <cus@passwd.hu>
* avfilter/drawtext: log why input pad failed to be configuredGyan Doshi2019-12-241-5/+7
|
* vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variablesCalvin Walton2019-07-071-0/+9
| | | | | | | | | | | Changes to vf_drawtext.c written by Calvin Walton <calvin.walton@kepstin.ca> Changes to filters.texi written by greg Luce <electron.rotoscope@gmail.com> with lots of help from Moritz Barsnick and Gyan Fixes #7947.
* avfilter/drawtext: stop resource leakGyan Doshi2019-05-161-2/+2
| | | | Fixes Coverity CID 1445099
* avfilter/drawtext: make command processing error-resilientGyan Doshi2019-05-131-9/+38
| | | | | Prevents crash or interruption in text rendering if new option string contains invalid values.
* avfilter/drawtext: fix box sizingGyan Doshi2018-07-131-2/+2
| | | | | | | | | At present, box size is clipped to frame size before being drawn, which can lead to the box not fully covering animated text which is longer than one or both frame dimensions. Since ff_blend_rectangle correctly takes care of clipping, it is skipped here which results in correct box sizing
* avfilter/drawtext: present 'hms' formatted 'pts' in 24h formatVishwanath Dixit2018-06-041-0/+8
| | | | | | | | | | | | HMS is formatted as HH:MM:SS.mmm, but, HH part is not limited to 24 hours. For example, the the drawn text may look like this: 243029:20:30.342. To present the timestamp in more readable and user friendly format, this patch provides an additional option to limit the hour part in the range 0-23. Note: Actually the above required format can be obtained with format options 'localtime' and 'gmtime', but, milliseconds part is not supported in those formats.
* 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/drawtext - implement fix_boundsGyan Doshi2018-01-201-1/+27
| | | | | | | | | | | When enabled, text, including effects like shadow or box, will be completely bound within the video frame. Default value changed to false to keep continuity of behaviour. Fixes #6960. Signed-off-by: Kyle Swanson <k@ylo.ph>
* 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/vf_drawtext: added expr evaluation to drawtext fontsizeBrett Harrison2017-04-191-17/+116
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* Merge commit '85baef4ff1512bcc2544928bfa5f42072903a691'Clément Bœsch2017-03-291-2/+1
|\ | | | | | | | | | | | | | | | | | | | | * commit '85baef4ff1512bcc2544928bfa5f42072903a691': vf_drawtext: Move static keyword to beginning of variable declaration This commit is mostly a noop, see: d9e2aceb7f1c712a52672129ca7971872b030e1e 6d7aa437e1108dd8142ae5b850a00c109f95f07f Merged-by: Clément Bœsch <u@pkh.me>
| * vf_drawtext: Move static keyword to beginning of variable declarationDiego Biurrun2016-11-021-3/+2
| | | | | | | | libavfilter/vf_drawtext.c:226:1: warning: ‘static’ is not at beginning of declaration [-Wold-style-declaration]
| * drawtext: Move the strftime expansion in a separate functionLuca Barbato2015-08-021-17/+29
| | | | | | | | Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
| * drawtext: Drop stray guardsLuca Barbato2015-08-021-5/+1
| | | | | | | | | | | | There is a fallback for localtime_r and it is in use already. Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
* | vf_drawtext: Fix memory leakKieran Kunhya2017-03-211-2/+4
| |
* | avfilter:vf_drawtext: add new line space size set parameterSteven Liu2017-01-191-1/+3
| | | | | | | | | | | | | | | | add line_spacing parameter to set the space between two lines Based on an idea by: Leandro Santiago <leandrosansilva@gmail.com> Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* | lavfi: split frame_count between input and output.Nicolas George2016-11-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | 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_drawtext: fixed default/flt formatting ignoring offset parameterAlex Agranovsky2016-11-061-1/+1
| | | | | | | | | | Signed-off-by: Alex Agranovsky <alex@sighthound.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avfilter/drawutils: allow drawing opaque text on transparent backgroundPaul B Mahol2016-09-211-1/+1
| | | | | | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* | avfilter/vf_drawtext: Check return code of load_glyph()Michael Niedermayer2016-04-241-1/+3
| | | | | | | | | | | | | | Fixes segfault Fixes Ticket5347 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avfilter/vf_drawtext: add optional default value to metadata functionTobias Rapp2016-04-131-1/+3
| | | | | | | | Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
* | lavfi/drawtext: Fix microsecond display.Carl Eugen Hoyos2016-01-031-1/+1
| | | | | | | | Fixes ticket #4792.
* | lavfi/vf_drawtext: replace round by llrintGanesh Ajjanagadde2015-12-211-1/+1
| | | | | | | | | | | | llrint is at least as fast, and avoids an implicit cast. Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* | lavfi/drawtext: fix shadow[xy] descriptionsClément Bœsch2015-12-211-2/+2
| |
* | lavfi/drawtext: hide first font load warning when fontconfig is presentClément Bœsch2015-12-211-0/+2
| |
* | lavfi/drawtext: fix crash when no text, file or timecode providedClément Bœsch2015-12-211-6/+6
| |
* | avutil/tree: add additional const qualifier to the comparatorGanesh Ajjanagadde2015-10-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | libc's qsort comparator has a const qualifier on both arguments. This adds a missing const qualifier to exactly match the comparator API. Existing usages of av_tree_find, av_tree_insert are appropriately modified: type signature changes of the comparators, and removal of unnecessary void * casts of function pointers. Reviewed-by: Henrik Gramner <henrik@gramner.com> Reviewed-by: wm4 <nfxjfg@googlemail.com> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* | all: remove some casts of function pointer to void *Ganesh Ajjanagadde2015-10-241-1/+1
| | | | | | | | | | | | | | | | | | | | These casts are unnecessary, and may safely be removed. Found by enabling -Wpedantic on clang 3.7. Tested with FATE. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* | avfilter/drawtext: allow to format pts with strftimeAlex Agranovsky2015-10-121-1/+11
| | | | | | | | Signed-off-by: Alex Agranovsky <alex@sighthound.com>
* | avfilter/drawtext: use AV_OPT_TYPE_BOOL for a few optionsClément Bœsch2015-09-081-5/+5
| |
* | Merge commit '9b2c57bef5e2f3f61a5fd708ba7d5351f5b3f386'Michael Niedermayer2015-04-211-5/+46
|\ \ | |/ | | | | | | | | | | | | | | | | | | * commit '9b2c57bef5e2f3f61a5fd708ba7d5351f5b3f386': drawtext: Add an alpha option Conflicts: doc/filters.texi libavfilter/vf_drawtext.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * drawtext: Add an alpha optionLuca Barbato2015-04-211-10/+38
| | | | | | | | | | | | And document both `draw` and `alpha`. Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
| * 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.
| * lavfi: Increase drawtext font size limitsМихаил Муковников2014-12-071-1/+1
| | | | | | | | | | | | Raise the maximum font size to a larger value. Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
* | avfilter/drawtext: fix frame mem leakIvan Efimov2015-04-141-2/+6
| | | | | | | | | | Signed-off-by: Ivan Efimov <ioefimov@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>