Commit Graph

213 Commits

Author SHA1 Message Date
Kacper Michajłow e9076896cd all: add missing repr assignments
Fixes: 66e451f4
2024-01-26 18:17:02 +02:00
Kacper Michajłow 475f76dc6d csputils: replace more primitives with pl_
We can go deeper, but need to stop somewhere to not reimplement vo_gpu
using libplacebo...
2024-01-22 14:54:55 +00:00
Kacper Michajłow 47be5ad4aa csputils: replace mp_chroma_location with pl_chroma_location 2024-01-22 14:54:55 +00:00
Kacper Michajłow 0ac7a40dac csputils: replace mp_alpha_type with pl_alpha_mode 2024-01-22 14:54:55 +00:00
Kacper Michajłow 66e451f4e6 csputils: replace mp_colorspace with pl_color_space 2024-01-22 14:54:55 +00:00
Kacper Michajłow 4e84ea22d7 mp_image: remove local params copy from mp_image_setfmt
No longer needed after 079f67268f.
2023-11-28 10:46:16 +01:00
Kacper Michajłow 73fbe09a49 ALL: use pl_hdr_metadata and nuke sig_peak
This commit replaces all uses of sig_peak and maps all HDR metadata.

Form notable changes mixed usage of maxCLL and max_luma is resolved and
not always max_luma is used which makes vo_gpu and vo_gpu_next behave
the same way.
2023-11-05 18:57:36 +01:00
Kacper Michajłow 174df99ffa ALL: use new mp_thread abstraction 2023-11-05 17:36:17 +00:00
Kacper Michajłow 7480efa62c mp_image: pass rotation correctly to/from AVFrame
Fixes rotating image by --video-rotate when filtering.

Fixes: #12771
2023-11-03 10:05:41 +01:00
Kacper Michajłow 9a7291d48e mp_image: set crop metadata when converting to AVFrame
So it is not lost after filtering.
2023-10-20 17:43:01 +00:00
Niklas Haas 50cd363c01 video/mp_image: handle non-power-of-two alignment
Needed for odd formats like rgb24.
2023-10-19 18:26:05 +02:00
Kacper Michajłow 71ce0cb71f mp_image: don't copy crop value from opaque_ref
It is already set above.

Fixes: #12577, #12587
2023-10-07 14:36:06 +00:00
Dudemanguy 69b7af3106 mp_image: add force_window field
It's useful for some VOs (dmabuf-wayland) to know if the image params
are actually real or fake ones sent by the core for the purpose of
force_window.
2023-09-21 14:08:52 +00:00
Kacper Michajłow 4d853c5545 mp_image: add missing crop initialization
This enabled cropping of container signaled rect.
2023-09-08 02:27:08 +00:00
Kacper Michajłow 765b68f971 mp_image: add image crop rect to mp_image_params 2023-08-31 17:37:42 +00:00
Kacper Michajłow 1b10d9dd9c mp_image: properly infer color levels for some pixfmts
ffmpeg does not tag yuv levels for GRAY formats, but apparently they
should be infered as full range. Instead of defaulting to limited range
always. Fixes (M)JPEG playback.

This mimic ffmpeg's behaviour.

See: d295b6b693/libswscale/utils.c (L926-L962)
Fixes: #12089
2023-08-07 18:22:41 +02:00
NRK d70b859084 mp_image: abort on av_buffer_ref() failure
this changes mp_image_new_ref() to handle allocation failure itself
instead of doing it at its many call-sites (some of which never checked
for failure at all).

also remove MP_HANDLE_OOM() from the call sites since this is not
necessary anymore.

not all the call-sites have been touched, since some of the caller might
be relying on `mp_image_new_ref(NULL)` returning NULL.

Fixes: https://github.com/mpv-player/mpv/issues/11840
2023-06-28 20:56:23 -07:00
Philip Langdale 8343b3bded mp_image: use the ffmpeg interlaced frame flags where available
The old frame properties are deprecated and have been replaced by frame
flags.
2023-05-11 14:31:17 -07:00
quietvoid 1808f264b3 mp_image: always add AV_FRAME_DATA_DOVI_METADATA when present
As the Dolby Vision metadata is only supported for vo_gpu_next, the check
whether to use the metadata is now handled by `mp_map_dovi_metadata_to_pl`.

It doesn't hurt to keep the metadata in `mp_image`, and might be useful to
library users.
2023-04-10 05:18:58 -04:00
Alexander Seiler bdf7b5c3b8 various: fix various typos in the code base
Signed-off-by: Alexander Seiler <seileralex@gmail.com>
2023-03-28 19:29:44 +00:00
Kacper Michajłow 22e3264652 mp_image: assert if src and dst are different in copy_attributes
It doesn't make sense to call this function on same image and the code
is not safe to do so.
2023-03-05 22:36:56 +02:00
Kacper Michajłow 2a7122ac41 mp_image: copy side data in mp_image_copy_attributes
This fixes HDR10 and HDR10+ metadata usage in vo_gpu_next when hwdec
copy variant is used.
2023-03-05 22:36:56 +02:00
Kacper Michajłow f2fab0d8e1 mp_image: fix XYZ gamma and primaries guess 2023-03-02 09:37:06 -05:00
Kacper Michajłow 40af0893a9 mp_image: be less agressive with clearing color information 2023-03-02 09:37:06 -05:00
Thomas Weißschuh 9efce6d4ae various: drop unused #include "config.h"
Most sources don't need config.h.
The inclusion only leads to lots of unneeded recompilation if the
configuration is changed.
2023-02-20 14:21:18 +00:00
quietvoid 0d82afbc7f mp_image: forward AV_FRAME_DATA_DOVI_RPU_BUFFER side data
When available, and ignored if `vf=format:dolbyvision=no`.
2023-02-19 20:50:37 +01:00
Niklas Haas 8c617765fe mp_image: fix XYZ primaries default
This was incorrectly set to BT.2020, when it should be DCI-P3 for pretty
much all real-world XYZ content (which is digital cinema content).
2023-01-21 13:03:33 +01:00
sfan5 7b03cd367d various: replace if + abort() with MP_HANDLE_OOM()
MP_HANDLE_OOM also aborts but calls assert() first, which
will result in an useful message if compiled in debug mode.
2023-01-12 22:02:07 +01:00
Philip Langdale 70683b8916 ffmpeg: increase minimum required version to 4.4
Now that 0.35 has been released, we can consider increasing our minimum
required ffmpeg version. Currently, we think 4.4 is the most recent
version we can move to (from the current requirement of 4.0).

This allows us to remove a few conditionals. There are more that we
won't be able to remove unless we move further up to 5.1.
2022-12-01 10:45:47 -08:00
Niklas Haas eba4ce5c2d mp_image: strip DoVi metadata that requires an EL
We can't support this. Better strip it than partially apply.

Fixes: #9831
2022-09-28 02:28:37 +02:00
Aaron Boxer 24d10fc998 video: remove unnecessary code
plane_clear[p] is never NULL
2022-08-01 23:11:42 +02:00
Lynne 3194ed4b58 mp_image: support film grain parameters 2022-04-05 15:02:18 +02:00
Niklas Haas e6c18641bd mp_image: fix mp_image_plane_w/h
These helpers, for some reason, decided to round the returned values up
to multiples of the nearest plane alignment. This logic makes no sense
to me, and completely breaks any sort of oddly-sized mp_image.

This logic was introduced, presumably in error and without real
justification, as part of a major refactor commit (caee8748), As far as
I can tell, removing it again doesn't regress anything.

Fixes several serious bugs including buffer underflows and GPU crashes
in vo_gpu and vo_gpu_next.
2022-02-24 18:36:28 +01:00
Lynne 0e5f7b48d2 mp_image: add dolbyvision metadata
Co-authored-by: Niklas Haas <git@haasn.dev>
2022-01-09 13:06:27 +01:00
Alex Xu (Hello71) 3ec2012cec mp_image, f_decoder_wrapper: implement AV_FRAME_DATA_DISPLAYMATRIX
fixes #9249 (JPEG orientation support) with ffmpeg commit [0].

[0] e93c998602
2021-12-15 16:39:45 +01:00
Niklas Haas 8bd0dee531 osdep: rename MP_UNREACHABLE
It was pointed out on IRC that the name is misleading, since the actual
semantics of the macro is to assert first.
2021-11-03 15:15:20 +01:00
Niklas Haas c704824b45 osdep: add MP_UNREACHABLE
This seems to work on gcc, clang and mingw as-is, but I made it
conditional on __GNUC__ just in case, even though I can't figure out
which compilers we care about that don't export this define.

Also replace all instances of assert(0) in the code by MP_UNREACHABLE(),
which is a strict improvement.
2021-11-03 14:09:27 +01:00
wm4 77f730f63c mp_image: add helper for clearing regions outside of a rectangle
Not sure if generally useful; the following commit uses it.
2020-05-22 14:18:35 +02:00
wm4 8f22aefae1 mp_image: reimplement mp_image_clear()
The old code ignored many corner cases, and even wrote "blacker than
black" to YUV images. Use the new pixel format metadata and other
recently added gimmicky crap, which should make this more correct. Even
the almighty fuckup of a format AV_PIX_FMT_UYYVYY411 should work,
although that couldn't be tested for obvious reasons.

This doesn't work for "monow", but this is so extremely fringe while at
the same time painful that I just won't care. In theory, it could be
modeled as some sort of inverted gray colorspace or something.
2020-05-21 02:07:08 +02:00
wm4 caee8748da video: clean up some imgfmt related stuff
Remove the vaguely defined plane_bits and component_bits fields from
struct mp_imgfmt_desc. Add weird replacements for existing uses. Remove
the bytes[] field, replace uses with bpp[].

Fix some potential alignment issues in existing code. As a compromise,
split mp_image_pixel_ptr() into 2 functions, because I think it's a bad
idea to implicitly round, but for some callers being slightly less
strict is convenient.

This shouldn't really change anything. In fact, it's a 100% useless
change. I'm just cleaning up what I started almost 8 years ago (see
commit 00653a3eb0). With this I've decided to keep mp_imgfmt_desc,
just removing the weird parts, and keeping the saner parts.
2020-05-18 01:54:59 +02:00
wm4 56dbbc3847 video: add yuv float formats
Adding all these so I can use them for obscure processing purposes (see
later draw_bmp commit).

There isn't really a reason why they should exist. On the other hand,
they're just labels for formats that can be handled in a generic way,
and this commit adds support for them in the zimg wrapper and vo_gpu
just by making the formats exist. (Well, vo_gpu had to be fixed in the
previous commit.)
2020-05-09 18:02:57 +02:00
wm4 b2720dba0f mp_image: add some helpers
This is really basic for planar image data access; not sure why there
weren't such helpers before.

They also handle trickier formats that use bit-packing, or they would be
mich simpler. (This affects only BGR4/BGR4/MONOW/MONOH, I hope whoever
invented them is proud of triggering so many special cases for so little
gain.)
2020-05-06 15:27:25 +02:00
wm4 71295fb872 video: add alpha type metadata
This is mostly for testing. It adds passing through the metadata through
the video chain. The metadata can be manipulated with vf_format. Support
for zimg alpha conversion (if built with zimg after it gained alpha
support) is implemented. Support premultiplied input in vo_gpu.

Some things still seem to be buggy.
2020-04-24 14:41:50 +02:00
wm4 7d11eda72e Remove remains of Libav compatibility
Libav seems rather dead: no release for 2 years, no new git commits in
master for almost a year (with one exception ~6 months ago). From what I
can tell, some developers resigned themselves to the horrifying idea to
post patches to ffmpeg-devel instead, while the rest of the developers
went on to greener pastures.

Libav was a better project than FFmpeg. Unfortunately, FFmpeg won,
because it managed to keep the name and website. Libav was pushed more
and more into obscurity: while there was initially a big push for Libav,
FFmpeg just remained "in place" and visible for most people. FFmpeg was
slowly draining all manpower and energy from Libav. A big part of this
was that FFmpeg stole code from Libav (regular merges of the entire
Libav git tree), making it some sort of Frankenstein mirror of Libav,
think decaying zombie with additional legs ("features") nailed to it.
"Stealing" surely is the wrong word; I'm just aping the language that
some of the FFmpeg members used to use. All that is in the past now, I'm
probably the only person left who is annoyed by this, and with this
commit I'm putting this decade long problem finally to an end. I just
thought I'd express my annoyance about this fucking shitshow one last
time.

The most intrusive change in this commit is the resample filter, which
originally used libavresample. Since the FFmpeg developer refused to
enable libavresample by default for drama reasons, and the API was
slightly different, so the filter used some big preprocessor mess to
make it compatible to libswresample. All that falls away now. The
simplification to the build system is also significant.
2020-02-16 15:14:55 +01:00
wm4 d3f8d82279 mp_image: copy closed captions when copying attributes
With hwdec copy modes, mp_image_copy_attributes() is used to transfer
metadata other than the image data when copying the image from the
hardware surface. It didn't copy the closed caption data.

Fix this. This makes closed captions in copy mode work.

Fixes: #6376
2019-10-25 22:38:00 +02:00
wm4 40b557db6a mp_image: move buffer ref assigning to a function
Mostly untested, for the next commit.

There's another case of this in this file (ref_buffer()), but it's too
weird, so ignore it.
2019-10-25 22:36:19 +02:00
Niklas Haas c2ed79247f mp_image: infer XYZ as BT.2020 instead of BT.709
And update the comment both explaining why this defaulting matters and
why we use BT.2020 instead.

tl;dr BT.709 clips even the one test file we *do* have, so if we don't
handle XYZ "natively" in vo_gpu we might as well at least handle it in a
way that runs less risk of clipping
2019-10-20 16:07:21 +02:00
wm4 fd539a542f mp_image: remove old acrobatics in frame copy code
This used to be needed for the "GPU memcpy" (shitty Intel methods to
deal with certain uncached memory types). This is now done in FFmpeg,
and the code in mp_image.c was just unnecessarily convoluted.
2019-10-20 01:44:22 +02:00
wm4 60ab82df32 video, demux: rip out unused spherical metadata code
This was preparation into something that never happened.

Spherical video is a shit idea anyway.
2019-10-17 22:49:26 +02:00
wm4 77fd4dd681 video: remove mp_image_params.hw_flags field
This was speculatively added 2 years ago in preparation for something
that apparently never happened. The D3D code was added as an "example",
but this too was never used/finished.

No reason to keep this.
2019-10-17 22:43:14 +02:00