From e3cad491158685693621407fe73a529fa8d29035 Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux <ajanni@videolabs.io> Date: Tue, 10 Sep 2024 13:30:12 +0200 Subject: [PATCH] vpx_alpha: early-return during merging Early return to avoid mixing the allocation path and the re-use path, making two level of indentation useless. Indentation is changed in the follow-up commit. --- modules/codec/vpx_alpha.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/codec/vpx_alpha.c b/modules/codec/vpx_alpha.c index b1a3e4b8fac9..d857e9a01528 100644 --- a/modules/codec/vpx_alpha.c +++ b/modules/codec/vpx_alpha.c @@ -128,17 +128,26 @@ static picture_t *CombinePicturesCPU(decoder_t *bdec, picture_t *opaque, picture for (int i=0; i<opaque->i_planes; i++) out->p[i] = opaque->p[i]; + if (alpha) + { out->p[opaque->i_planes] = alpha->p[0]; - else + return out; + } + { // use the dummy opaque plane attached in the picture context struct pic_alpha_plane *p = alpha_ctx->plane; - if (out->p_sys == NULL) + if (p == NULL) { int plane_size = bdec->fmt_out.video.i_width * bdec->fmt_out.video.i_height; p = malloc(sizeof(*p) + plane_size); - if (likely(p != NULL)) + if (unlikely(p == NULL)) + { + picture_Release(out); + return NULL; + } + { p->p.i_lines = bdec->fmt_out.video.i_height; p->p.i_visible_lines = bdec->fmt_out.video.i_y_offset + bdec->fmt_out.video.i_visible_height; @@ -152,11 +161,6 @@ static picture_t *CombinePicturesCPU(decoder_t *bdec, picture_t *opaque, picture alpha_ctx->plane = p; } } - if (unlikely(p == NULL)) - { - picture_Release(out); - return NULL; - } out->p[opaque->i_planes] = p->p; } return out; -- GitLab