2010-01-30 16:57:40 +00:00
|
|
|
/*
|
2015-04-13 07:36:54 +00:00
|
|
|
* This file is part of mpv.
|
2010-01-30 16:57:40 +00:00
|
|
|
*
|
2017-09-21 11:50:18 +00:00
|
|
|
* mpv is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2010-01-30 16:57:40 +00:00
|
|
|
*
|
2015-04-13 07:36:54 +00:00
|
|
|
* mpv is distributed in the hope that it will be useful,
|
2010-01-30 16:57:40 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2017-09-21 11:50:18 +00:00
|
|
|
* GNU Lesser General Public License for more details.
|
2010-01-30 16:57:40 +00:00
|
|
|
*
|
2017-09-21 11:50:18 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
2010-01-30 16:57:40 +00:00
|
|
|
*/
|
|
|
|
|
2008-02-22 09:09:46 +00:00
|
|
|
#ifndef MPLAYER_MP_IMAGE_H
|
|
|
|
#define MPLAYER_MP_IMAGE_H
|
2002-01-16 00:14:59 +00:00
|
|
|
|
2012-12-11 23:43:36 +00:00
|
|
|
#include <stdbool.h>
|
2008-03-06 08:34:50 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2012-10-27 15:59:16 +00:00
|
|
|
#include <inttypes.h>
|
2013-12-18 16:12:21 +00:00
|
|
|
#include "common/common.h"
|
2013-12-17 01:39:45 +00:00
|
|
|
#include "common/msg.h"
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "csputils.h"
|
2012-12-31 00:58:25 +00:00
|
|
|
#include "video/img_format.h"
|
2008-03-06 08:34:50 +00:00
|
|
|
|
video: generally try to align image data on 64 bytes
Generally, using x86 SIMD efficiently (or crash-free) requires aligning
all data on boundaries of 16, 32, or 64 (depending on instruction set
used). 64 bytes is needed or AVX-512, 32 for old AVX, 16 for SSE. Both
FFmpeg and zimg usually require aligned data for this reason.
FFmpeg is very unclear about alignment. Yes, it requires you to align
data pointers and strides. No, it doesn't tell you how much, except
sometimes (libavcodec has a legacy-looking avcodec_align_dimensions2()
API function, that requires a heavy-weight AVCodecContext as argument).
Sometimes, FFmpeg will take a shit on YOUR and ITS OWN alignment. For
example, vf_crop will randomly reduce alignment of data pointers,
depending on the crop parameters. On the other hand, some libavfilter
filters or libavcodec encoders may randomly crash if they get the wrong
alignment. I have no idea how this thing works at all.
FFmpeg usually doesn't seem to signal alignment internal anywhere, and
usually leaves it to av_malloc() etc. to allocate with proper alignment.
libavutil/mem.c currently has a ALIGN define, which is set to 64 if
FFmpeg is built with AVX-512 support, or as low as 16 if built without
any AVX support. The really funny thing is that a normal FFmpeg build
will e.g. align tiny string allocations to 64 bytes, even if the machine
does not support AVX at all.
For zimg use (in a later commit), we also want guaranteed alignment.
Modern x86 should actually not be much slower at unaligned accesses, but
that doesn't help. zimg's dumb intrinsic code apparently randomly
chooses between aligned or unaligned accesses (depending on compiler, I
guess), and on some CPUs these can even cause crashes. So just treat the
requirement to align as a fact of life.
All this means that we should probably make sure our own allocations are
64 bit aligned. This still doesn't guarantee alignment in all cases, but
it's slightly better than before.
This also makes me wonder whether we should always override libavcodec's
buffer pool, just so we have a guaranteed alignment. Currently, we only
do that if --vd-lavc-dr is used (and if that actually works). On the
other hand, it always uses DR on my machine, so who cares.
2019-07-15 01:06:47 +00:00
|
|
|
// Assumed minimum align needed for image allocation. It's notable that FFmpeg's
|
|
|
|
// libraries except libavcodec don't really know what alignment they want.
|
|
|
|
// Things will randomly crash or get slower if the alignment is not satisfied.
|
|
|
|
// Whatever. This value should be pretty safe with current CPU architectures.
|
|
|
|
#define MP_IMAGE_BYTE_ALIGN 64
|
|
|
|
|
2003-08-18 14:49:06 +00:00
|
|
|
#define MP_IMGFIELD_TOP_FIRST 0x02
|
|
|
|
#define MP_IMGFIELD_REPEAT_FIRST 0x04
|
2003-12-22 17:26:19 +00:00
|
|
|
#define MP_IMGFIELD_INTERLACED 0x20
|
2003-08-03 12:09:58 +00:00
|
|
|
|
2013-08-24 17:37:34 +00:00
|
|
|
// Describes image parameters that usually stay constant.
|
|
|
|
// New fields can be added in the future. Code changing the parameters should
|
|
|
|
// usually copy the whole struct, so that fields added later will be preserved.
|
2013-06-07 23:35:44 +00:00
|
|
|
struct mp_image_params {
|
|
|
|
enum mp_imgfmt imgfmt; // pixel format
|
2016-07-15 09:54:44 +00:00
|
|
|
enum mp_imgfmt hw_subfmt; // underlying format for some hwaccel pixfmts
|
2013-06-07 23:35:44 +00:00
|
|
|
int w, h; // image dimensions
|
2016-05-30 17:07:09 +00:00
|
|
|
int p_w, p_h; // define pixel aspect ratio (undefined: 0/0)
|
2016-06-29 07:16:13 +00:00
|
|
|
struct mp_colorspace color;
|
vo_opengl: handle chroma location
Use the video decoder chroma location flags and render chroma locations
other than centered. Until now, we've always used the intuitive and
obvious centered chroma location, but H.264 uses something else.
FFmpeg provides a small overview in libavcodec/avcodec.h:
-----------
/**
* X X 3 4 X X are luma samples,
* 1 2 1-6 are possible chroma positions
* X X 5 6 X 0 is undefined/unknown position
*/
enum AVChromaLocation{
AVCHROMA_LOC_UNSPECIFIED = 0,
AVCHROMA_LOC_LEFT = 1, ///< mpeg2/4, h264 default
AVCHROMA_LOC_CENTER = 2, ///< mpeg1, jpeg, h263
AVCHROMA_LOC_TOPLEFT = 3, ///< DV
AVCHROMA_LOC_TOP = 4,
AVCHROMA_LOC_BOTTOMLEFT = 5,
AVCHROMA_LOC_BOTTOM = 6,
AVCHROMA_LOC_NB , ///< Not part of ABI
};
-----------
The visual difference is literally minimal, but since videophiles
apparently consider this detail as quality mark of a video renderer,
support it anyway. We don't bother with chroma locations other than
centered and left, though.
Not sure about correctness, but it's probably ok.
2013-06-08 00:15:24 +00:00
|
|
|
enum mp_chroma_location chroma_location;
|
2014-04-20 19:28:09 +00:00
|
|
|
// The image should be rotated clockwise (0-359 degrees).
|
|
|
|
int rotate;
|
2018-04-21 11:31:00 +00:00
|
|
|
enum mp_stereo3d_mode stereo3d; // image is encoded with this mode
|
2020-04-24 12:41:50 +00:00
|
|
|
enum mp_alpha_type alpha; // usually auto; only set if explicitly known
|
2013-06-07 23:35:44 +00:00
|
|
|
};
|
|
|
|
|
2012-12-11 23:43:36 +00:00
|
|
|
/* Memory management:
|
|
|
|
* - mp_image is a light-weight reference to the actual image data (pixels).
|
|
|
|
* The actual image data is reference counted and can outlive mp_image
|
|
|
|
* allocations. mp_image references can be created with mp_image_new_ref()
|
|
|
|
* and free'd with talloc_free() (the helpers mp_image_setrefp() and
|
|
|
|
* mp_image_unrefp() can also be used). The actual image data is free'd when
|
|
|
|
* the last mp_image reference to it is free'd.
|
|
|
|
* - Each mp_image has a clear owner. The owner can do anything with it, such
|
|
|
|
* as changing mp_image fields. Instead of making ownership ambiguous by
|
|
|
|
* sharing a mp_image reference, new references should be created.
|
|
|
|
* - Write access to the actual image data is allowed only after calling
|
|
|
|
* mp_image_make_writeable(), or if mp_image_is_writeable() returns true.
|
|
|
|
* Conceptually, images can be changed by their owner only, and copy-on-write
|
|
|
|
* is used to ensure that other references do not see any changes to the
|
|
|
|
* image data. mp_image_make_writeable() will do that copy if required.
|
|
|
|
*/
|
2008-04-24 02:49:44 +00:00
|
|
|
typedef struct mp_image {
|
2015-04-10 19:06:18 +00:00
|
|
|
int w, h; // visible dimensions (redundant with params.w/h)
|
2012-12-31 00:58:25 +00:00
|
|
|
|
2014-04-20 19:27:45 +00:00
|
|
|
struct mp_image_params params;
|
|
|
|
|
|
|
|
// fields redundant to params.imgfmt, for convenience or compatibility
|
|
|
|
struct mp_imgfmt_desc fmt;
|
2013-06-07 23:35:44 +00:00
|
|
|
enum mp_imgfmt imgfmt;
|
2012-12-31 00:58:25 +00:00
|
|
|
int num_planes;
|
|
|
|
|
2012-10-27 15:59:16 +00:00
|
|
|
uint8_t *planes[MP_MAX_PLANES];
|
2005-02-24 16:52:18 +00:00
|
|
|
int stride[MP_MAX_PLANES];
|
2012-12-31 00:58:25 +00:00
|
|
|
|
2002-10-29 11:26:26 +00:00
|
|
|
int pict_type; // 0->unknown, 1->I, 2->P, 3->B
|
2003-08-18 14:49:06 +00:00
|
|
|
int fields;
|
2012-12-31 00:58:25 +00:00
|
|
|
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
/* only inside filter chain */
|
|
|
|
double pts;
|
2016-01-25 19:47:13 +00:00
|
|
|
/* only after decoder */
|
2016-12-21 17:18:24 +00:00
|
|
|
double dts, pkt_duration;
|
2018-04-19 15:42:14 +00:00
|
|
|
/* container reported FPS; can be incorrect, or 0 if unknown */
|
|
|
|
double nominal_fps;
|
2012-12-12 22:55:41 +00:00
|
|
|
/* for private use */
|
2002-07-20 16:26:49 +00:00
|
|
|
void* priv;
|
video: replace our own refcounting with libavutil's
mpv had refcounted frames before libav*, so we were not using
libavutil's facilities. Change this and drop our own code.
Since AVFrames are not actually refcounted, and only the image data
they reference, the semantics change a bit. This affects mainly
mp_image_pool, which was operating on whole images instead of buffers.
While we could work on AVBufferRefs instead (and use AVBufferPool),
this doesn't work for use with hardware decoding, which doesn't
map cleanly to FFmpeg's reference counting. But it worked out. One
weird consequence is that we still need our custom image data
allocation function (for normal image data), because AVFrame's uses
multiple buffers.
There also seems to be a timing-dependent problem with vaapi (the
pool appears to be "leaking" surfaces). I don't know if this is a new
problem, or whether the code changes just happened to cause it more
often. Raising the number of reserved surfaces seemed to fix it, but
since it appears to be timing dependent, and I couldn't find anything
wrong with the code, I'm just going to assume it's not a new bug.
2015-07-05 21:56:00 +00:00
|
|
|
|
|
|
|
// Reference-counted data references.
|
|
|
|
// These do not necessarily map directly to planes[]. They can have
|
|
|
|
// different order or count. There shouldn't be more buffers than planes.
|
|
|
|
// If bufs[n] is NULL, bufs[n+1] must also be NULL.
|
|
|
|
// All mp_* functions manage this automatically; do not mess with it.
|
|
|
|
// (See also AVFrame.buf.)
|
|
|
|
struct AVBufferRef *bufs[MP_MAX_PLANES];
|
2016-04-15 13:07:02 +00:00
|
|
|
// Points to AVHWFramesContext* (same as AVFrame.hw_frames_ctx)
|
|
|
|
struct AVBufferRef *hwctx;
|
2017-07-25 21:06:27 +00:00
|
|
|
// Embedded ICC profile, if any
|
|
|
|
struct AVBufferRef *icc_profile;
|
2018-01-29 12:49:39 +00:00
|
|
|
// Closed captions packet, if any (only after decoder)
|
|
|
|
struct AVBufferRef *a53_cc;
|
2022-01-06 07:32:46 +00:00
|
|
|
// Dolby Vision metadata, if any
|
|
|
|
struct AVBufferRef *dovi;
|
2018-03-01 12:58:15 +00:00
|
|
|
// Other side data we don't care about.
|
|
|
|
struct mp_ff_side_data *ff_side_data;
|
|
|
|
int num_ff_side_data;
|
2002-01-16 00:14:59 +00:00
|
|
|
} mp_image_t;
|
|
|
|
|
2018-03-01 12:58:15 +00:00
|
|
|
struct mp_ff_side_data {
|
|
|
|
int type;
|
|
|
|
struct AVBufferRef *buf;
|
|
|
|
};
|
|
|
|
|
vo_opengl: change the way unaligned chroma size is handled
This deals with subsampled YUV video that has odd sizes, for example a
5x5 image with 4:2:0 subsampling.
It would be easy to handle if we actually passed separate texture
coordinates for each plane to the shader, but as of now the luma
coordinates are implicitly rescaled to chroma one. If luma and chroma
sizes don't match up, and this is not handled, you'd get a chroma shift
by 1 pixel.
The existing hack worked, but broke separable scaling. This was exposed
by a recent commit which switched to GL_NEAREST sampling for FBOs. The
rendering was accidentally scaled by 1 pixel, because the FBO size used
the original video size, while textures_sizes[0] was set to the padded
texture size (i.e. one pixel larger).
It could be fixed by setting the padded texture size only on the first
shader. But somehow that is annoying, so do something else. Don't pad
textures anymore, and rescale the chroma coordinates in the shader
instead.
Seems like this somehow doesn't work with rectangle textures (and
introduces a chroma shift), but since it's only used when doing VDA
hardware decoding, and the bug occurs only with unaligned video sizes, I
don't care much.
Fixes #1523.
2015-01-27 17:08:42 +00:00
|
|
|
int mp_chroma_div_up(int size, int shift);
|
|
|
|
|
2017-07-23 07:31:27 +00:00
|
|
|
int mp_image_get_alloc_size(int imgfmt, int w, int h, int stride_align);
|
|
|
|
struct mp_image *mp_image_from_buffer(int imgfmt, int w, int h, int stride_align,
|
|
|
|
uint8_t *buffer, int buffer_size,
|
|
|
|
void *free_opaque,
|
|
|
|
void (*free)(void *opaque, uint8_t *data));
|
|
|
|
|
2014-03-17 17:19:57 +00:00
|
|
|
struct mp_image *mp_image_alloc(int fmt, int w, int h);
|
2012-12-11 23:43:36 +00:00
|
|
|
void mp_image_copy(struct mp_image *dmpi, struct mp_image *mpi);
|
|
|
|
void mp_image_copy_attributes(struct mp_image *dmpi, struct mp_image *mpi);
|
|
|
|
struct mp_image *mp_image_new_copy(struct mp_image *img);
|
|
|
|
struct mp_image *mp_image_new_ref(struct mp_image *img);
|
|
|
|
bool mp_image_is_writeable(struct mp_image *img);
|
video: introduce failure path for image allocations
Until now, failure to allocate image data resulted in a crash (i.e.
abort() was called). This was intentional, because it's pretty silly to
degrade playback, and in almost all situations, the OOM will probably
kill you anyway. (And then there's the standard Linux overcommit
behavior, which also will kill you at some point.)
But I changed my opinion, so here we go. This change does not affect
_all_ memory allocations, just image data. Now in most failure cases,
the output will just be skipped. For video filters, this coincidentally
means that failure is treated as EOF (because the playback core assumes
EOF if nothing comes out of the video filter chain). In other
situations, output might be in some way degraded, like skipping frames,
not scaling OSD, and such.
Functions whose return values changed semantics:
mp_image_alloc
mp_image_new_copy
mp_image_new_ref
mp_image_make_writeable
mp_image_setrefp
mp_image_to_av_frame_and_unref
mp_image_from_av_frame
mp_image_new_external_ref
mp_image_new_custom_ref
mp_image_pool_make_writeable
mp_image_pool_get
mp_image_pool_new_copy
mp_vdpau_mixed_frame_create
vf_alloc_out_image
vf_make_out_image_writeable
glGetWindowScreenshot
2014-06-17 20:43:43 +00:00
|
|
|
bool mp_image_make_writeable(struct mp_image *img);
|
2012-12-11 23:43:36 +00:00
|
|
|
void mp_image_setrefp(struct mp_image **p_img, struct mp_image *new_value);
|
|
|
|
void mp_image_unrefp(struct mp_image **p_img);
|
|
|
|
|
2012-12-26 20:13:58 +00:00
|
|
|
void mp_image_clear(struct mp_image *mpi, int x0, int y0, int x1, int y1);
|
2020-05-22 12:18:35 +00:00
|
|
|
void mp_image_clear_rc(struct mp_image *mpi, struct mp_rect rc);
|
|
|
|
void mp_image_clear_rc_inv(struct mp_image *mpi, struct mp_rect rc);
|
2012-12-25 21:29:49 +00:00
|
|
|
void mp_image_crop(struct mp_image *img, int x0, int y0, int x1, int y1);
|
|
|
|
void mp_image_crop_rc(struct mp_image *img, struct mp_rect rc);
|
2013-03-01 10:28:59 +00:00
|
|
|
void mp_image_vflip(struct mp_image *img);
|
2012-12-25 21:29:49 +00:00
|
|
|
|
2012-11-10 01:02:24 +00:00
|
|
|
void mp_image_set_size(struct mp_image *mpi, int w, int h);
|
2015-04-10 18:58:26 +00:00
|
|
|
int mp_image_plane_w(struct mp_image *mpi, int plane);
|
|
|
|
int mp_image_plane_h(struct mp_image *mpi, int plane);
|
2012-11-10 01:02:24 +00:00
|
|
|
|
2014-03-17 17:19:57 +00:00
|
|
|
void mp_image_setfmt(mp_image_t* mpi, int out_fmt);
|
2012-12-11 23:43:36 +00:00
|
|
|
void mp_image_steal_data(struct mp_image *dst, struct mp_image *src);
|
2017-02-20 12:15:50 +00:00
|
|
|
void mp_image_unref_data(struct mp_image *img);
|
2012-12-11 23:43:36 +00:00
|
|
|
|
Implement backwards playback
See manpage additions. This is a huge hack. You can bet there are shit
tons of bugs. It's literally forcing square pegs into round holes.
Hopefully, the manpage wall of text makes it clear enough that the whole
shit can easily crash and burn. (Although it shouldn't literally crash.
That would be a bug. It possibly _could_ start a fire by entering some
sort of endless loop, not a literal one, just something where it tries
to do work without making progress.)
(Some obvious bugs I simply ignored for this initial version, but
there's a number of potential bugs I can't even imagine. Normal playback
should remain completely unaffected, though.)
How this works is also described in the manpage. Basically, we demux in
reverse, then we decode in reverse, then we render in reverse.
The decoding part is the simplest: just reorder the decoder output. This
weirdly integrates with the timeline/ordered chapter code, which also
has special requirements on feeding the packets to the decoder in a
non-straightforward way (it doesn't conflict, although a bugmessmass
breaks correct slicing of segments, so EDL/ordered chapter playback is
broken in backward direction).
Backward demuxing is pretty involved. In theory, it could be much
easier: simply iterating the usual demuxer output backward. But this
just doesn't fit into our code, so there's a cthulhu nightmare of shit.
To be specific, each stream (audio, video) is reversed separately. At
least this means we can do backward playback within cached content (for
example, you could play backwards in a live stream; on that note, it
disables prefetching, which would lead to losing new live video, but
this could be avoided).
The fuckmess also meant that I didn't bother trying to support
subtitles. Subtitles are a problem because they're "sparse" streams.
They need to be "passively" demuxed: you don't try to read a subtitle
packet, you demux audio and video, and then look whether there was a
subtitle packet. This means to get subtitles for a time range, you need
to know that you demuxed video and audio over this range, which becomes
pretty messy when you demux audio and video backwards separately.
Backward display is the most weird (and potentially buggy) part. To
avoid that we need to touch a LOT of timing code, we negate all
timestamps. The basic idea is that due to the navigation, all
comparisons and subtractions of timestamps keep working, and you don't
need to touch every single of them to "reverse" them.
E.g.:
bool before = pts_a < pts_b;
would need to be:
bool before = forward
? pts_a < pts_b
: pts_a > pts_b;
or:
bool before = pts_a * dir < pts_b * dir;
or if you, as it's implemented now, just do this after decoding:
pts_a *= dir;
pts_b *= dir;
and then in the normal timing/renderer code:
bool before = pts_a < pts_b;
Consequently, we don't need many changes in the latter code. But some
assumptions inhererently true for forward playback may have been broken
anyway. What is mainly needed is fixing places where values are passed
between positive and negative "domains". For example, seeking and
timestamp user display always uses positive timestamps. The main mess is
that it's not obvious which domain a given variable should or does use.
Well, in my tests with a single file, it suddenly started to work when I
did this. I'm honestly surprised that it did, and that I didn't have to
change a single line in the timing code past decoder (just something
minor to make external/cached text subtitles display). I committed it
immediately while avoiding thinking about it. But there really likely
are subtle problems of all sorts.
As far as I'm aware, gstreamer also supports backward playback. When I
looked at this years ago, I couldn't find a way to actually try this,
and I didn't revisit it now. Back then I also read talk slides from the
person who implemented it, and I'm not sure if and which ideas I might
have taken from it. It's possible that the timestamp reversal is
inspired by it, but I didn't check. (I think it claimed that it could
avoid large changes by changing a sign?)
VapourSynth has some sort of reverse function, which provides a backward
view on a video. The function itself is trivial to implement, as
VapourSynth aims to provide random access to video by frame numbers (so
you just request decreasing frame numbers). From what I remember, it
wasn't exactly fluid, but it worked. It's implemented by creating an
index, and seeking to the target on demand, and a bunch of caching. mpv
could use it, but it would either require using VapourSynth as demuxer
and decoder for everything, or replacing the current file every time
something is supposed to be played backwards.
FFmpeg's libavfilter has reversal filters for audio and video. These
require buffering the entire media data of the file, and don't really
fit into mpv's architecture. It could be used by playing a libavfilter
graph that also demuxes, but that's like VapourSynth but worse.
2019-05-18 00:10:51 +00:00
|
|
|
int mp_image_approx_byte_size(struct mp_image *img);
|
|
|
|
|
video: replace our own refcounting with libavutil's
mpv had refcounted frames before libav*, so we were not using
libavutil's facilities. Change this and drop our own code.
Since AVFrames are not actually refcounted, and only the image data
they reference, the semantics change a bit. This affects mainly
mp_image_pool, which was operating on whole images instead of buffers.
While we could work on AVBufferRefs instead (and use AVBufferPool),
this doesn't work for use with hardware decoding, which doesn't
map cleanly to FFmpeg's reference counting. But it worked out. One
weird consequence is that we still need our custom image data
allocation function (for normal image data), because AVFrame's uses
multiple buffers.
There also seems to be a timing-dependent problem with vaapi (the
pool appears to be "leaking" surfaces). I don't know if this is a new
problem, or whether the code changes just happened to cause it more
often. Raising the number of reserved surfaces seemed to fix it, but
since it appears to be timing dependent, and I couldn't find anything
wrong with the code, I'm just going to assume it's not a new bug.
2015-07-05 21:56:00 +00:00
|
|
|
struct mp_image *mp_image_new_dummy_ref(struct mp_image *img);
|
2012-12-11 23:43:36 +00:00
|
|
|
struct mp_image *mp_image_new_custom_ref(struct mp_image *img, void *arg,
|
|
|
|
void (*free)(void *arg));
|
2002-04-20 22:24:19 +00:00
|
|
|
|
2013-06-29 22:27:50 +00:00
|
|
|
void mp_image_params_guess_csp(struct mp_image_params *params);
|
|
|
|
|
2014-11-12 18:19:16 +00:00
|
|
|
char *mp_image_params_to_str_buf(char *b, size_t bs,
|
|
|
|
const struct mp_image_params *p);
|
2017-08-21 12:56:07 +00:00
|
|
|
#define mp_image_params_to_str(p) mp_image_params_to_str_buf((char[256]){0}, 256, p)
|
2014-11-12 18:19:16 +00:00
|
|
|
|
2014-06-17 20:44:13 +00:00
|
|
|
bool mp_image_params_valid(const struct mp_image_params *p);
|
2014-06-17 21:30:16 +00:00
|
|
|
bool mp_image_params_equal(const struct mp_image_params *p1,
|
|
|
|
const struct mp_image_params *p2);
|
2013-07-18 11:17:56 +00:00
|
|
|
|
2015-12-19 19:04:31 +00:00
|
|
|
void mp_image_params_get_dsize(const struct mp_image_params *p,
|
|
|
|
int *d_w, int *d_h);
|
|
|
|
void mp_image_params_set_dsize(struct mp_image_params *p, int d_w, int d_h);
|
|
|
|
|
2013-07-18 11:42:57 +00:00
|
|
|
void mp_image_set_params(struct mp_image *image,
|
|
|
|
const struct mp_image_params *params);
|
|
|
|
|
2013-11-03 22:55:16 +00:00
|
|
|
void mp_image_set_attributes(struct mp_image *image,
|
|
|
|
const struct mp_image_params *params);
|
|
|
|
|
2013-03-09 19:21:12 +00:00
|
|
|
struct AVFrame;
|
2013-03-09 19:50:06 +00:00
|
|
|
struct mp_image *mp_image_from_av_frame(struct AVFrame *av_frame);
|
2016-04-15 13:33:53 +00:00
|
|
|
struct AVFrame *mp_image_to_av_frame(struct mp_image *img);
|
2013-03-10 18:30:48 +00:00
|
|
|
struct AVFrame *mp_image_to_av_frame_and_unref(struct mp_image *img);
|
2013-03-09 19:21:12 +00:00
|
|
|
|
2015-03-19 23:21:23 +00:00
|
|
|
void memcpy_pic(void *dst, const void *src, int bytesPerLine, int height,
|
|
|
|
int dstStride, int srcStride);
|
|
|
|
void memset_pic(void *dst, int fill, int bytesPerLine, int height, int stride);
|
|
|
|
void memset16_pic(void *dst, int fill, int unitsPerLine, int height, int stride);
|
|
|
|
|
2020-05-02 21:48:43 +00:00
|
|
|
void *mp_image_pixel_ptr(struct mp_image *img, int plane, int x, int y);
|
2020-05-17 12:57:13 +00:00
|
|
|
void *mp_image_pixel_ptr_ny(struct mp_image *img, int plane, int x, int y);
|
2020-05-02 21:48:43 +00:00
|
|
|
size_t mp_image_plane_bytes(struct mp_image *img, int plane, int x0, int w);
|
|
|
|
|
2008-02-22 09:09:46 +00:00
|
|
|
#endif /* MPLAYER_MP_IMAGE_H */
|