Commit Graph

258 Commits

Author SHA1 Message Date
Jan Ekström 29561c8e2d avutil/pix{desc,fmt}: add new matrix coefficients from H.273 v3
* SMPTE ST 2128 IPT-C2 defines the coefficients utilized in DoVi
  Profile 5. Profile 5 can thus now be represented in VUI as
  {AVCOL_RANGE_JPEG, AVCOL_PRI_BT2020, AVCOL_TRC_SMPTE2084,
   AVCOL_SPC_IPT_C2, AVCHROMA_LOC_LEFT} (although other chroma
  sample locations are allowed). AVCOL_TRC_SMPTE2084 should in
  this case be interpreted as 'PQ with reshaping'.
* YCgCo-Re and YCgCo-Ro define the bitexact YCgCo-R, where the
  number of bits added to a source RGB bit depth is 2 (i.e., even)
  and 1 (i.e., odd), respectively.
2024-04-03 21:31:35 +03:00
James Almer a12cd3be98 avutil: remove deprecated FF_API_XVMC
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-07 08:53:30 -03:00
Jeffrey Knockel 0e20146db0
avutil/pixfmt: fix AV_PIX_FMT_RGB8 description
Previously AV_PIX_FMT_RGB8 was documented as "RGB 3:3:2,
(msb)2R 3G 3B(lsb)".  While the RGB 3:3:2 part is correct, the latter
part should be: (msb)3R 3G 2B(lsb).  This commit also updates the
format's pixdesc description to be (msb)3R 3G 2B(lsb).

Signed-off-by: Jeffrey Knockel <jeff@jeffreyknockel.com>
Reviewed-by: "Diederick C. Niehorster" <dcnieho@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-01-16 01:34:57 +01:00
Wu Jianhua 142f727b9c libavutil: add hwcontext_d3d12va and AV_PIX_FMT_D3D12
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
Signed-off-by: Tong Wu <tong1.wu@intel.com>
2023-12-21 16:15:23 +08:00
Niklas Haas 93f07d98d9 avutil/pixdesc: simplify xyz pixfmt check 2023-10-31 15:46:38 +01:00
Niklas Haas 57c16323f2 avutil/pixdesc: add AV_PIX_FMT_FLAG_XYZ
There are already several places in the codebase that match desc->name
against "xyz", and many downstream clients replicate this behavior.
I have no idea why this is not just a flag.

Motivated by my desire to add yet another check for XYZ to the codebase,
and I'd rather not keep copy/pasting a string comparison hack.
2023-10-31 15:46:07 +01:00
Paul B Mahol 8e1ef7c38f avutil: add GBRAP14 format support 2023-09-28 19:36:08 +02:00
Lynne 0bda3340a3
lavu: add 12-bit 2-plane 422 and 444 pixel formats 2023-05-29 00:41:35 +02:00
Philip Langdale 9651f873f8 lavu/pixdesc: handle xv30be in av_[read|write]_image_line
xv30be is an obnoxious format that I shouldn't have included in the
first place. xv30 packs 3 10bit channels into 32bits and while our
byte-oriented logic can handle Little Endian correctly, it cannot
handle Big Endian. To avoid that, I marked xv30be as a bitstream
format, but while that didn't produce FATE errors, it turns out that
the existing read/write code silently produces incorrect results, which
can be revealed via ubsan.

In all likelyhood, the correct fix here is to remove the format. As
this format is only used by Intel vaapi, it's only going to show up
in LE form, so we could just drop the BE version. But I don't want to
deal with creating a hole in the pixfmt list and all the weirdness that
comes from that. Instead, I decided to write the correct read/write
code for it.

And that code isn't too bad, as long as it's specialised for this
format, as the channels are all bit-aligned inside a 32bit word.
2022-12-08 21:15:44 -08:00
Andreas Rheinhardt 5fe447bbb4 avutil/pixdesc: Move ff_check_pixfmt_descriptors() to its only user
Namely to lavu/tests/pixelutils.c. This way, this function will
not be included into actual binaries any more.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-30 14:33:08 +02:00
Andreas Rheinhardt 571b670e7d avutil/pixdesc: Avoid direct access to pix fmt desc array
Instead use av_pix_fmt_desc_next(). It is still possible
to check its return values by comparing it with the
(currently) expected values and the code does so.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-30 14:33:08 +02:00
Andreas Rheinhardt 6d0a7e96e7 avutil/pixdesc: Remove always-false checks
ff_check_pixfmt_descriptors() was added in commit
20e99a9c10. At this time,
the values of enum AVPixelFormat were not contiguous;
instead there was a jump from 111 to 291 (or from 115
to 295 depending upon AV_PIX_FMT_ABI_GIT_MASTER).
ff_check_pixfmt_descriptors() accounts for this
by skipping empty descriptors. Yet this issue no longer
exists: There are no holes.

The check for said holes makes GCC believe that the name
can be NULL; because it is used as argument corresponding to
%s in a log statement, it therefore emits a warning
(since d75c4693fe). Therefore
this commit simply removes these checks.

Also move the checks for name before the log statement.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-30 14:33:08 +02:00
Andreas Rheinhardt 8be6552aa4 avutil/pixdesc: Add av_chroma_location_(enum_to_pos|pos_to_enum)
They are intended as replacements for avcodec_enum_to_chroma_pos()
and avcodec_chroma_pos_to_enum().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-26 03:02:25 +02:00
Paul B Mahol 7bb0afc245 avutil: add RGBA single-float precision packed formats 2022-09-25 18:34:48 +02:00
Paul B Mahol 63bb6d6a9b avutil: add RGB single-precision float formats 2022-09-25 18:34:48 +02:00
Philip Langdale ed83a3a5bd lavu/pixdesc: favour formats where depth and subsampling exactly match
Since introducing the various packed formats used by VAAPI (and p012),
we've noticed that there's actually a gap in how
av_find_best_pix_fmt_of_2 works. It doesn't actually assign any value
to having the same bit depth as the source format, when comparing
against formats with a higher bit depth. This usually doesn't matter,
because av_get_padded_bits_per_pixel() will account for it.

However, as many of these formats use padding internally, we find that
av_get_padded_bits_per_pixel() actually returns the same value for the
10 bit, 12 bit, 16 bit flavours, etc. In these tied situations, we end
up just picking the first of the two provided formats, even if the
second one should be preferred because it matches the actual bit depth.

This bug already existed if you tried to compare yuv420p10 against p016
and p010, for example, but it simply hadn't come up before so we never
noticed.

But now, we actually got a situation in the VAAPI VP9 decoder where it
offers both p010 and p012 because Profile 3 could be either depth and
ends up picking p012 for 10 bit content due to the ordering of the
testing.

In addition, in the process of testing the fix, I realised we have the
same gap when it comes to chroma subsampling - we do not favour a
format that has exactly the same subsampling vs one with less
subsampling when all else is equal.

To fix this, I'm introducing a small score penalty if the bit depth or
subsampling doesn't exactly match the source format. This will break
the tie in favour of the format with the exact match, but not offset
any of the other scoring penalties we already have.

I have added a set of tests around these formats which will fail
without this fix.
2022-09-17 15:11:13 -07:00
Philip Langdale d75c4693fe lavu/pixfmt: Add P012, Y212, XV30, and XV36 formats
These are the formats we want/need to use when dealing with the Intel
VAAPI decoder for 12bit 4:2:0, 12bit 4:2:2, 10bit 4:4:4 and 12bit 4:4:4
respectively.

As with the already supported Y210 and YUVX (XVUY) formats, they are
based on formats Microsoft picked as their preferred 4:2:2 and 4:4:4
video formats, and Intel ran with it.

P12 and Y212 are simply an extension of 10 bit formats to say 12 bits
will be used, with 4 unused bits instead of 6.

XV30, and XV36, as exotic as they sound, are variants of Y410 and Y412
where the alpha channel is left formally undefined. We prefer these
over the alpha versions because the hardware cannot actually do
anything with the alpha channel and respecting it is just overhead.

Y412/XV46 is a normal looking packed 4 channel format where each
channel is 16bits wide but only the 12msb are used (like P012).

Y410/XV30 packs three 10bit channels in 32bits with 2bits of alpha,
like A/X2RGB10 style formats. This annoying layout forced me to define
the BE version as a bitstream format. It seems like our pixdesc
infrastructure can handle the LE version being byte-defined, but not
when it's reversed. If there's a better way to handle this, please
let me know. Our existing X2 formats all have the 2 bits at the MSB
end, but this format places them at the LSB end and that seems to be
the root of the problem.
2022-09-03 16:19:40 -07:00
Philip Langdale cc5a5c9860 lavu/pixfmt: Introduce VUYX format
This is the alphaless version of VUYA that I introduced recently. After
further discussion and noting that the Intel vaapi driver explicitly
lists XYUV as a support format for encoding and decoding 8bit 444
content, we decided to switch our usage and avoid the overhead of
having a declared alpha channel around.

Note that I am not removing VUYA, as this turned out to have another
use, which was to replace the need for v408enc/dec when dealing with
the format.

The vaapi switching will happen in the next change
2022-08-25 19:02:49 -07:00
Timo Rothenpieler e95b08a7dd lavu/pixfmt: add packed RGBA float16 format
This is the default format of the Windows compositor and what DXGI
Desktop Duplication will give you for any kind of HDR output.
2022-08-13 15:21:46 +02:00
Philip Langdale 6ab8a9d375 lavu/pixfmt: Add packed 4:4:4 format
The "AYUV" format is defined by Microsoft as their preferred format for
4:4:4 content, and so it is the format used by Intel VAAPI and QSV.

As Microsoft like to define their byte ordering in little-endian
fashion, the memory order is reversed, and so our pix_fmt, which
follows memory order, has a reversed name (VUYA).
2022-08-03 14:09:46 -07:00
Anton Khirnov cefa595361 lavu/pixfmt: deprecate AV_PIX_FMT_XVMC
It is no longer used for anything.
2022-02-15 10:16:16 +01:00
rcombs b2cd1fb2ec lavu/pixfmt: add high-bit-depth semi-planar 4:2:2/4:4:4 formats
These are used by VideoToolbox hardware decoders.
2021-11-28 16:40:43 -06:00
Manuel Stoeckl 0760d9153c lavu/pix_fmt: add pixel format for x2bgr10
The new format (given in big/little endian forms) matches the
existing X2RGB10 format, except with B and R channels switched.

AV_PIX_FMT_X2BGR10 data often is created by OpenGL programs
whose buffers use the GL_RGB10 internal format.

Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-09-26 16:26:10 +02:00
Andreas Rheinhardt e7bd47e657 Remove obsolete version.h inclusions
These have mostly been added because of FF_API_*; yet when these were
removed, removing the header has been forgotten.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 14:34:31 +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
Andreas Rheinhardt 0181162bb5 avutil/pixdesc: Remove deprecated off-by-one fields from pix fmt descs
Deprecated in 2268db2cd0.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:12 -03:00
Andreas Rheinhardt ad524cb9ee avutil/pixfmt: Remove deprecated VAAPI pixel formats
Deprecated in 9f8e57efe4.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:12 -03:00
Andreas Rheinhardt b7565b65b8 avutil/pixdesc: Fix 1 << 32
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-04-01 14:52:18 +02:00
Andreas Rheinhardt 114603d0b9 avutil/pixdesc: Use av_strstart where appropriate
It makes the intent clearer and allows to avoid calculating the strlen
separately.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-02-28 17:14:21 +01:00
Fei Wang b09fb030c1 lavu/pix_fmt: add new pixel format x2rgb10
The format is packed RGB with each channel 10 bits available and
include 2 bits unused.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
2020-06-12 17:56:15 +01:00
Linjie Fu 1c37cad084 lavu/pix_fmt: add new pixel format y210
Add some packed 4:2:2 10-bit pixel formats for hardware decode support
in VAAPI and QSV.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
2020-02-24 00:09:51 +00:00
Lynne a88449ffb2 lavu: add Vulkan hwcontext code
This commit adds the necessary code to initialize and use a Vulkan device
within the hwcontext libavutil framework.
Currently direct mapping to VAAPI and DRM frames is functional, and
transfers to CUDA and native frames are supported.

Lets hope the future Vulkan video decode extension fits well within this
framework.
2020-02-04 23:19:48 +00:00
Raphaël Zumer 8821d1f56e avutil/pixfmt: Add EBU Tech. 3213-E AVColorPrimaries value
This is an alias for JEDEC P22.

The name associated with the value is also changed
from jedec-p22 to ebu3213 to match ITU-T H.273.

Signed-off-by: Raphaël Zumer <rzumer@tebako.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2019-09-01 19:56:05 -03:00
Philip Langdale 5de4f1d871 avutil: Add NV24 and NV42 pixel formats
These are the 4:4:4 variants of the semi-planar NV12/NV21 formats.

These formats are not used much, so we've never had a reason to add
them until now. VDPAU recently added support HEVC 4:4:4 content
and when you use the OpenGL interop, the returned surfaces are in
NV24 format, so we need the pixel format for media players, even
if there's no direct use within ffmpeg.

Separately, there are apparently webcams that use NV24, but I've
never seen one.
2019-05-12 07:51:02 -07:00
Martin Vignali 80b0624099 avutil : add YUVA444P12 and YUVA422P12 2018-11-24 16:24:43 +01:00
Michael Niedermayer 718044dc19 avutil/pixdesc: Add av_write_image_line2(), av_read_image_line2()
This is needed because of 32bit float formats (which are difficult to
store in 16bits)

This also fixes undefined behavior found by fate

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-10-27 22:39:27 +02:00
Sergey Lavrushkin 00ae3498bf libavutil: Adds gray floating-point pixel formats.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-08-11 02:37:42 +02:00
Derek Buitenhuis 238a8ae92f pixdesc: Only check against valid entries when iterating over lists of enums
Some of these enums have gaps in between their values, since they correspond
to the values in various specs, instead of being an incrementing list.

Fixes segfaults when, for example, using the valid API call:

   av_color_primaries_from_name("jecdec-p22");

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2018-06-12 16:10:31 +01:00
Paul B Mahol aef93c6aa5 avutil: add gray14 pixel format
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2018-05-05 21:35:31 +02:00
Marton Balint 7033654f7f Use AV_PIX_FMT_FLAG_ALPHA for detecting transparency where nb_components was used
Temporarily keep the old method for ffmpeg_filters.c choose_pix_fmt and
avfiltergraph.c pick_format() until a paletted pixel format without alpha is
introduced.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-04-30 21:51:31 +02:00
Marton Balint 56b081da57 avutil/pixdesc: add AV_PIX_FMT_FLAG_ALPHA to AV_PIX_FMT_PAL8
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-04-30 21:51:31 +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
Mark Thompson a050f56c09 lavu: Add OpenCL hardware pixfmt 2017-11-22 23:01:29 +00:00
James Almer b773a8d8c1 Merge commit 'dd343fd986459f467a2d1d70c26101dff1d47d68'
* commit 'dd343fd986459f467a2d1d70c26101dff1d47d68':
  lavu: Drop deprecated VDPAU pixel formats

Merged-by: James Almer <jamrial@gmail.com>
2017-10-23 18:15:49 -03:00
James Almer b46613dd9b Merge commit 'dcc39ee10e82833ce24aa57926c00ffeb1948198'
* commit 'dcc39ee10e82833ce24aa57926c00ffeb1948198':
  lavc: Remove deprecated XvMC support hacks

Merged-by: James Almer <jamrial@gmail.com>
2017-10-23 15:20:49 -03:00
Clément Bœsch 2b32031827 lavc: drop VDA
Deprecated (aka removed) in OSX 10.11, and we have a replacement for it
(VideoToolbox).
2017-10-23 11:56:15 +02:00
James Almer 318778de9e Merge commit 'fd9212f2edfe9b107c3c08ba2df5fd2cba5ab9e3'
* commit 'fd9212f2edfe9b107c3c08ba2df5fd2cba5ab9e3':
  Mark some arrays that never change as const.

Merged-by: James Almer <jamrial@gmail.com>
2017-09-26 16:02:40 -03:00
Vittorio Giovara 6f15f1cdc8 pixdesc: Add API to map color property names to enum values
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2017-09-21 13:33:29 +02:00
Mark Thompson 9cb23cd9fe lavu: Add DRM hwcontext 2017-09-13 22:03:27 +01:00
Vittorio Giovara 1460408703 Add single precision planar RGB pixel formats
Add a pixel format flag to identify this family.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2017-08-15 15:26:20 +02:00