diff options
author | sfan5 <sfan5@live.de> | 2023-01-10 18:59:21 +0100 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2023-01-12 22:02:07 +0100 |
commit | 7b03cd367dd5416a4728ccea7e47dcd2827cbab7 (patch) | |
tree | cea4075b81850000890f55d6cd01de117a2138a0 /video | |
parent | b6b83805183618f3a46f2cc77d85dcff72ef6396 (diff) | |
download | mpv-7b03cd367dd5416a4728ccea7e47dcd2827cbab7.tar.bz2 mpv-7b03cd367dd5416a4728ccea7e47dcd2827cbab7.tar.xz |
various: replace if + abort() with MP_HANDLE_OOM()
MP_HANDLE_OOM also aborts but calls assert() first, which
will result in an useful message if compiled in debug mode.
Diffstat (limited to 'video')
-rw-r--r-- | video/filter/refqueue.c | 6 | ||||
-rw-r--r-- | video/filter/vf_d3d11vpp.c | 3 | ||||
-rw-r--r-- | video/filter/vf_vavpp.c | 3 | ||||
-rw-r--r-- | video/mp_image.c | 12 | ||||
-rw-r--r-- | video/out/dr_helper.c | 3 | ||||
-rw-r--r-- | video/out/gpu/lcms.c | 6 | ||||
-rw-r--r-- | video/out/gpu/shader_cache.c | 3 | ||||
-rw-r--r-- | video/out/vo.c | 3 | ||||
-rw-r--r-- | video/out/vo_lavc.c | 3 |
9 files changed, 14 insertions, 28 deletions
diff --git a/video/filter/refqueue.c b/video/filter/refqueue.c index 964fa29c08..e97e85bfaa 100644 --- a/video/filter/refqueue.c +++ b/video/filter/refqueue.c @@ -68,8 +68,7 @@ struct mp_refqueue *mp_refqueue_alloc(struct mp_filter *f) q->filter = f; q->conv = mp_autoconvert_create(f); - if (!q->conv) - abort(); + MP_HANDLE_OOM(q->conv); q->in = q->conv->f->pins[1]; mp_pin_connect(q->conv->f->pins[0], f->ppins[0]); @@ -267,8 +266,7 @@ struct mp_image *mp_refqueue_execute_reinit(struct mp_refqueue *q) mp_refqueue_flush(q); q->in_format = mp_image_new_ref(cur); - if (!q->in_format) - abort(); + MP_HANDLE_OOM(q->in_format); mp_image_unref_data(q->in_format); mp_refqueue_add_input(q, cur); diff --git a/video/filter/vf_d3d11vpp.c b/video/filter/vf_d3d11vpp.c index df029417b9..2f05219976 100644 --- a/video/filter/vf_d3d11vpp.c +++ b/video/filter/vf_d3d11vpp.c @@ -102,8 +102,7 @@ static struct mp_image *alloc_pool(void *pctx, int fmt, int w, int h) return NULL; struct mp_image *mpi = mp_image_new_custom_ref(NULL, texture, release_tex); - if (!mpi) - abort(); + MP_HANDLE_OOM(mpi); mp_image_setfmt(mpi, IMGFMT_D3D11); mp_image_set_size(mpi, w, h); diff --git a/video/filter/vf_vavpp.c b/video/filter/vf_vavpp.c index 8d58fb173b..affb1a1c48 100644 --- a/video/filter/vf_vavpp.c +++ b/video/filter/vf_vavpp.c @@ -172,8 +172,7 @@ static struct mp_image *alloc_out(struct mp_filter *vf) } AVFrame *av_frame = av_frame_alloc(); - if (!av_frame) - abort(); + MP_HANDLE_OOM(av_frame); if (av_hwframe_get_buffer(p->hw_pool, av_frame, 0) < 0) { MP_ERR(vf, "Failed to allocate frame from hw pool.\n"); av_frame_free(&av_frame); diff --git a/video/mp_image.c b/video/mp_image.c index 533061465d..6c28a54c47 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -1102,24 +1102,21 @@ struct AVFrame *mp_image_to_av_frame(struct mp_image *src) dst->chroma_location = mp_chroma_location_to_av(src->params.chroma_location); dst->opaque_ref = av_buffer_alloc(sizeof(struct mp_image_params)); - if (!dst->opaque_ref) - abort(); + MP_HANDLE_OOM(dst->opaque_ref); *(struct mp_image_params *)dst->opaque_ref->data = src->params; if (src->icc_profile) { AVFrameSideData *sd = av_frame_new_side_data_from_buf(dst, AV_FRAME_DATA_ICC_PROFILE, new_ref->icc_profile); - if (!sd) - abort(); + MP_HANDLE_OOM(sd); new_ref->icc_profile = NULL; } if (src->params.color.sig_peak) { AVContentLightMetadata *clm = av_content_light_metadata_create_side_data(dst); - if (!clm) - abort(); + MP_HANDLE_OOM(clm); clm->MaxCLL = src->params.color.sig_peak * MP_REF_WHITE; } @@ -1130,8 +1127,7 @@ struct AVFrame *mp_image_to_av_frame(struct mp_image *src) if (!av_frame_get_side_data(dst, mpsd->type)) { AVFrameSideData *sd = av_frame_new_side_data_from_buf(dst, mpsd->type, mpsd->buf); - if (!sd) - abort(); + MP_HANDLE_OOM(sd); mpsd->buf = NULL; } } diff --git a/video/out/dr_helper.c b/video/out/dr_helper.c index 78d4633efb..5b585f5528 100644 --- a/video/out/dr_helper.c +++ b/video/out/dr_helper.c @@ -140,8 +140,7 @@ static void sync_get_image(void *ptr) AVBufferRef *new_ref = av_buffer_create(ctx->ref->data, ctx->ref->size, free_dr_buffer_on_dr_thread, ctx, 0); - if (!new_ref) - abort(); // tiny malloc OOM + MP_HANDLE_OOM(new_ref); cmd->res->bufs[0] = new_ref; diff --git a/video/out/gpu/lcms.c b/video/out/gpu/lcms.c index b49b9614a2..3df5eba5f2 100644 --- a/video/out/gpu/lcms.c +++ b/video/out/gpu/lcms.c @@ -317,8 +317,7 @@ bool gl_lcms_get_lut3d(struct gl_lcms *p, struct lut3d **result_lut3d, if (vid_profile) { MP_VERBOSE(p, "Got an embedded ICC profile.\n"); p->vid_profile = av_buffer_ref(vid_profile); - if (!p->vid_profile) - abort(); + MP_HANDLE_OOM(p->vid_profile); } if (!gl_parse_3dlut_size(p->opts->size_str, &s_r, &s_g, &s_b)) @@ -344,8 +343,7 @@ bool gl_lcms_get_lut3d(struct gl_lcms *p, struct lut3d **result_lut3d, uint8_t hash[32]; struct AVSHA *sha = av_sha_alloc(); - if (!sha) - abort(); + MP_HANDLE_OOM(sha); av_sha_init(sha, 256); av_sha_update(sha, cache_info, strlen(cache_info)); if (vid_profile) diff --git a/video/out/gpu/shader_cache.c b/video/out/gpu/shader_cache.c index 5436881ded..1d5e563cb8 100644 --- a/video/out/gpu/shader_cache.c +++ b/video/out/gpu/shader_cache.c @@ -579,8 +579,7 @@ static bool create_pass(struct gl_shader_cache *sc, struct sc_entry *entry) cache_dir = mp_get_user_path(tmp, sc->global, sc->cache_dir); struct AVSHA *sha = av_sha_alloc(); - if (!sha) - abort(); + MP_HANDLE_OOM(sha); av_sha_init(sha, 256); av_sha_update(sha, entry->total.start, entry->total.len); diff --git a/video/out/vo.c b/video/out/vo.c index a5458b593e..cf806b2244 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -1431,8 +1431,7 @@ struct vo_frame *vo_frame_ref(struct vo_frame *frame) *new = *frame; for (int n = 0; n < frame->num_frames; n++) { new->frames[n] = mp_image_new_ref(frame->frames[n]); - if (!new->frames[n]) - abort(); // OOM on tiny allocs + MP_HANDLE_OOM(new->frames[n]); } new->current = new->num_frames ? new->frames[0] : NULL; return new; diff --git a/video/out/vo_lavc.c b/video/out/vo_lavc.c index e817b530e0..8e188b5aab 100644 --- a/video/out/vo_lavc.c +++ b/video/out/vo_lavc.c @@ -217,8 +217,7 @@ static void draw_frame(struct vo *vo, struct vo_frame *voframe) pthread_mutex_unlock(&ectx->lock); AVFrame *frame = mp_image_to_av_frame(mpi); - if (!frame) - abort(); + MP_HANDLE_OOM(frame); frame->pts = rint(outpts * av_q2d(av_inv_q(avc->time_base))); frame->pict_type = 0; // keep this at unknown/undefined |