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
|
|
|
|
|
|
|
struct mp_image_pool *mp_image_pool_new(int max_count);
|
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);
|
|
|
|
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);
|
|
|
|
|
|
|
|
#endif
|