2012-12-12 22:55:34 +00:00
|
|
|
#ifndef MPV_MP_IMAGE_POOL_H
|
|
|
|
#define MPV_MP_IMAGE_POOL_H
|
|
|
|
|
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
|
|
|
#include <stdbool.h>
|
|
|
|
|
2013-07-27 22:10:58 +00:00
|
|
|
struct mp_image_pool;
|
2012-12-12 22:55:34 +00:00
|
|
|
|
2018-01-12 00:40:01 +00:00
|
|
|
struct mp_image_pool *mp_image_pool_new(void *tparent);
|
2014-03-17 17:19:57 +00:00
|
|
|
struct mp_image *mp_image_pool_get(struct mp_image_pool *pool, int fmt,
|
2012-12-12 22:55:34 +00:00
|
|
|
int w, int h);
|
2016-02-16 00:04:52 +00:00
|
|
|
// the reference to "new" is transferred to the pool
|
|
|
|
void mp_image_pool_add(struct mp_image_pool *pool, struct mp_image *new);
|
2012-12-12 22:55:34 +00:00
|
|
|
void mp_image_pool_clear(struct mp_image_pool *pool);
|
|
|
|
|
2014-03-17 17:21:29 +00:00
|
|
|
void mp_image_pool_set_lru(struct mp_image_pool *pool);
|
|
|
|
|
|
|
|
struct mp_image *mp_image_pool_get_no_alloc(struct mp_image_pool *pool, int fmt,
|
|
|
|
int w, int h);
|
|
|
|
|
|
|
|
typedef struct mp_image *(*mp_image_allocator)(void *data, int fmt, int w, int h);
|
|
|
|
void mp_image_pool_set_allocator(struct mp_image_pool *pool,
|
|
|
|
mp_image_allocator cb, void *cb_data);
|
|
|
|
|
2012-12-12 22:55:34 +00:00
|
|
|
struct mp_image *mp_image_pool_new_copy(struct mp_image_pool *pool,
|
|
|
|
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_pool_make_writeable(struct mp_image_pool *pool,
|
2012-12-12 22:55:34 +00:00
|
|
|
struct mp_image *img);
|
|
|
|
|
2017-01-12 11:51:55 +00:00
|
|
|
struct mp_image *mp_image_hw_download(struct mp_image *img,
|
|
|
|
struct mp_image_pool *swpool);
|
|
|
|
|
2019-10-02 19:07:14 +00:00
|
|
|
int mp_image_hw_download_get_sw_format(struct mp_image *img);
|
|
|
|
|
2017-09-29 15:54:21 +00:00
|
|
|
bool mp_image_hw_upload(struct mp_image *hw_img, struct mp_image *src);
|
|
|
|
|
2018-01-16 10:46:16 +00:00
|
|
|
struct AVBufferRef;
|
|
|
|
bool mp_update_av_hw_frames_pool(struct AVBufferRef **hw_frames_ctx,
|
|
|
|
struct AVBufferRef *hw_device_ctx,
|
2023-02-28 05:11:39 +00:00
|
|
|
int imgfmt, int sw_imgfmt, int w, int h,
|
|
|
|
bool disable_multiplane);
|
2018-01-16 10:46:16 +00:00
|
|
|
|
|
|
|
struct mp_image *mp_av_pool_image_hw_upload(struct AVBufferRef *hw_frames_ctx,
|
|
|
|
struct mp_image *src);
|
|
|
|
|
2022-04-04 03:12:50 +00:00
|
|
|
struct mp_image *mp_av_pool_image_hw_map(struct AVBufferRef *hw_frames_ctx,
|
|
|
|
struct mp_image *src);
|
2012-12-12 22:55:34 +00:00
|
|
|
#endif
|