Commit Graph

68 Commits

Author SHA1 Message Date
Niklas Haas d312a33ed2 avfilter/drawutils: remove redundant xyz format check
The code above this does a whitelist on desc->flags, which now includes
the (disallowed) AV_PIX_FMT_FLAG_XYZ for XYZ formats. So there is no
more need for a separate check, here.
2023-10-31 15:46:38 +01:00
Niklas Haas 96dfc4481b avfilter/drawutils: ban XYZ formats
These are not supported by the drawing functions at all, and were
incorrectly advertised as supported in the past.

Note: This check is added only to separate the logic change from the API
change in the following commit, and will be removed again after it
becomes redundant.
2023-10-31 15:43:30 +01:00
Paul B Mahol 442bbdb3c5 avfilter/drawutils: rgb48/bgr48 is supported 2022-12-10 14:57:05 +01:00
rcombs 6c3a82f043 lavfi/drawutils: improve colorspace support
- Introduce ff_draw_init2, which takes explicit colorspace and range
  args
- Use lavu/csp and lavfi/colorspace for conversion, rather than the
  lavu/colorspace.h macros
- Use the passed-in colorspace when performing RGB->YUV conversions

The upshot of this is:
- Support for YUV spaces other than BT601
- Better rounding for all conversions
- Particular rounding improvements in >8-bit formats, which previously
  used simple left-shifts
- Support for limited-range RGB
- Support for full-range YUV in non-J pixfmts

Due to the rounding improvements, this results in a large number of
minor changes to FATE tests.

Signed-off-by: rcombs <rcombs@rcombs.me>
2022-06-19 19:18:34 -05:00
rcombs da92865b27 lavfi/drawutils: re-enable P010 and P016 support
These formats now work as expected.
2022-01-04 19:39:22 -06:00
rcombs 66343e46cf lavfi/drawutils: overhaul to improve pixel format support
- No longer mixes u8 and u16 component accesses (this was UB)
- De-duplicated 8->16 conversion
- De-duplicated component -> plane+offset conversion
- De-duplicated planar + packed RGB
- No longer calls ff_fill_rgba_map
- Removed redundant comp_mask data member
- RGB0 and related formats no longer write an alpha value to the 0 byte
- Non-planar YA formats now work correctly
- High-bit-depth semi-planar YUV now works correctly
2022-01-04 19:39:22 -06:00
rcombs f67bd3a825 lavfi/drawutils: ensure we don't support formats with non-pixel-sized offsets 2022-01-04 19:39:22 -06:00
rcombs f320722eb5 lavfi/drawutils: ensure we can't overflow a component 2022-01-04 19:39:22 -06:00
rcombs f00079b25c lavfi/drawutils: ensure we don't allow mixed-byte-depth formats
These could be hazardous because of FFDrawColor's union
2022-01-04 19:39:22 -06:00
rcombs e24b71add5 lavfi/drawutils: reimplement ff_fill_rgba_map without hardcoding the list
Same outputs, but computed instead of statically known, so new formats will be
supported more easily. Asserts in place to ensure we update this if we add
anything incompatible with its logic.
2022-01-04 19:39:22 -06:00
rcombs 5018103fa3 lavfi/drawutils: reject shift-packed formats
Disables x2bgr10/x2rgb10 (which did not behave correctly before).
2022-01-04 19:39:22 -06:00
rcombs 186e931f74 lavfi/drawutils: remove redundant BE format checks
We already explicitly don't support big-endian in general
2022-01-04 19:39:22 -06:00
rcombs 52fe11ef34 lavfi/drawutils: move BE check out of loop 2022-01-04 19:39:22 -06:00
Andreas Rheinhardt 2934a4b9a5 Remove unnecessary avassert.h inclusions
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 15:02:30 +02:00
Andreas Rheinhardt 4608f7cc6a Remove unnecessary mem.h inclusions
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 14:47:57 +02:00
Andreas Rheinhardt 985c0dac67 avutil/pixdesc: Remove deprecated AV_PIX_FMT_FLAG_PSEUDOPAL
Deprecated in d6fc031caf.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:13 -03:00
Paul B Mahol 629dd8efb5 avfilter/vf_extractplanes: add float formats support 2021-02-07 21:45:26 +01:00
Andreas Rheinhardt 124e2a79e2 avfilter/drawutils: Remove remnants of old API
ff_fill_line_with_color and ff_draw_rectangle are unused since
19c8f2271423281c9b876b984076a6467c455904; ff_copy_rectangle
is unused since 53b7a3fe08.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-29 15:20:53 +01:00
Paul B Mahol 72b29c02f4 avfilter/drawutils: support gray14
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2018-05-05 21:50:22 +02:00
Paul B Mahol f43fd68f28 avfilter/drawutils: add support for full range
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2018-05-03 21:43:57 +02:00
wm4 d6fc031caf avutil/pixdesc: deprecate AV_PIX_FMT_FLAG_PSEUDOPAL
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.
2018-04-03 17:53:00 +02:00
Carl Eugen Hoyos 9fe61b6107 lavfi/drawutils: Do not claim to support P016.
Fixes fate on big-endian.
2018-03-08 11:56:41 +01:00
Paul B Mahol 1bef0088dc avfilter/drawutils: add gray9/10/12 support 2017-08-07 18:39:29 +02:00
Paul B Mahol 5621a99e27 avfilter/drawutils: support gbrap10 too 2017-08-07 13:06:34 +02:00
Paul B Mahol 9d16e46d9e avfilter/drawutils: allow drawing opaque text on transparent background
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-09-21 11:54:00 +02:00
Timo Rothenpieler 2625b955a3 avfilter/drawutils: honor shift for color component description 2016-08-31 13:19:46 +02:00
Timo Rothenpieler d3a23b6777 avfilter/drawutils: P010 is not supported 2016-08-31 13:19:46 +02:00
Michael Niedermayer 369ed11e3c avfilter/drawutils: Fix single plane with alpha
Fixes Ticket5720

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-09 12:42:57 +02:00
Derek Buitenhuis f693184557 Split drawutils test out into separate file
This was missed during 96d616052b because
it is not included in FATE.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-05-11 20:43:19 +01:00
Rodger Combs d645182227
lavfi/drawutils: support NV12 and NV21 2016-05-10 20:32:50 -05:00
Carl Eugen Hoyos 8653d6e1a6 lavfi/drawutils: Add some missing GBRP pix_fmts.
Fixes for example extractplanes with GBRAP16.
2016-03-03 11:15:30 +01:00
Michael Niedermayer 954f865c8e avfilter/drawutils: fix gray and gbr formats on big endian
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-25 00:07:51 +01:00
Michael Niedermayer 6bc20e84d8 avfilter/drawutils: Fix ff_fill_rectangle() on big endian
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-25 00:07:51 +01:00
Paul B Mahol 38ed528fa5 avfilter/drawutils: >8 bit support
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-02-17 18:59:56 +01:00
Derek Buitenhuis 21f9468402 avutil: Rename FF_CEIL_COMPAT to AV_CEIL_COMPAT
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>
2016-01-27 16:36:46 +00:00
Ronald S. Bultje 9cf81e573c lavfi: recognize GBR9-14P as RGB in ff_fill_rgba_map(). 2016-01-24 11:45:53 -05:00
Timothy Gu 852c4b3d42 drawutils: Reindent 2015-10-26 23:24:30 -07:00
Nicolas George 559603dae1 lavfi/drawutils: add const to blending mask. 2015-10-25 20:58:21 +01:00
Ganesh Ajjanagadde 6aaac24d72 avfilter/all: propagate errors of functions from avfilter/formats
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>
2015-10-14 10:04:01 -04:00
Hendrik Leppkes 5d8e836d0e Replace all remaining occurances of step/depth_minus1 and offset_plus1 2015-09-08 17:10:48 +02:00
Michael Niedermayer a98d4d5207 avfilter/drawutils: Assert av_pix_fmt_desc_get() return value in ff_fill_line_with_color()
Theres currently no case where this could be triggered

Found-by: Daemon404
Reviewed-by: Nicolas George <george@nsup.org>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-13 21:33:18 +02:00
Michael Niedermayer e0db41316a avfilter/drawutils: Fix format validity check in ff_draw_init()
Found-by: Daemon404
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-13 00:06:28 +02:00
Michael Niedermayer f77571f6bb avfilter/drawutils: Check for av_malloc* failures
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-01-22 13:54:26 +01:00
Michael Niedermayer c90069c6ba avfilter/drawutils: Use av_malloc_array()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-01-22 13:50:30 +01:00
Michael Niedermayer 0d26264fb4 avfilter/vf_drawtext: Avoid using non public AV_PIX_FMT_NB
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-27 17:52:24 +02:00
Paul B Mahol d5598c0963 lavfi/drawutils: set subsampling for rgb too
Otherwise it is incorrectly set to 1.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-07-14 17:59:25 +00:00
Paul B Mahol 55c94f48ce lavfi/drawutils: fix planar rgb
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-07-08 16:40:49 +00:00
Clément Bœsch 1f1df07ce5 lavfi/drawutils: attempt to fix subsampling. 2013-05-28 19:20:27 +02:00
Michael Niedermayer c7c71f95f8 replace remaining PIX_FMT_* flags with AV_PIX_FMT_FLAG_*
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-15 11:23:14 +02:00
Paul B Mahol deef4b1ac9 lavfi/drawutils: add 16 bit rgb and planar rgb to ff_fill_rgba_map()
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-05-08 19:24:23 +00:00