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 4F15E4E310 for ; Tue, 6 May 2025 15:41:40 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4187568BC1C; Tue, 6 May 2025 18:41:16 +0300 (EEST) Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DC36E68A120 for ; Tue, 6 May 2025 18:41:06 +0300 (EEST) Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-ac3fcf5ab0dso959678566b.3 for ; Tue, 06 May 2025 08:41:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1746546066; x=1747150866; 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=kf0PsP7+ejP0/uiqT1xWGskO+t9ZKBBC2BSUZcqsfH8=; b=kiYsubpUgFGVB0m3SDOKD1qatwk9ehpCKmFyiu4LB8hnGuqTYjyX+UXu+KLSahRxNF 5C0k7aFpRmdrQrAsHDlnDh3sSKhV5HQ9+fO8EqvPgq+GhitqGbrjDWEwKm3Srgw74B4M TIOPS/RIB6k/nd0ZM8Ha5IMQ7CvtwWqn+2vG8Awcdxj276nDWh3wTeo90C3YQ7p+FJAC jiIuxgXHUZ8/VoyyIQrTsor3mNYoeuQXA2zomgOwYQp2eNuftL7vUZ+2Lszd7vyXL1fa tegjQqhZAUBk0LYVZY8b5Kt3lbT/QtIh2RfeFTD5hsbECqfk+w/NEihatyzCJFmaRFV6 YbhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746546066; x=1747150866; 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=kf0PsP7+ejP0/uiqT1xWGskO+t9ZKBBC2BSUZcqsfH8=; b=QmuTEnm5+vKSXM3YlZ33BVpGY4ukb3oAjzLC8FhHPchewiRh7YNiJ74lkm9IiZcTV/ dGHUlir4Fuqd+gsq9XwuQhbV/ySX58VsiG7UIN3Sw0bFMJaVVe38za62l0kJO098BqBg 8qr9Qs9lw1oS2Msj2fDFI5z0nIPBRwKHOfg67rmt98mCd9Z7xhQ8Sc30F9ITn73oDUqu VVdPWt5tWQAwP73viqVc6KbN/uQ24AnHevRGCD8yApiwyLxw4e2WuozWB8FDqZHAZFxf ap0wZCTZxotJJwx8zHnp6HApBcJmuUVZIGf7H9wUubV39N/y9bKqSuMAP1nOB6D8wueC bFnw== X-Gm-Message-State: AOJu0Yx98jQP1588VYRrqN4KG7lorWKFwTDaioEwglK59b1m+/geVs/r sxAspH9Vwz3A4J76lv3g5uCHSwmyZHd9HnuJuRK+bumrIgoz3vuEn0Ssgg== X-Gm-Gg: ASbGncuGIHL6qEXi3fVzBpTzeQxkcp56HXSSXLJNgKp5RZpDeNte4ne46MGkPm6ZMKY vnYNyA0mOeIgajBJFJAGyxhTmOLvn2c71TBhJ4qBoOKxfwH2+cYOz4IaZ/ZeJF5q556/gTqS+CK QiiWEyfLYANuCo2FUV33S0KwYouTlAl5jhU46Ki1H5c01GT7AetyYwdL+IZjaAluCLcGpn/Aqpb VluSbIM3qD4T38NXEX6PosMiUg6IzmwdrPonrLYwrTBrOFMM+D8QtAK7tYLoTE7Dz5+95LfHszy wpiaVriLWknPfgQ2pKak75w2meI09ILV0gmQjCmwjAiJwJLMXqRMoZubrV75krvegQXZNuC0CSA Ht6Addo9qvfRwsuDl5ELozk9DVpVYZg8CpfXv9R+9GRwGsbIRKKE= X-Google-Smtp-Source: AGHT+IGyZe54Umyuq7JRj+iLmlXMFx443lngwQb95GZdiFTtcADkvTHvtvD7DJvgMChQAccviGAfuA== X-Received: by 2002:a17:907:c24a:b0:ace:37d6:a5ce with SMTP id a640c23a62f3a-ad1d454f57fmr343721166b.19.1746546065825; Tue, 06 May 2025 08:41:05 -0700 (PDT) Received: from flagship3.deu.mlau.at (p200300c027336900fca3fe402a6066d1.dip0.t-ipconnect.de. [2003:c0:2733:6900:fca3:fe40:2a60:66d1]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ad18950ace4sm719495366b.153.2025.05.06.08.41.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 May 2025 08:41:05 -0700 (PDT) From: Manuel Lauss To: ffmpeg-devel@ffmpeg.org Date: Tue, 6 May 2025 17:40:55 +0200 Message-ID: <20250506154056.920553-3-manuel.lauss@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250506154056.920553-1-manuel.lauss@gmail.com> References: <20250506154056.920553-1-manuel.lauss@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 2/3] avcodec/sanm: recognize common 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, since they can be embedded in a larger frame. Signed-off-by: Manuel Lauss --- v2: reworded description. 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".