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 ESMTP id 7A00240ABA for ; Thu, 3 Feb 2022 18:46:23 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A73B468B18C; Thu, 3 Feb 2022 20:45:41 +0200 (EET) Received: from mail-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7BCE468B148 for ; Thu, 3 Feb 2022 20:45:33 +0200 (EET) Received: by mail-qv1-f49.google.com with SMTP id s7so712732qvb.0 for ; Thu, 03 Feb 2022 10:45:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RDVpNu+d/1V4UdxuuE3cqLrUdn5wcMxN8wvetm30qXI=; b=jo3kxc84zPTYUIls0uJU8jIo+ONw8xkumJgZCPqZdNq9mLmkRZnWZndY1lmZITB4Ys i7YgmKWdFUZc0AgMs7ysZ3o0sTjZhvK3dGE+HykYFMxH99XI0zpzJWYWNcXM3EUZxIv4 PDyUAznWiJ8Jxi0cl1IMNHyzNUCEUQ8aM8D31GO83q7ULGueYcOtNw4GC7NeMasEJzzL LENCLkzfaDvmSD563MlMH/HpJe9A/Y+xJhLxknbcoPQ1od3EyGZ2Ev7yav7lcOlaaY6e Psh4Oyv57n6BkSvkg3o3OU0GHUNmMucTUwmWVT22Ag3ChRI2VISUf8UJjRUXZKyoWCYo RooA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RDVpNu+d/1V4UdxuuE3cqLrUdn5wcMxN8wvetm30qXI=; b=7H0M2SgOHAAmOf5QONFHuwn+kV/uBV5IpXjRzXugLVvhk/l9fo8d17yqhk5biKcnfc 13HBRdXkugzkw80e3PtDAGz9kIYgv1qS17lAG2DTcjCCjkFbbf37RLe/S0soC+pWCuJ0 p0ZTcwsLKl7hI2xsrYVg9Dcp/Rtir3Njd84IyJ2PPfvS6XtsK11JcOTX+u6gN6wz83we 5ldC/vpUzevQpCQgkACaISYT9vJ3MAbfR96BmMcPOoGof3GlWFE8ZgQ93TnQmkHY6nic WrmNkWAMcZpQw9xL8IvLcFcGi/+c+cc4sNgCopxXGPUx9rhem3I3IUamRMyuxI7uM6yt 9+Jg== X-Gm-Message-State: AOAM53140nYExzJa8YSPcHKfscJPYKNyaBiYrXzvQUxTRhRT0nFzg71D Y8b9Z/fq2sGg9dUg2WVC6jdtFAqiTy9mhw== X-Google-Smtp-Source: ABdhPJyBb5vav8LFrtAyhuwLJ4Pz27mg7/QVeyZ+ZN+pL5kMjE67gG52DsLZV0FuTjDn/jEaa1rlSQ== X-Received: by 2002:a05:6214:2524:: with SMTP id gg4mr32428191qvb.27.1643913932189; Thu, 03 Feb 2022 10:45:32 -0800 (PST) Received: from localhost.localdomain ([151.200.235.219]) by smtp.gmail.com with ESMTPSA id f16sm5947887qtk.8.2022.02.03.10.45.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 10:45:31 -0800 (PST) From: Scott Theisen To: ffmpeg-devel@ffmpeg.org Date: Thu, 3 Feb 2022 13:44:41 -0500 Message-Id: <20220203184450.5491-5-scott.the.elm@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220203184450.5491-1-scott.the.elm@gmail.com> References: <20220201212056.29712-1-scott.the.elm@gmail.com> <20220203184450.5491-1-scott.the.elm@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 04/13] avpriv_find_start_code(): rewrite for loop for clarity 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 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: --- libavcodec/utils.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 8f8cc820bd..1a806b9fa8 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -944,18 +944,20 @@ const uint8_t *avpriv_find_start_code(const uint8_t *av_restrict p, const uint8_t *end, uint32_t *av_restrict state) { - int i; - av_assert0(p <= end); if (p >= end) return end; - for (i = 0; i < 3; i++) { - uint32_t tmp = *state << 8; - *state = tmp + *(p++); - if (tmp == 0x100 || p == end) + // read up to the first three bytes in p to enable reading a start code across + // two (to four) buffers + for (int i = 0; i < 3; i++) { + *state <<= 8; + *state += *p; + p++; + if (avpriv_start_code_is_valid(*state) || p == end) return p; } + // p is now properly incremented for the negative indices in the while loop /* with memory address increasing left to right, we are looking for (in hexadecimal): * 00 00 01 XX -- 2.32.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".