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 7E0A6423A1 for ; Sun, 15 May 2022 18:51:10 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 232D568B4B1; Sun, 15 May 2022 21:51:08 +0300 (EEST) Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 98D0E68B02F for ; Sun, 15 May 2022 21:51:01 +0300 (EEST) Received: by mail-qt1-f177.google.com with SMTP id v14so9645058qtc.3 for ; Sun, 15 May 2022 11:51:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language :references:to:from:in-reply-to:content-transfer-encoding; bh=mKh3rTM1eugASvVxXnSt69Axe+U0XDC43cXPPhtfoAo=; b=a55qFkpsT89VHhxS7bwM3ef++fk4QfVmjU3OuTlr0ysoPsDBKFmx0PLB6XbkVDDEUw Dmw+7+YjqKAsQP6kvl7CZ9qYUX46iOYBFabWg/uX7A2tvzXR+PtLA/I6vAvT7WOxoRJP gZ7UAnsm49uxduE9uGdOyapIHBX02Zk7/cLjhaNIj8OuO/7Gapf3AjkdeowTGZC/wK9N WI4IJpv/uEoLW58yLELO86Ig2v9iISS54IlfzTQ25C4dKglt11FLr74pwyJQRSj/W5aq zUeFMUsRlKRv7xcOTyhUFJq5GHxcg/IzC62XG1IaIZcA3fYnZEH+kT4QERfjIoXIriJx bVPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:references:to:from:in-reply-to :content-transfer-encoding; bh=mKh3rTM1eugASvVxXnSt69Axe+U0XDC43cXPPhtfoAo=; b=f5KFY1y6Oyrpz2OYcA1SNDDRZqvYmeF/U1rfdhM8Ne0uVwlZ5zRmE+FSr3v7hSV8nX HqXZA2vfFqhgje78w7WIjs1RcrZjASOVwXciS3+8NLHRWwNmhd2CTU7P5Ungp0geccos fWG+VhMOoyeWJsSzmWYRX4lDTMSdYDw6u8XEaYDj1QzRpMOXYFxLMcWStHY7nTudCLXP q5NAnu9nmHHDojzxzrWT2P25LTo2aZiQynTdiOwHUsMakACfqYxSGrBh3n4KKO2F/wd3 /eOCu5C74rlZagD3wUGqdb5aTO6aJ6NrBwufsdAqGQbFsd8Cv+v9EUJEtTSvIsMXPy0j 9/8A== X-Gm-Message-State: AOAM533RpCr6iwSZ6tNcl84E/P/i59txi8P99yHlGSok1U3wgHEsSMFs c+RzY3ioE9v5Rv1AqH0jZ+bX3riPIO8= X-Google-Smtp-Source: ABdhPJzOQX4fN+9VC5OSX69nDrle4aIzipfFWs4SA80tmWIhA+FmF9iksu+NOm+4Ge+s83p54wbr/Q== X-Received: by 2002:a05:622a:11c1:b0:2f3:c0d2:225d with SMTP id n1-20020a05622a11c100b002f3c0d2225dmr12781487qtk.296.1652640659968; Sun, 15 May 2022 11:50:59 -0700 (PDT) Received: from [192.168.1.10] ([151.200.235.219]) by smtp.gmail.com with ESMTPSA id g23-20020a05620a109700b0069fc13ce1e9sm4641163qkk.26.2022.05.15.11.50.59 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 15 May 2022 11:50:59 -0700 (PDT) Message-ID: <6ee80cc2-136e-85c7-ea14-6a8332f4c85a@gmail.com> Date: Sun, 15 May 2022 14:50:58 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Content-Language: en-US References: <20220208203214.161469-1-scott.the.elm@gmail.com> To: ffmpeg-devel@ffmpeg.org From: Scott Theisen In-Reply-To: <20220208203214.161469-1-scott.the.elm@gmail.com> Subject: Re: [FFmpeg-devel] [PATCH] cbs_mpeg2_split_fragment(): cache the buffer end 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Ping; it still applies cleanly. -Scott Theisen On 2/8/22 15:32, Scott Theisen wrote: > Also add a few clarifying comments. > --- > libavcodec/cbs_mpeg2.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/libavcodec/cbs_mpeg2.c b/libavcodec/cbs_mpeg2.c > index 33bd3e0998..47732562d1 100644 > --- a/libavcodec/cbs_mpeg2.c > +++ b/libavcodec/cbs_mpeg2.c > @@ -144,12 +144,12 @@ static int cbs_mpeg2_split_fragment(CodedBitstreamContext *ctx, > CodedBitstreamFragment *frag, > int header) > { > - const uint8_t *start; > + const uint8_t *start = frag->data; > + const uint8_t * const buf_end = frag->data + frag->data_size; > uint32_t start_code = -1; > int err; > > - start = avpriv_find_start_code(frag->data, frag->data + frag->data_size, > - &start_code); > + start = avpriv_find_start_code(start, buf_end, &start_code); > if (start_code >> 8 != 0x000001) { > // No start code found. > return AVERROR_INVALIDDATA; > @@ -165,12 +165,11 @@ static int cbs_mpeg2_split_fragment(CodedBitstreamContext *ctx, > // start code in any way (as e.g. happens when there is a > // Sequence End unit at the very end of a packet). > start_code = UINT32_MAX; > - end = avpriv_find_start_code(start--, frag->data + frag->data_size, > - &start_code); > - > - // start points to the byte containing the start_code_identifier > + end = avpriv_find_start_code(start, buf_end, &start_code); > + start--; > + // decrement so start points to the byte containing the start_code_identifier > // (may be the last byte of fragment->data); end points to the byte > - // following the byte containing the start code identifier (or to > + // following the byte containing the next start code identifier (or to > // the end of fragment->data). > if (start_code >> 8 == 0x000001) { > // Unit runs from start to the beginning of the start code > @@ -178,6 +177,7 @@ static int cbs_mpeg2_split_fragment(CodedBitstreamContext *ctx, > unit_size = (end - 4) - start; > } else { > // We didn't find a start code, so this is the final unit. > + // There is no start code to remove from end, hence not (end - 4). > unit_size = end - start; > } > _______________________________________________ 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".