From patchwork Sat Dec 14 22:19:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 16790 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 EA0C2448FE9 for ; Sun, 15 Dec 2019 00:26:03 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D593B689BD9; Sun, 15 Dec 2019 00:26:03 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C52066898D2 for ; Sun, 15 Dec 2019 00:25:53 +0200 (EET) Received: by mail-wm1-f65.google.com with SMTP id q9so2613467wmj.5 for ; Sat, 14 Dec 2019 14:25:53 -0800 (PST) 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=B2z/0H0QAtKchz4shKNe4EmOiSDzz74/yJWZD3koK8Q=; b=IxRVFCLpkh1GdzZpizjn0S4l0RnrYCWExEMAOLpik2Rkun8KwJ5AxslaeoIePVUZxW YKEE9JfZVaLRZ/MQeyq+KV7DdiEnglNm66Wfl0mpXCkWaftzToBcVkTqUWPRuZajw7KE oEAWRTf9LGjgbn00XtMR4HJ59wc2YXGam+h6PZBZFP/BqHxPjJ3YiniNZXCjmlrIx7QB 08qwVU/Tq70Y0i5RVc1AdOtRj8l99oTJuBMhQWfvRT9Mne0/lPROmVsIXV5kTDamNsjc nk55CDQJSCg9aImNyZxan/Fani1Xr0/JLybLCWteE499+u6Fd7KCDARmGkiMaLf/W8g6 mRhw== 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=B2z/0H0QAtKchz4shKNe4EmOiSDzz74/yJWZD3koK8Q=; b=ou/Vnq5Sotuq2YsN7CMALt0B+eH4o8xTMvQS/ko+IPLAETw/fOZF+g/cQOqUGyTpKc PIlubULWpJWxR6v7Fo0wPVpZS50O5W4KxPw/D9vJlBKt5PLbV6V4W+KRgliF8+S0g5an vIIX77m8I5zk7b44/bkni+K0MfdvV/5EBBIo6hr4/romRo64n4cusc3i9rKSoATMJWQx ySq8103CaFkDznC1nbyAClNtMJ/WZ+Pj6J3rx4RMlW4dy6rsD99tuYF4ERzT26z2bKyz T6kA0h2cTWXpS8kfgrH01hmAg6yAmOmahP2Z83nfHqMzTtE/0A9hYZ0F2Yq1dGClUw9j E6sQ== X-Gm-Message-State: APjAAAV7dhzcgVGRtvhq9Lins9wdXxaw0SKv3zW86TGR0wnzC8EHFrJf czCT6Z9ViBq/VzkN/Zuz+nMBqBx6 X-Google-Smtp-Source: APXvYqxeYSRkH6Yl5MDdip49VeBbvvfk/o8ADfnKp3HXUJ0goV8z/EEfDYKWU7H8SHFgLT6w5/RPCg== X-Received: by 2002:a7b:ce98:: with SMTP id q24mr20184669wmj.41.1576362353095; Sat, 14 Dec 2019 14:25:53 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc08e23.dynamic.kabel-deutschland.de. [188.192.142.35]) by smtp.gmail.com with ESMTPSA id v3sm15063771wml.47.2019.12.14.14.25.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Dec 2019 14:25:52 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 14 Dec 2019 23:19:22 +0100 Message-Id: <20191214221926.16074-10-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191214221926.16074-1-andreas.rheinhardt@gmail.com> References: <20191214221926.16074-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 10/14] h264_mp4toannexb: Consistently use pointer comparisons 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" h264_mp4toannexb_filter currently uses both indices/offsets as well as direct pointers comparisons for the checks whether one has reached or even surpassed the end. This commit removes the offsets. Signed-off-by: Andreas Rheinhardt --- libavcodec/h264_mp4toannexb_bsf.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libavcodec/h264_mp4toannexb_bsf.c b/libavcodec/h264_mp4toannexb_bsf.c index c28e02ae55..1505ee1c3d 100644 --- a/libavcodec/h264_mp4toannexb_bsf.c +++ b/libavcodec/h264_mp4toannexb_bsf.c @@ -176,10 +176,8 @@ static int h264_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out) AVPacket *in; uint8_t unit_type; int32_t nal_size; - uint32_t cumul_size = 0; const uint8_t *buf; const uint8_t *buf_end; - int buf_size; int ret = 0, i; ret = ff_bsf_get_packet(ctx, &in); @@ -194,7 +192,6 @@ static int h264_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out) } buf = in->data; - buf_size = in->size; buf_end = in->data + in->size; do { @@ -262,8 +259,7 @@ static int h264_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out) } buf += nal_size; - cumul_size += nal_size + s->length_size; - } while (cumul_size < buf_size); + } while (buf < buf_end); ret = av_packet_copy_props(out, in); if (ret < 0)