From patchwork Tue Sep 8 09:15:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Andreani X-Patchwork-Id: 22165 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id BF58E44A787 for ; Tue, 8 Sep 2020 12:21:30 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A3C7068AB04; Tue, 8 Sep 2020 12:21:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 36A056883C5 for ; Tue, 8 Sep 2020 12:21:24 +0300 (EEST) Received: by mail-lj1-f193.google.com with SMTP id s205so19123853lja.7 for ; Tue, 08 Sep 2020 02:21:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ym/AlA4AyxhTn5GmFFjSzsfzoKxmOauiGpFCXm6KAwU=; b=oe0gA+e+m/CHZ/GsfxRnXUP3DWEMJxv/r5XGsNAwu7PuGCMJxo/lfdfjwe7/kGaQoz Tef/GUT7avafPZG3nqJRqQrU0jKLsk9BB6VulkcPzADToB0hFLtPMi9LSaqKkvj3/e8R uS5pnPRqXvOaxzPrZIYeOGWyj7M+VLTbekh6hX4Eu7a2d7Rs2VVJ5R7uU1cAaW+Qhbb3 3roFK/6Xmbr9+jQz4EYl3ZKwnaZ1XKTOQ7CfmDC/Jwevmiv9EEuPprAwiueZ2uXhzS12 DSw/NsfFgDDmDEgQcJmcKi9qsAzQRMVrXzFlXHIh95wFLr/5wMKzRHfpbiMWlCZI4JQy 87Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ym/AlA4AyxhTn5GmFFjSzsfzoKxmOauiGpFCXm6KAwU=; b=DTxM1b34FiYTHp1B/ohoMUwh+izW3R/uIilHcELlIUpbzBeKnLmnzsiphMkkV+NQ3k oLqxVA44OlHzFe/cA5jBZLpr6nFwJIafMvlus8Z4OYqP3/q+eetwvoaZbyTarXZcbaub GTk9Y7imBBiDMzQIOa66TY0vU39B1+VbTZyF08wEeWxxCUzVZN7qJ0Yy5nqLdSsc/xjT BWPYI0WzGk+OCl56mJKXoILZ2zR15xkC1nuKuU4qlwwajPqukRa93Amp/BTygvjunzR5 +14GF1K+OTj77Roh+DaQ2ZPm4lTRnZGR6alTje3kmQcSV8S2ZyWCS6SfIGxowfS8jOyX azHg== X-Gm-Message-State: AOAM533s5tV07I/wAX4DjCZAp+NcbkwPICBUESc6DPI7BIVE+LbUyKDc J67Ga8yxquqXE3t40JUpSmq56d7bvF2Y0Q== X-Google-Smtp-Source: ABdhPJxtTH5MFp/DXTsLaoTRRSJHc9vuNxMuUdW4XfMCepGyDMbNjpgoMcQYCIAvS09Or/9LKISXyw== X-Received: by 2002:a50:a44a:: with SMTP id v10mr24764995edb.133.1599556559115; Tue, 08 Sep 2020 02:15:59 -0700 (PDT) Received: from ubuntu1904.lan (5-12-122-120.residential.rdsnet.ro. [5.12.122.120]) by smtp.gmail.com with ESMTPSA id cf7sm17125355edb.78.2020.09.08.02.15.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 02:15:58 -0700 (PDT) From: Dario Andreani To: ffmpeg-devel@ffmpeg.org Date: Tue, 8 Sep 2020 12:15:15 +0300 Message-Id: <20200908091515.4652-1-darioandre@gmail.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/h263dec: Reduce H.263 probe score if only one frame is found X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Dario Andreani Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Fixes #6500 I checked the h263 specification and the current implementation is already quite thorough. False positives, like #6500, can happen by pure chance. To improve the situation it would be necessary to further parse and validate additional data from the h263 "picture" layer. A possible alternative is to add some heuristic in relation with TR (time reference): in all h263 samples which I could find, the first TR is zero and successive ones differ from the previous (mod 0xFF) by a small value, typically 1. The score could be lowered if this doesn't happen (e.g. the value is 214 in #6500). For now, my proposal is something much simpler, which takes care of #6500 and possibly other "unlucky" cases: the score is reduced to 12 if only a single valid PSC is found. Note that the current implementation already unconditionally reduces the score to 25 if there are less than 4 valid PSCs. Signed-off-by: Dario Andreani --- libavformat/h263dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/h263dec.c b/libavformat/h263dec.c index 0736158bfe..ff2828ed83 100644 --- a/libavformat/h263dec.c +++ b/libavformat/h263dec.c @@ -71,7 +71,7 @@ static int h263_probe(const AVProbeData *p) if(valid_psc > 2*invalid_psc + 2*res_change + 3){ return AVPROBE_SCORE_EXTENSION; }else if(valid_psc > 2*invalid_psc) - return AVPROBE_SCORE_EXTENSION / 2; + return valid_psc > 1 ? AVPROBE_SCORE_EXTENSION / 2 : AVPROBE_SCORE_EXTENSION / 4; return 0; }