From patchwork Fri Sep 16 18:19:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Theisen X-Patchwork-Id: 37961 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp1139557pzh; Fri, 16 Sep 2022 11:20:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5KpuxxZFuljBwgJuuaQyvNnPaAcBuFlEPe/mQJxndV4GcFnTEsaYYBLriEb6lrjJuxOWuH X-Received: by 2002:a17:907:96a8:b0:780:3293:8e73 with SMTP id hd40-20020a17090796a800b0078032938e73mr4308647ejc.538.1663352440829; Fri, 16 Sep 2022 11:20:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663352440; cv=none; d=google.com; s=arc-20160816; b=SGljS9FnvfsDPRvRbih1TSBPFhahYsRkaQN/11mes4YH0eGpxmj6qPmrHWA5MIT9Pp 8wIS2l+2m3T1k3RsV2lDxIzHPzss3Y73XbDNyI8Xp9Ssc/6iW5V/Z3+ZLPeM2/DEu/7z HMFly5dAM7ytvDs/HkPDsFUVvJBYYYLN20k5M81DGK+sdW6JxJpcBxqXl5KD9R95w02f nyPju/zISUfdLAAuWd+09JEm1JwAq0Puj3f+dgFbK9tqa5OuspkLmdxlwgq7jbB7/Kln BycU/3oVIXEAU95DGtzNrRMWEpmcpJpY/Cr6SRGCjFwLas+x2JYGVWGBgPFZWaS+w5XN I4vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=cR43mMZMRdj8auJXmp1kop8LJzCgfGeH4t6RcPrVgFQ=; b=zK9qy224VMrasC8esaBHEhxMwe74uehaf0oyOIcqkMv7YQxChGvwdU1s59LWl7RCsq N+u1n1AKHxy6AfdtkBIaegLJw0ObtEYDxgkp2jXeQnthB8IIjWQCJxn2hMb1zOft7DVj zV3X4sl46G5nHKE9lEm2pImYWvlQhPHFieLwZ8YzfHpL822poit1+W4JaqEaydJk2uB0 z4P/d0WBwcGDff0oTtf3DjmHJJvdf1gGjwYTfhpSMrIhb8G8jC3O4uU7l/JkgRUCUbVo 118xOtqFVJQ/QKZXeFD1/fFSU8AocadoLCPzyoL8pTKhYfWB7s7OLY83Ay8lyM3C7oe2 4apQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=MeBO52Py; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j30-20020a508a9e000000b0045261ae8b8bsi2032106edj.504.2022.09.16.11.20.36; Fri, 16 Sep 2022 11:20:40 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=MeBO52Py; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1B5BB68BC34; Fri, 16 Sep 2022 21:20:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B65A568BBF4 for ; Fri, 16 Sep 2022 21:20:11 +0300 (EEST) Received: by mail-qv1-f45.google.com with SMTP id m9so17247591qvv.7 for ; Fri, 16 Sep 2022 11:20:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=0pRbvpZKHvYp+aRrC9WxdCO3h7/5O+mMKcWqXWIMK9k=; b=MeBO52Py0/exX7fc81s0c4mAawOG2wzlRPWQuHUBuDG+Z1GkXmbPxpikdM2VmW2I3X l5uXKoh3JWGocq07OskkZt1pBkY4cK64Ym5q3/kGLM63RCzXj9q0Mx0GOYQHBAbrJqol +PJVFZRNJaBDMzqvw7ZU123fcVo0usYmgiVbW0D4/Sw9ZTBdJDrt/As0RKMDf+VJh/+J nmQYLRjuPr7QJMbLxqh0fum1NHJAe8VV8mrbdTwFb+JDUglb8OMrCkdS1uuapkEXMaAH 2OgF72ZVnPDqQcdfJLrVCqyOFlGtXXmU6dMNDyG7aMFeBBbdG/udrGnqIhoJVFJKcMrW 5caA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=0pRbvpZKHvYp+aRrC9WxdCO3h7/5O+mMKcWqXWIMK9k=; b=6K5SdWEI/XG8Ad5lmXuAZ+ftR5M0wW1xbfmPm3GUQ3U2xE2j/K3QBG5Q///TyAyaJ9 v7BIWRCE0OfdmjQ94rvH5s5O+XLmfDUPEmZy1kE4TPcxqkG1oe9+GwjfL0daS2tLvPYo jV+HKmzY4i7ACZha/aC0mPaBeDq53nPVbjtgnrgPZDb7YFe53tj9utJdfaSdvXrwW1Un j15S+w73mrOCk/jAlmvV8eJ8OCLmJQ0Ue8NfoRWQ/ZVe+Illz2Iv4QuKYiRo/JOTFzXe DCjGJx3I1N0pvEjybGojQ1CK9aG/rQD3d0b1St0KgGfgkICNLRJIvedmX/TTZYhlgwGf bb8w== X-Gm-Message-State: ACrzQf3hX2uvvaGKuQ+gC4e++qegPNYiKb3B1zlwnS0YAtpO2+ghBpOy VupAdCUXJ5hM3SJ3a20MX0hpJrZRgdI= X-Received: by 2002:ad4:5c6a:0:b0:4a2:6356:e6b with SMTP id i10-20020ad45c6a000000b004a263560e6bmr5087976qvh.71.1663352409464; Fri, 16 Sep 2022 11:20:09 -0700 (PDT) Received: from scott-desktop.. (pool-71-114-80-52.washdc.fios.verizon.net. [71.114.80.52]) by smtp.gmail.com with ESMTPSA id l10-20020ac8724a000000b0035cb9531851sm5148098qtp.65.2022.09.16.11.20.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 11:20:08 -0700 (PDT) From: Scott Theisen To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Sep 2022 14:19:56 -0400 Message-Id: <20220916182002.122699-3-scott.the.elm@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220916182002.122699-1-scott.the.elm@gmail.com> References: <20220201212056.29712-1-scott.the.elm@gmail.com> <20220916182002.122699-1-scott.the.elm@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 2/8] avpriv_find_start_code(): readability enhancement part 1 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: Scott Theisen Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 2z6ZDd1vK0+8 No functional change. --- libavcodec/utils.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 2f57418ff7..d6ab21b1a0 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1006,10 +1006,11 @@ const uint8_t *avpriv_find_start_code(const uint8_t *av_restrict p, } } - p = FFMIN(p, end) - 4; - *state = AV_RB32(p); - - return p + 4; + if (p > end) + p = end; + // read the previous 4 bytes, i.e. bytes {p - 4, p - 3, p - 2, p - 1} + *state = AV_RB32(p - 4); + return p; } AVCPBProperties *av_cpb_properties_alloc(size_t *size)