From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 01E46420F1 for ; Thu, 16 Dec 2021 10:33:25 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3DF9868AE57; Thu, 16 Dec 2021 12:33:23 +0200 (EET) Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 78D3B68A486 for ; Thu, 16 Dec 2021 12:33:17 +0200 (EET) Received: by mail-ed1-f52.google.com with SMTP id z29so5184387edl.7 for ; Thu, 16 Dec 2021 02:33:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=ufwSjYeEnx/CQhKanVljr6hYyhQfN0ZvrAv/4HhQFMg=; b=heyJpRZTD+JPn1FsOShEeNFpL1MLJxPRe6KaIwRBo3Ir4jPNsvFqs/v7UP9PiV2BvL FCtLUdfiVR1doVDrtdZVrxoAv5ylmRBMHskwHBBYFCtimCcFj40iWMfuqnU9XGe/YQqt jf/uP1sCB3HhO4VNFK72ms84k+RSvSf/drwD/9ILfCi2p6aK3yettkmnj8xycWJeJB/I A5lrmxPQrSnAEP2RRcEMrbZLMGLaq+pcAvoFgHTuhpO3qJjwbG319/rN+mObyPxbSKm5 ooEw1YkUFt7+ege/DVJFgYa8StQ4F0qMvkQadG1bVvcfOiQo07OmQati6gEQfWijx4Kr Hduw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=ufwSjYeEnx/CQhKanVljr6hYyhQfN0ZvrAv/4HhQFMg=; b=haeK+eUh7jtQlACdqCXtZApD8xN5J+EUEQ7Fpd5vJvNU6gdVUp384uKtyl8v8SrrYr EyNhUEGgjXyB1bo5JJAmz618+ZRvEGlQAf2y5d8e20GY8QbiUCYkfmsJAb2rB7rTtv1M HzKwIg9v21yFEZwAUogzBVZz1NadVX/c3E71CL2mLs9UvR8Cu1NoZzETX4fcn/+HTJya DApwKuEy/7Aljkh7mPbl2Rj40m5LO1jmmbd/LA37CUMIiZE+VcP0pSSmD3huYMQW914S vBtOB4DXL4u71jixlkVhF7qWswfja6PvMhz+vyZNZ0cLPhBp1mqJwr/5pXYCtKuVhYDy KaPw== X-Gm-Message-State: AOAM530w4SqaaX308zMgOENVWLI70Sf7H4OwsfUzKxmti67P+PHXmddJ TkIKGUokWrkmxRQM6jOgo+yUtbRoQvQ= X-Google-Smtp-Source: ABdhPJwasKro9T8PYqq3x4SgoyhxPfgkRt1b5yA9jUYzBThfu9g2zY8h4KersmuYsc1qdicBT36Vog== X-Received: by 2002:a17:906:1706:: with SMTP id c6mr15147500eje.343.1639650796146; Thu, 16 Dec 2021 02:33:16 -0800 (PST) Received: from localhost.localdomain ([95.168.120.84]) by smtp.gmail.com with ESMTPSA id sh30sm1684256ejc.117.2021.12.16.02.33.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 02:33:15 -0800 (PST) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Thu, 16 Dec 2021 11:33:16 +0100 Message-Id: <20211216103316.920100-1-onemda@gmail.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avcodec/cdgraphics: fix transparency handling X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Signed-off-by: Paul B Mahol --- libavcodec/cdgraphics.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libavcodec/cdgraphics.c b/libavcodec/cdgraphics.c index c9e265fa53..06f8392094 100644 --- a/libavcodec/cdgraphics.c +++ b/libavcodec/cdgraphics.c @@ -68,7 +68,7 @@ typedef struct CDGraphicsContext { AVFrame *frame; int hscroll; int vscroll; - int transparency; + uint8_t alpha[CDG_PALETTE_SIZE]; int cleared; } CDGraphicsContext; @@ -79,7 +79,9 @@ static av_cold int cdg_decode_init(AVCodecContext *avctx) cc->frame = av_frame_alloc(); if (!cc->frame) return AVERROR(ENOMEM); - cc->transparency = -1; + + for (int i = 0; i < CDG_PALETTE_SIZE; i++) + cc->alpha[i] = 0xFFU; avctx->pix_fmt = AV_PIX_FMT_PAL8; return ff_set_dimensions(avctx, CDG_FULL_WIDTH, CDG_FULL_HEIGHT); @@ -120,9 +122,7 @@ static void cdg_load_palette(CDGraphicsContext *cc, uint8_t *data, int low) r = ((color >> 8) & 0x000F) * 17; g = ((color >> 4) & 0x000F) * 17; b = ((color ) & 0x000F) * 17; - palette[i + array_offset] = 0xFFU << 24 | r << 16 | g << 8 | b; - if (cc->transparency >= 0) - palette[cc->transparency] &= 0xFFFFFF; + palette[i + array_offset] = cc->alpha[i + array_offset] << 24 | r << 16 | g << 8 | b; } cc->frame->palette_has_changed = 1; } @@ -346,7 +346,8 @@ static int cdg_decode_frame(AVCodecContext *avctx, return ret; break; case CDG_INST_TRANSPARENT_COL: - cc->transparency = cdg_data[0] & 0xF; + for (int i = 0; i < CDG_PALETTE_SIZE; i++) + cc->alpha[i] = 255 - ((cdg_data[i] & 0x3f) << 2); break; default: break; -- 2.33.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".