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 BCADB4E2F7 for ; Thu, 1 May 2025 09:58:40 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 985FC68B53E; Thu, 1 May 2025 12:58:15 +0300 (EEST) Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2525368B3FA for ; Thu, 1 May 2025 12:58:07 +0300 (EEST) Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-39ac9aea656so752239f8f.3 for ; Thu, 01 May 2025 02:58:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1746093486; x=1746698286; 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=8YrOktNJEcV67boXbxScVdMWecwvOCOiJrWMz2PZMps=; b=hOBLpAGXbCARiJgRx8fU+ZE3vtj54ipV2yjon/1eti4AbgormPCjVWBuMw9LXt6tg4 xwATpKwfszbHWmVoreKhrmfczeC18HIbYwIQvO6BOmpDf7M9XqsS5KF65gALLw/J493g ccYUDvY4fcCvhMVJe4S69G3UUfyYh8khlKtPw3agqN0DIRcoA417XrJBL/reIHSJ7m56 Wj/mTqLWyLz4pgsYBpYZ0w0GjOieUVD1pcFauPBIuZhSAmGQI6y3IuFn8OQx9qJvOoxo TBocLtnmYBL7fTMBRyVnlVUop2rVXcPU9AsxeCvf+lB3Fa/LWWqkvaBekiPopjTkiUsG aK/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746093486; x=1746698286; 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=8YrOktNJEcV67boXbxScVdMWecwvOCOiJrWMz2PZMps=; b=ZqusUaXbr605SpcIgmkK1YOXPbXIAggAud6S0AzXMgi5UnbA0ZumYB38nd/1HVBRSl GWm+TgKlVuOv7gxjw71xkYY5Tq+++9l2NM8NV+Mq5xpPvBZCU73BrSsq+ZgF+hLZJmwa XHwqsa0pnC/EvHKcw1jKxnTXYR9EaMhrqXUKiX4Ms/cOm0e+WGSZjK0Vicg/rkdg1N02 fyaXFoGi053Hn9iUecyIduL5e39PC+Lu0FI2imp/ejXWFAmXGqFmoTT+J8BVFuhuw5kV EpAK2pOckOVVDEO9w3y6JuQ8qOCPuq5HOEqXuR2y696eVfzKzffKZLKHQTRk8N6EJ892 HLwg== X-Gm-Message-State: AOJu0YyO+LL9BOYEpwq4gW8ZEFuPIWd4dnP35jvsN3e9DmufYS38I8gE YzlliNkzBwsXjB9UO/2bsDBziyKb0eq45xOi8f5YEsSf8I0aD+r1eWKYzg== X-Gm-Gg: ASbGncttnAmVKH6f/lbteZ8TeOFqZcScHw5/9LQFQdaf7cUMSDDFGphb22qcygZpn7V yiRE+eLOzExgtQvrYdSeGnAB/EXlJzR4vTOhCjlZLunc1v0c84TPdXnenPkb0TRHdaKA79iuj/N Fk+nUarX2hv9qZhZt87v52gWsc252uez4RDbhx4k8BmYbqoIFVjDJrBhKqV9UuQcWbon2CnLnaN iffmOXeYh+aDmXX6W7ZJb5e5L7ryuxSYqu90Jm8nY9KOUmoopbQMgqAwk+BUmxaSMKGJTL5BI9C 75g4bXr9ma70l9EqLbNYTV/YOJusSGOBVGPUMZM93I/MfGzWfL1djcEkeXg/qVDuDPwI7hSrDGi CeN+/STf3OZv1AWgR4h4K7w82JawL1FLAzujkOcuYNphjuUHYIA== X-Google-Smtp-Source: AGHT+IFH6+WLOuRkoU+0jswp54vdakZsIB+Edh8CHibJrKxjGwv6AsSxAHhuqseG81ZRSlS5UyykhQ== X-Received: by 2002:a05:6000:3101:b0:39c:266c:12a5 with SMTP id ffacd0b85a97d-3a09404c263mr1565977f8f.13.1746093486400; Thu, 01 May 2025 02:58:06 -0700 (PDT) Received: from flagship3.deu.mlau.at (p200300c0272bdf00de833b3b0c942d7a.dip0.t-ipconnect.de. [2003:c0:272b:df00:de83:3b3b:c94:2d7a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a095a3df60sm421041f8f.3.2025.05.01.02.58.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 May 2025 02:58:06 -0700 (PDT) From: Manuel Lauss To: ffmpeg-devel@ffmpeg.org Date: Thu, 1 May 2025 11:58:00 +0200 Message-ID: <20250501095801.68542-3-manuel.lauss@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250501095801.68542-1-manuel.lauss@gmail.com> References: <20250501095801.68542-1-manuel.lauss@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/sanm: add a whitelist for known FOBJ sizes 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: Change the size detection a bit to recognize common video sizes, as the FOBJ codecs>=37 cannot always be trusted. Signed-off-by: Manuel Lauss --- libavcodec/sanm.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c index e436b5ab8e..63f5c2cc7f 100644 --- a/libavcodec/sanm.c +++ b/libavcodec/sanm.c @@ -1603,6 +1603,7 @@ static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb) uint16_t w, h, parm2; uint8_t codec, param; int16_t left, top; + int fsc, sote; codec = bytestream2_get_byteu(gb); param = bytestream2_get_byteu(gb); @@ -1620,6 +1621,14 @@ static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb) return 0; } + /* codecs with their own buffers */ + fsc = (codec == 37 || codec == 47 || codec == 48); + + /* special case for "Shadows of the Empire" videos */ + sote = ((w == 640) && (h == 272) && (codec == 47)); + if (sote) + left = top = 0; + if (!ctx->have_dimensions) { int xres, yres; if (ctx->subversion < 2) { @@ -1633,12 +1642,24 @@ static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb) yres = h; ctx->have_dimensions = 1; } else { - /* Rebel Assault 2: 424x260 internal size */ - if (((left + w) == 424) && ((top + h) == 260)) + /* detect common sizes */ + xres = w + left; + yres = h + top; + if (sote) { + /* SotE: has top=60 at all times to center video + * inside the 640x480 game window + */ + xres = w; + yres = h; ctx->have_dimensions = 1; + } else if (((xres == 424) && (yres == 260)) || /* RA1 */ + ((xres == 320) && (yres == 200)) || /* ft/dig/... */ + ((xres == 640) && (yres == 480))) { /* ol/comi/mots... */ + ctx->have_dimensions = 1; + } - xres = FFMAX(left + w, ctx->width); - yres = FFMAX(top + h, ctx->height); + xres = FFMAX(xres, ctx->width); + yres = FFMAX(yres, ctx->height); } if (ctx->width < xres || ctx->height < yres) { @@ -1652,8 +1673,7 @@ static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb) } } } else { - if (((left + w > ctx->width) || (top + h > ctx->height)) - && (codec >= 37)) { + if (((left + w > ctx->width) || (top + h > ctx->height)) && fsc) { /* correct unexpected overly large frames: this happens * for instance with The Dig's sq1.san video: it has a few * (all black) 640x480 frames halfway in, while the rest is @@ -1671,7 +1691,7 @@ static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb) */ if (ctx->first_fob) { ctx->first_fob = 0; - if (codec < 37) + if (!fsc) memset(ctx->frm0, 0, ctx->frm0_size); } -- 2.49.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".