summaryrefslogtreecommitdiff
path: root/libavfilter/vf_colorspace.c
Commit message (Collapse)AuthorAge
* 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/internal: Factor out executing a filter's execute_funcAndreas Rheinhardt2021-08-15
| | | | | | | 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: 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>
* lavu/mem: move the DECLARE_ALIGNED macro family to mem_internal on next+1 bumpAnton Khirnov2021-01-01
| | | | They are not properly namespaced and not intended for public use.
* vf_colorspace: Added linear trc.Andrew Klaassen2020-09-27
| | | | | | | | This patch adds the coefficients for the linear gamma function (1,0,1,0) to the colorspace filter. Signed-off-by: Andrew Klaassen <clawsoon@yahoo.com> Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
* lavfi: regroup formats lists in a single structure.Nicolas George2020-09-08
| | | | | | | | | | | | | | | 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_colorspace: fix memmory leaksPaul B Mahol2019-10-18
| | | | Fixes #8303
* lavfi/colorspace: typedef ThreadData as all other filtersJun Zhao2019-10-10
| | | | | | | typedef ThreadData as all other filters. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* avfilter: add av_cold where it is missingPaul B Mahol2019-10-03
|
* avfilter: Support EBU Tech. 3213-E primaries valuesRaphaël Zumer2019-09-01
| | | | | Signed-off-by: Raphaël Zumer <rzumer@tebako.net> Signed-off-by: James Almer <jamrial@gmail.com>
* libavfilter/vf_colorspace.c: fix demarcation point of gamma linearize functionYonglin Luo2019-07-03
| | | | | | | | | | | | | | | | The linearize function (usually refered to EOTF) is the inverse of delinearize function (usually referred to OETF). Demarcation point of EOTF should be beta*delta, but the actual value used now in the source code is beta. For ITU Rec.709, they are 0.081 (0.018*4.5) and 0.018 respectively (beta = 0.018 and delta = 4.5), and they correspond to pixel value 5 and 21 for an 8-bit image. Linearized result of pixel within that range (5-21) will be different, but this commit will make linearize function of the filter more accurate in the mathematical sense. Signed-off-by: Yonglin Luo <vincenluo@tencent.com> Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
* lavfi/colorspace: move some functions to common fileRuiling Song2019-03-22
| | | | | | | These functions can be reused by other colorspace filters, so move them to common file. No functional changes. Signed-off-by: Ruiling Song <ruiling.song@intel.com>
* avfilter/vf_colorspace: fix typo in commentPaul B Mahol2018-09-17
|
* lavfi/colorspace: Add namespace prefix to global functionsMark Thompson2018-06-28
|
* lavfi: make vf_colorspace use functions from colorspace.cRuiling Song2018-06-21
| | | | | | These functions are shared among colorspace related filters. Signed-off-by: Ruiling Song <ruiling.song@intel.com>
* vf_colorspace: Add a pixdesc API alias name for bt2020nc color spaceVittorio Giovara2017-06-09
|
* vf_colorspace: Add support for jedec p22 primariesVittorio Giovara2017-06-07
| | | | Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
* vf_colorspace: Add support for smpte248 color primariesVittorio Giovara2017-06-07
|
* vf_colorspace: Add support for gbr color spaceVittorio Giovara2017-06-06
| | | | Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
* vf_colorspace: Forbid odd dimensionsVittorio Giovara2016-11-28
| | | | | | This prevents writing past bounds. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
* vf_colorspace: Add support for film primariesVittorio Giovara2016-11-01
| | | | | Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com> Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
* vf_colorspace: Add support for smpte 431/432 (dci/display p3) primariesVittorio Giovara2016-11-01
| | | | | Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com> Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
* vf_colorspace: Add support for ycgco color spaceVittorio Giovara2016-11-01
| | | | | Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com> Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
* vf_colorspace: Add support for iec61966-2.4 (xvYCC) transferVittorio Giovara2016-10-31
| | | | | | Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com> Reviewed-by: "Ronald S. Bultje" <rsbultje@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* vf_colorspace: Add support for iec61966-2.1 (sRGB) transferVittorio Giovara2016-10-24
| | | | | Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com> Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
* vf_colorspace: don't spam console with warnings if range is unspecified.Ronald S. Bultje2016-10-24
|
* avfilter/vf_colorspace: fix range for output colorspace optionJames Almer2016-09-28
| | | | | Rreviewed-by: BBB Signed-off-by: James Almer <jamrial@gmail.com>
* vf_colorspace: Interpret unspecified color range as limited rangeVittorio Giovara2016-09-19
| | | | | | | | | | | | This is the assumption that is made in pixel format conversion do throughout the code (in particular swscale), and BT-specifications mandate. Add a warning to inform the user that an automatic selection is being made. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com> Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
* vf_colorspace: Add modern names for color range optionVittorio Giovara2016-09-14
| | | | | | Allows to use values returned from API and from ffprobe directly. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
* vf_colorspace: Add BT-names for gamma22/28 transfer optionVittorio Giovara2016-09-13
| | | | | | | Allows to use values returned from API and from ffprobe directly. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com> Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
* vf_colorspace: Allow overriding input color propertiesVittorio Giovara2016-09-04
| | | | | | | | | | The filter needs input frames with color properties filled out by the decoder. Since this is not always possible, add input options to the filter so that user may override color space, color primaries, transfer characteristics, and color range, as well as a generic option to set all properties at once. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
* avfilter: make use of ff_filter_get_nb_threadsPaul B Mahol2016-08-29
|
* vf_colorspace: Add support for full range yuvVittorio Giovara2016-08-27
| | | | | | | | | | | | | | | Whenever a full range video is input, since the YUVJ* formats are not listed as supported for this filter, a range reduction takes place through the auto-inserted format filter, forcing the conversion to operate on a limited range, However the filter handles full range videos perfectly fine, so adding support to YUVJ* formats will allow skipping a conversion step, while providing completely identical results. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com> Reviewed-by: "Ronald S. Bultje" <rsbultje@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* vf_colorspace: Check av_frame_copy_props() return valueVittorio Giovara2016-08-27
| | | | | | | This function can potentially allocate memory. Reviewed-by: "Ronald S. Bultje" <rsbultje@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* vf_colorspace: don't enable passthrough if bitdepth doesn't match.Ronald S. Bultje2016-05-10
| | | | | | | Also check return value of av_frame_copy() in passthrough mode, so that if a copy fails (as it did here, because bitdepth didn't match), the filter doesn't return success, which would mean sending an uninitialized framebuffer further down the filtergraph.
* vf_colorspace: fix range order.Ronald S. Bultje2016-05-10
|
* vf_colorspace: make whitepoint adaptation mode configurable.Ronald S. Bultje2016-05-10
| | | | | Also add von kries whitepoint adaptation, and add 'identity' to turn whitepoint adaptation off.
* vf_colorspace: add floyd-steinberg dithering option to full conversion.Ronald S. Bultje2016-05-10
|
* lavfi: new colorspace conversion filter.Ronald S. Bultje2016-04-12
The intent here is similar to colormatrix, but it's LGPLv2.1-or-later (instead of GPLv2.0) and supports gamma/chromaticity correction.