mirror of
https://github.com/mpv-player/mpv
synced 2024-12-27 09:32:40 +00:00
72aac9ae8a
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
28 lines
1009 B
C
28 lines
1009 B
C
#ifndef MPV_MP_IMAGE_POOL_H
|
|
#define MPV_MP_IMAGE_POOL_H
|
|
|
|
#include <stdbool.h>
|
|
|
|
struct mp_image_pool;
|
|
|
|
struct mp_image_pool *mp_image_pool_new(int max_count);
|
|
struct mp_image *mp_image_pool_get(struct mp_image_pool *pool, int fmt,
|
|
int w, int h);
|
|
void mp_image_pool_clear(struct mp_image_pool *pool);
|
|
|
|
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);
|
|
|
|
struct mp_image *mp_image_pool_new_copy(struct mp_image_pool *pool,
|
|
struct mp_image *img);
|
|
bool mp_image_pool_make_writeable(struct mp_image_pool *pool,
|
|
struct mp_image *img);
|
|
|
|
#endif
|