From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 6AE004CBDE for ; Thu, 30 Oct 2025 15:23:35 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'gGAbb7F5QxjLFotqFlPmyefpLQBSS6QEdyOgBcZgyU8=', expected b'DhnbA4KZ2J2r7KBgcwayPJ9b0D475UkxnYr7AfI97ME=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1761837806; h=mime-version : to : date : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=gGAbb7F5QxjLFotqFlPmyefpLQBSS6QEdyOgBcZgyU8=; b=NFwvL8N1etI9xwursN/Y7X/2GJSfuXweqeAS4NSDLbLxTbFul6LungKCz3ApvdAgbUcWU UY/IP9s/ZfIg/irvgE2d1HcEyIcIw386INF5R+GyWaboKlNv8sidLpAeAMiHMS7qPdHL3JX WkBbg4kKdu34mCRhEH2fjGqoIjEI+QdPO9cN+lXKDr/QmHhw84WDY2H+Rvmglyd3TrSNBwe ACxwW6wBB30dpAz+45ZgBMAzBjx2hBCBIep17DYDPoidRwebYIUXaANftfHUEiMtMsp11R1 r6u8A5hN3kFi0E0XWVFT1cCornkgDTBH3HJ8ZkLcnTzkeI6Mr6YhEiNhbC9Q== Received: from [172.19.0.2] (unknown [172.19.0.2]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 76D5268F813; Thu, 30 Oct 2025 17:23:26 +0200 (EET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1761837789; b=hdmxXhqRu5n0SVaaeK0S1lFjDd6Z/zdX86wXGUrNdjtj4/sbde5l9w2woq6014Z/PtqQI uQo/p5x95QfghbVqcUy//gXGEXOC61htejqPXU0T/S7zAtHHhfcZ6sLePJltJfkOmuN5DOv LjdcRfEcl+f6lSqCbyPK15SwHjO6TCk+31+KZhjYMgLN1Z6ZVj7FJSv/GCkhx0vtYfd9TPs kGPQztDFptg12fgjM+8jE70jfmAORWKVOwhcH++2npxYle1vZcCi8gM2+yc+fLBPTRkui97 jy0Oeh9XVUZSBEps8Lrq6PoWoDJDbmASBNrt6/jJ30bFsw7n0YOZ3AKd9trA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1761837789; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=gOvPzuKQTzhPXIu1XZa8n9Dv2T3I5+cjPIjXGOLs+aI=; b=rsRsgYjjBmXUZnG90b97wbi9d3/my+EJDRCqs/M8xC5igrAutGY7W8yoGZlNFgh9znT2m sICdn4tt8KQ4FUcbN7Qv+CIyAUqC5eCFdhqnCWfGfKfY6nzLsmAwqr/CStWaAB5pyVNskcw m1obrW1e7ocqbvHCLUm8T0Dqg9+Lywl2eQwqmz9ms0w7QQq9C8YgYwH9nbT1nbk1Nax5CC/ DhRELsV6vFob50M5ON9SH3bvjUjutohflKOrs8IGE5L+a20q9Nasb6OcyhU+0eqcsd4AJJL z8K1AA3X7OLrOnONQGk9kvPnWpe74yClNj+QxN2/MFhkjKKpdTKCo74FXSRA== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=pass header.from=ffmpeg.org policy.dmarc=quarantine Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=ffmpeg.org policy.dmarc=quarantine DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1761837782; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=DhnbA4KZ2J2r7KBgcwayPJ9b0D475UkxnYr7AfI97ME=; b=eLwJ9UEziNGxI+OEu6+t4kHQBo6uLSccKN90E1lImH9jDGCxfxRwo8pLlJNVbpXvpLOG5 yBEvSyVWnSNEZ+pgbjn23V2IfHwmlokS7woG4szCq9JtU586R0M3ysz1SiZ5XyJ+4iy90Zd xNAUZhidPusgJroGQtNPU7MmhdSV74HaBY3837DTBZ4EYyE/lInXmbwi8LVFEBR4FalqAch RBnnSIlv8HCIA0gd2D+Z/unFpfolxtLq+b/RzPJO24qKtz9mlBGwZBZybeA3oOLmUjnXYED 7w+H9pJYSZXi9vBk7fPWMOd72LJD13npxPhT3LUq5JvV5sAtbiYxI1tG7KTg== Received: from 02c22a36bd31 (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 47DA168F4B2 for ; Thu, 30 Oct 2025 17:23:02 +0200 (EET) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Thu, 30 Oct 2025 15:23:01 -0000 Message-ID: <176183778240.81.5458891861110094331@7d278768979e> Message-ID-Hash: N3DYZPZ4H6B6R5OGIG3RUFJ5GR6VMKQX X-Message-ID-Hash: N3DYZPZ4H6B6R5OGIG3RUFJ5GR6VMKQX X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH] avcodec/sanm: implement codec45 (PR #20795) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Manuel Lauss via ffmpeg-devel Cc: Manuel Lauss Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #20795 opened by Manuel Lauss (mlauss2) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20795 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20795.patch This is another post-processing codec: it sums the r/g/b componentes of the 4 surrounding pixels, and uses the 15bit-rgb value as an index into a second table to find a matching pixel. It is only used in the first 10-20 frames of the Rebel Assault 2 LxxRETRY.SAN files to slightly blur the outline of the "opening aperture" effect. Signed-off-by: Manuel Lauss >>From 137913ee994bf18fd3444b76893237474ec93ef4 Mon Sep 17 00:00:00 2001 From: Manuel Lauss Date: Thu, 30 Oct 2025 16:01:10 +0100 Subject: [PATCH] avcodec/sanm: implement codec45 This is another post-processing codec: it sums the r/g/b componentes of the 4 surrounding pixels, and uses the 15bit-rgb value as an index into a second table to find a matching pixel. It is only used in 10-20 frames of the Rebel Assault 2 LxxRETRY.SAN files to slightly blur the outline of the "opening aperture" effect. Signed-off-by: Manuel Lauss --- libavcodec/sanm.c | 77 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 75 insertions(+), 2 deletions(-) diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c index 742fc1d477..1d04edc672 100644 --- a/libavcodec/sanm.c +++ b/libavcodec/sanm.c @@ -297,6 +297,8 @@ typedef struct SANMVideoContext { uint8_t c4tbl[2][256][16]; uint16_t c4param; uint8_t c47cb[4]; + uint8_t c45tbl1[0x300]; + uint8_t c45tbl2[0x8000]; } SANMVideoContext; enum GlyphEdge { @@ -1946,6 +1948,71 @@ static int old_codec48(SANMVideoContext *ctx, GetByteContext *gb, int top, int l return 0; } +static void old_codec45(SANMVideoContext *ctx, GetByteContext *gb, int top, int left, int flag) +{ + int t1, t2, i; + int16_t x, y; + + if (bytestream2_get_bytes_left(gb) < 6) + return; + + bytestream2_skip(gb, 2); + t1 = bytestream2_get_le16u(gb); + t2 = bytestream2_get_byteu(gb); + bytestream2_skip(gb, 1); + if (t2 != 1) + return; + if (t1 == 0) { + if (bytestream2_get_bytes_left(gb) < 0x300) + return; + bytestream2_get_bufferu(gb, ctx->c45tbl1, 0x300); + i = 0; + while ((bytestream2_get_bytes_left(gb) > 1) && (i < 0x8000)) { + uint8_t len = bytestream2_get_byteu(gb); + uint8_t val = bytestream2_get_byteu(gb); + if ((i + len) > 0x8000) + len = 0x8000 - i; + memset(ctx->c45tbl2 + i, val, len); + i += len; + } + } + + if (flag) + return; + + x = left; + y = top; + while (bytestream2_get_bytes_left(gb) > 3) { + int16_t xd = bytestream2_get_le16u(gb); + int8_t yd = bytestream2_get_byteu(gb); + x += xd; + y += yd; + int len = bytestream2_get_byteu(gb); + while (len >= 0) { + if ((x > 0) && (y > 0) && (x < ctx->width - 1)) { + if (y >= ctx->height) + return; + + uint8_t *dst = (uint8_t *)ctx->fbuf + x + y * ctx->pitch; + unsigned int c1 = *(dst - 1) * 3; + unsigned int c2 = *(dst + 1) * 3; + unsigned int r = ctx->c45tbl1[c1 + 0] + ctx->c45tbl1[c2 + 0]; + unsigned int g = ctx->c45tbl1[c1 + 1] + ctx->c45tbl1[c2 + 1]; + unsigned int b = ctx->c45tbl1[c1 + 2] + ctx->c45tbl1[c2 + 2]; + c1 = *(dst - ctx->pitch) * 3; + c2 = *(dst + ctx->pitch) * 3; + r += ctx->c45tbl1[c1 + 0] + ctx->c45tbl1[c2 + 0]; + g += ctx->c45tbl1[c1 + 1] + ctx->c45tbl1[c2 + 1]; + b += ctx->c45tbl1[c1 + 2] + ctx->c45tbl1[c2 + 2]; + *dst = ctx->c45tbl2[((r << 5) & 0x7c00) | (g & 0x3e0) | (b >> 5)]; + } + x++; + len--; + } + x--; + } +} + static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb, int xoff, int yoff) { @@ -1964,6 +2031,12 @@ static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb, parm2 = bytestream2_get_le16u(gb); if (w < 1 || h < 1 || w > 640 || h > 480 || left > 640 || top > 480 || left + w <= 0 || top + h <= 0) { + /* codec45 frames with data for the 2 tables have nonsensical dimensions */ + if (codec == 45) { + old_codec45(ctx, gb, 0, 0, 1); + return 0; + } + av_log(ctx->avctx, AV_LOG_WARNING, "ignoring invalid fobj dimensions: c%d %d %d @ %d %d\n", codec, w, h, left, top); @@ -1980,7 +2053,7 @@ static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb, if ((w == 640) && (h == 272) && (top == 60) && (codec == 47)) left = top = 0; - if (!ctx->have_dimensions) { + if (!ctx->have_dimensions && (codec != 45)) { int xres, yres; if (ctx->subversion < 2) { /* Rebel Assault 1: 384x242 internal size */ @@ -2073,7 +2146,7 @@ static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb, case 37: return old_codec37(ctx, gb, top, left, w, h); break; case 45: - return 0; + old_codec45(ctx, gb, top, left, 0); break; case 47: return old_codec47(ctx, gb, top, left, w, h); break; case 48: -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org