From patchwork Sat Jun 1 22:47:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 13374 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 03C95446F95 for ; Sun, 2 Jun 2019 01:48:43 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CF24568AAE8; Sun, 2 Jun 2019 01:48:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 37F4F68AAE4 for ; Sun, 2 Jun 2019 01:48:36 +0300 (EEST) Received: by mail-wr1-f67.google.com with SMTP id h1so8806782wro.4 for ; Sat, 01 Jun 2019 15:48:36 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=jLaIQBXVcoRKdEUcVAJV/V2lq3AyWBDqWePNPoW5b8o=; b=L/7W/GXzcOYJc/hKZXq7EImimAg9xzguBFwT+Adt1BgevrEMRwK7OsZ+tqCDYDB5uL tIIw1uT94U3UTQIgeSGlxU+Y5vq+OC0vJO/Xa2oxhVdhmtU9brUfdQyqZtrFCe8TX96f hwdkSRGleOZ6+FivMfsUSM0nGdiSNCZAkxeOF+3xEmd7lsHqmon2Spt7D+gYnmZbTpjR 9RB6uJItU3jE7l6RuVUgIL+74X40RGsAhMdeVjCL1SnURcXQzSGDwFtfxda44Vb8XGwc z0mfI96SKUPJ1tfOomGKyGYdJOLhNnaak2Xl5D7MNMCqm/whxuPmXfA+6IZ02QT4LCGT X+uA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=jLaIQBXVcoRKdEUcVAJV/V2lq3AyWBDqWePNPoW5b8o=; b=hmUstCZ3u9kmlZ88lv40mgF6EQvIiLT3JdUqxqdPtz/VJxsxrWYsUlMrazv3y+yBGY XxukEAl5jUxpsfQ17zYBRt2XPSLuR+CIyaT3IuT29AExuRTEcOkuOuyQfutEigb+GJqm 5cUEipT4NiTgPmtcobl+7++f8oSBv+2LGCmefhcuVp1QN6TEA4GIcQ4MYhsEFfQSzq16 ODN5IByft9rZUoKiVkj7OswCfOeKaqeaOrgvChpWE8d2anAhTQ1Phb6S3nMvazLpFU/J aqIlj65JA2JzNnkQSleim7+efXm6JvzBDRxKZbFazegKPweAL7lplkeTmlKOe7WDmJaA FeUg== X-Gm-Message-State: APjAAAVnLDXSwqp+JU8g3ThDI3GUMd2Ibu5JHZLgnVeXHcl6e9A4zO1V CLAgTtCwnGO+E8xrLPr/asNpdLPU X-Google-Smtp-Source: APXvYqzGeGIy3HnpyQ5cjV1ZhL6ZUyXVRVZPahkPygq7Ef6ZysN5UwFtH2ssNddAAPvhy+j6V6Pvmw== X-Received: by 2002:a05:6000:146:: with SMTP id r6mr10950861wrx.237.1559429315614; Sat, 01 Jun 2019 15:48:35 -0700 (PDT) Received: from localhost.localdomain (ipbcc063db.dynamic.kabel-deutschland.de. [188.192.99.219]) by smtp.gmail.com with ESMTPSA id c24sm7591892wmb.21.2019.06.01.15.48.34 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 01 Jun 2019 15:48:35 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 2 Jun 2019 00:47:17 +0200 Message-Id: <20190601224719.32872-4-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190601224719.32872-1-andreas.rheinhardt@gmail.com> References: <20190601224719.32872-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/5] startcode: Stop overreading 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Up until now ff_startcode_find_candidate_c could overread; it relied on zero-padding after the buffer in order to function correctly. This has been changed: No overreads occur any more. The ultimate goal behind all this is to create a high-performance function for searching of startcodes that can be applied even in scenarios where the buffer is not padded. Signed-off-by: Andreas Rheinhardt --- libavcodec/startcode.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libavcodec/startcode.c b/libavcodec/startcode.c index 373572365b..b027c191c0 100644 --- a/libavcodec/startcode.c +++ b/libavcodec/startcode.c @@ -41,10 +41,7 @@ int ff_startcode_find_candidate_c(const uint8_t *buf, int size) #define READ(bitness) AV_RN ## bitness ## A #define MAIN_LOOP(bitness, mask1, mask2) do { \ - /* we check p < end instead of p + 3 / 7 because it is - * simpler and there must be AV_INPUT_BUFFER_PADDING_SIZE - * bytes at the end. */ \ - for (; buf < end; buf += bitness / 8) \ + for (; buf <= end - bitness / 8; buf += bitness / 8) \ if ((~READ(bitness)(buf) & (READ(bitness)(buf) - mask1)) \ & mask2) \ break; \