summaryrefslogtreecommitdiffstats
path: root/video/image_writer.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-06-17 22:43:43 +0200
committerwm4 <wm4@nowhere>2014-06-17 22:43:43 +0200
commit72aac9ae8a0053e7c30199044cc2c9493a39b793 (patch)
tree90c61f53e20aac949fd4c513267d080814ebf4a8 /video/image_writer.c
parent973c1fa5701366eed3752666d6035454ae37712c (diff)
downloadmpv-72aac9ae8a0053e7c30199044cc2c9493a39b793.tar.bz2
mpv-72aac9ae8a0053e7c30199044cc2c9493a39b793.tar.xz
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
Diffstat (limited to 'video/image_writer.c')
-rw-r--r--video/image_writer.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/video/image_writer.c b/video/image_writer.c
index f769fd9f27..c6da4ff7e5 100644
--- a/video/image_writer.c
+++ b/video/image_writer.c
@@ -289,6 +289,10 @@ int write_image(struct mp_image *image, const struct image_writer_opts *opts,
// it's unclear what colorspace/levels the target wants
if (image->imgfmt != destfmt || is_anamorphic) {
struct mp_image *dst = mp_image_alloc(destfmt, d_w, d_h);
+ if (!dst) {
+ mp_err(log, "Out of memory.\n");
+ return 0;
+ }
mp_image_copy_attributes(dst, image);
mp_image_swscale(dst, image, mp_sws_hq_flags);