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 ESMTPS id B86D44E43A for ; Tue, 11 Mar 2025 15:04:28 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B212668E120; Tue, 11 Mar 2025 17:03:58 +0200 (EET) Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0FA9768E106 for ; Tue, 11 Mar 2025 17:03:50 +0200 (EET) Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-3913958ebf2so2886127f8f.3 for ; Tue, 11 Mar 2025 08:03:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741705429; x=1742310229; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AvQgNr7mcroOYfzd02D5iux3dWdMBRcz7/FAWcCnWoY=; b=d98YvTm8xd6Y/8Px/wl8gz8ht2KCGUb9Ky5I6vwIcOozRvviw3mRvSwm160HKtwGVb oHKeCJ8P7op9UsYpy2s0bwwsEaZPvZb+M4fS9fecYoUoT7DU8h7BUwzUls/Uv2MXwncM 8GFUN9UTdS/y1oxluIehyWjiYA8SwBmt/eTQ6bylHdHvQY/uC437TGZSrREroNYBuwN7 gQihdc7wg3AwdkJpK9+/ZpotGFjEt7L908yqYevmcS4y8co81uwdb9yJfNBs10kR+4in QiHg+TwMJsF2Jxjd6Qvp3mscq0caS/V3bjpMfyOQStvc8HFozzIiuG0j+ysEqr7m8tV4 0E5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741705429; x=1742310229; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AvQgNr7mcroOYfzd02D5iux3dWdMBRcz7/FAWcCnWoY=; b=ZZm5j4ElGuREsxTBtMF7PSx+NrcnZ40FiDjLEeUtkaZOER/xaZ/NcWkePWE2PaxoYB VNjWioOCzwxxp2sEOMdfSqf287/Bp+8tKMXn+VpxoS3Snh4zW9EU8rNy1FDsBwMs4KS+ Nga8/nEh7aBY+pq7uJ3GC449zdARBOp24AGquPxEPnoKIztLyRgosan4TrjMfEf3VHQe 80LVA2aSUSvp4bmaSLOOmCLK8xJxlxeFpK27vSdmOgKu/cJ4KpEn+eFLPXCFyFCQ9284 tgLiqlkWtw7kioFKZQTJCW7Nv/QDtCAJDrc6EvaDyMO/sdZuzeIDD6rzu22xBhBYvPA6 OJLw== X-Gm-Message-State: AOJu0YyZBhixKKKFTRNYDJXpjxYjIf1Q5j9UzsVwjuvV/8XEddofFEIB GLtSK2LtQG6DpPf8y+DsaC5qkcDcaPd5bEo/vzIzOukP/DYCaK+DJ59jag== X-Gm-Gg: ASbGncufWTp3zSF0Cq/Rm/a6XKwNuw9g25JJkRD1pBiAvWTtoN2HELYYPtMLJHXizng H3MZOJtQo2RqnhNkxAP2JY7MLPn9CWGL65p02g6BeU/oOcjkoP83GdpufovVVctLwSQ5vtHT2VI yRyHD6X0X6H1rBEhxgELng7boOOZpPZ8GuAa+9c+jopG0EjeYbH/BLwvLjqhj4rdKUv7RgmIQIR 4TXnAJsbSp+8x6JCn8RtwtEQNmDwxYdxbd2Kytd98oF0q8830u6OYz12ej8Ed8DgLbMFM+0p/kG AoQHaTH169aLsLPDcK7pihtYhQzCB/vbTcouAwD9N2dXNhRJZBJBIMSEnqFmLumRt8qSrIjzx1K nortN1/U+TcrFf10wilsWZmLjdVYaP6iWKqqXrUC5jPFU62sDQCdD5yA= X-Google-Smtp-Source: AGHT+IGvwL0T4bvuIAM+pflbNkZVhd3TGkMB5mQDHw2EqN3UYNYGfqCeppPYAewNZN0sTtaxzJVV1Q== X-Received: by 2002:a05:6000:1863:b0:390:f902:f961 with SMTP id ffacd0b85a97d-3926c4afe6dmr5772399f8f.45.1741705428761; Tue, 11 Mar 2025 08:03:48 -0700 (PDT) Received: from flagship3.deu.mlau.at (p200300c0271f29004c5623f045c27bca.dip0.t-ipconnect.de. [2003:c0:271f:2900:4c56:23f0:45c2:7bca]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43ceaac390bsm115259215e9.35.2025.03.11.08.03.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Mar 2025 08:03:48 -0700 (PDT) From: Manuel Lauss To: ffmpeg-devel@ffmpeg.org Date: Tue, 11 Mar 2025 16:03:35 +0100 Message-ID: <20250311150341.348678-3-manuel.lauss@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250311150341.348678-1-manuel.lauss@gmail.com> References: <20250311150341.348678-1-manuel.lauss@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/9] avcodec/sanm: disable left/top for fullscreen codecs 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 Cc: Manuel Lauss 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: The block-based codecs 37/47/48 work on the full frame, and there's no existing LucasArts game video that uses left/top offsets for these, as it doesn't make sense. Ignore the left/top parameters for these codecs. Signed-off-by: Manuel Lauss --- Well, except for SotE, which uses "top" to move the widescreen video to the center of the 4:3 game window, but ffmpeg doesn't need do do that. libavcodec/sanm.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c index ca345bc61a..b2923515b1 100644 --- a/libavcodec/sanm.c +++ b/libavcodec/sanm.c @@ -621,8 +621,7 @@ static inline void codec37_mv(uint8_t *dst, const uint8_t *src, } } -static int old_codec37(SANMVideoContext *ctx, int top, - int left, int width, int height) +static int old_codec37(SANMVideoContext *ctx, int width, int height) { int i, j, k, l, t, run, len, code, skip, mx, my; ptrdiff_t stride = ctx->pitch; @@ -638,8 +637,8 @@ static int old_codec37(SANMVideoContext *ctx, int top, flags = bytestream2_get_byte(&ctx->gb); bytestream2_skip(&ctx->gb, 3); - if (decoded_size > ctx->height * stride - left - top * stride) { - decoded_size = ctx->height * stride - left - top * stride; + if (decoded_size > ctx->height * stride) { + decoded_size = ctx->height * stride; av_log(ctx->avctx, AV_LOG_WARNING, "Decoded size is too large.\n"); } @@ -649,8 +648,8 @@ static int old_codec37(SANMVideoContext *ctx, int top, FFSWAP(uint16_t*, ctx->frm1, ctx->frm2); } - dst = ((uint8_t*)ctx->frm1) + left + top * stride; - prev = ((uint8_t*)ctx->frm2) + left + top * stride; + dst = ((uint8_t*)ctx->frm1); + prev = ((uint8_t*)ctx->frm2); if (mvoff > 2) { av_log(ctx->avctx, AV_LOG_ERROR, "Invalid motion base value %d.\n", mvoff); @@ -923,15 +922,14 @@ static void codec47_comp1(SANMVideoContext *ctx, uint8_t *dst_in, int width, } } -static int old_codec47(SANMVideoContext *ctx, int top, - int left, int width, int height) +static int old_codec47(SANMVideoContext *ctx, int width, int height) { uint32_t decoded_size; int i, j; ptrdiff_t stride = ctx->pitch; - uint8_t *dst = (uint8_t *)ctx->frm0 + left + top * stride; - uint8_t *prev1 = (uint8_t *)ctx->frm1 + left + top * stride; - uint8_t *prev2 = (uint8_t *)ctx->frm2 + left + top * stride; + uint8_t *dst = (uint8_t *)ctx->frm0; + uint8_t *prev1 = (uint8_t *)ctx->frm1; + uint8_t *prev2 = (uint8_t *)ctx->frm2; uint8_t auxcol[2]; int tbl_pos = bytestream2_tell(&ctx->gb); int seq = bytestream2_get_le16(&ctx->gb); @@ -945,8 +943,8 @@ static int old_codec47(SANMVideoContext *ctx, int top, decoded_size = bytestream2_get_le32(&ctx->gb); bytestream2_skip(&ctx->gb, 8); - if (decoded_size > ctx->height * stride - left - top * stride) { - decoded_size = ctx->height * stride - left - top * stride; + if (decoded_size > ctx->height * stride) { + decoded_size = ctx->height * stride; av_log(ctx->avctx, AV_LOG_WARNING, "Decoded size is too large.\n"); } @@ -957,8 +955,8 @@ static int old_codec47(SANMVideoContext *ctx, int top, } if (!seq) { ctx->prev_seq = -1; - memset(prev1, auxcol[0], (ctx->height - top) * stride); - memset(prev2, auxcol[1], (ctx->height - top) * stride); + memset(prev1, auxcol[0], ctx->height * stride); + memset(prev2, auxcol[1], ctx->height * stride); } switch (compr) { @@ -1289,6 +1287,14 @@ static int process_frame_obj(SANMVideoContext *ctx) av_log(ctx->avctx, AV_LOG_WARNING, "resizing too large fobj.\n"); } } + + if (codec == 37 || codec == 47 || codec == 48) { + /* these codecs work on full frames. In SotE only, "top" is used + * to create a black bar at the top to center the video inside + * the 640x480 game window. We don't need/want that here. + */ + left = top = 0; + } bytestream2_skip(&ctx->gb, 4); switch (codec) { @@ -1296,9 +1302,9 @@ static int process_frame_obj(SANMVideoContext *ctx) case 3: return old_codec1(ctx, top, left, w, h); case 37: - return old_codec37(ctx, top, left, w, h); + return old_codec37(ctx, w, h); case 47: - return old_codec47(ctx, top, left, w, h); + return old_codec47(ctx, w, h); case 48: return old_codec48(ctx, w, h); default: -- 2.48.1 _______________________________________________ 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".