From patchwork Tue Sep 1 15:03:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derek Buitenhuis X-Patchwork-Id: 22051 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 30D44449D9B for ; Tue, 1 Sep 2020 18:30:01 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0B5F868AE45; Tue, 1 Sep 2020 18:30:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f65.google.com (mail-ej1-f65.google.com [209.85.218.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8023968010D for ; Tue, 1 Sep 2020 18:29:55 +0300 (EEST) Received: by mail-ej1-f65.google.com with SMTP id p9so2262646ejf.6 for ; Tue, 01 Sep 2020 08:29:55 -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:mime-version :content-transfer-encoding; bh=rNn5i4yAZd+OLdBdAlBgN/dFTRSN/RB4MpW5tXzgrMg=; b=EQ1341NWv7xwxai7Tx537PLVueVcd8F1J3LJ6LM7NvxjuQgNG0LU+/AC9/6Jr06O4h n4/4hvorn4i13LhF1b+gk01Xf8iVH3f/qy+PS3KJFcVSQpd2/T71swZYRSGKpuJbYoUJ mTH9DTjVQ6f0YLD+jixIEhk3RWDsVzfUwXXrKxGa3X91n7fpiovUF1modxP2SdYU+N8q uguA0ObkQ8WP1ZQh7sFzux2Zq8Iobdxxsn8T66t2iHEfaZ9bXM+q1a+QpJj/7i2ccZwf jr6x+X1ScieySATkd/4AVh1/Y1AaIw5PGeM69xC0lRM107BxvdSabgQL6FQOEXSGhuZz /YSg== 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:mime-version :content-transfer-encoding; bh=rNn5i4yAZd+OLdBdAlBgN/dFTRSN/RB4MpW5tXzgrMg=; b=OfJXiGxT66DXKEA8hytWzycyKLBMXMY2GVC4E0om4V7TdtR2UwqVBCYsuaYmGcuqdX 8q3jhYT7xYegtUWCthw29twde2o3ocmnSnX4eOdvNMRvWigJpwzh2t5Cq8mXh3uhXIjs dJH34OS+aLHYhUkJe8aAaZkKfcRw6gq3KbaWGPNBzhkLuvHvCnOcW8EXG4cBGc8B9V4z hJWJDqG5lVxYqD3WN+sWcaBUTENfDuR2ELVky+BGmStl5tY17FBbynrK3AioRCp/FpWY 8srbUacS1ilYxeHs5YGW7GIdX1b9c/oXYadEiCAMY7S3XPsQ8xr0LlNFgrIdIV/te4BX sPcg== X-Gm-Message-State: AOAM533Cgs+MMuWOJxm35H/iMbL+pKROhukq+gXsGLb9gBdDN9PFB27K bI8EWhXoPcFMHF711/ley9SUMzOmg2U= X-Google-Smtp-Source: ABdhPJw7cra3uv6dQzM9Z/bYbpcbGpDbR1zCw4BkseWtJwbqEhnspZh8HTppvzKVtdfem4H794qDQQ== X-Received: by 2002:adf:c182:: with SMTP id x2mr2392623wre.400.1598972627029; Tue, 01 Sep 2020 08:03:47 -0700 (PDT) Received: from localhost.localdomain ([81.2.169.31]) by smtp.gmail.com with ESMTPSA id l18sm2655252wrm.52.2020.09.01.08.03.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 08:03:46 -0700 (PDT) From: Derek Buitenhuis To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Sep 2020 16:03:32 +0100 Message-Id: <20200901150335.103855-1-derek.buitenhuis@gmail.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/4] avformat/mov: Fix return type used for av_seek in mfra code 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: dalecurtis@chromium.org Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" It should be a 64-bit integer, otherwise it overflows and fails on files greater than 2GB on some systems like x86_64 Linux. Signed-off-by: Derek Buitenhuis --- libavformat/mov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index dcec74662d..f0b4edc2ed 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -5095,7 +5095,7 @@ static int mov_read_sidx(MOVContext *c, AVIOContext *pb, MOVAtom atom) // See if the remaining bytes are just an mfra which we can ignore. is_complete = offset == stream_size; if (!is_complete) { - int ret; + int64_t ret; int64_t original_pos = avio_tell(pb); int32_t mfra_size; if ((ret = avio_seek(pb, stream_size - 4, SEEK_SET)) < 0) From patchwork Tue Sep 1 15:03:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derek Buitenhuis X-Patchwork-Id: 22049 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 3DC16449D11 for ; Tue, 1 Sep 2020 18:11:02 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1598E68AD4C; Tue, 1 Sep 2020 18:11:02 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BCDCF6880D5 for ; Tue, 1 Sep 2020 18:10:55 +0300 (EEST) Received: by mail-wm1-f66.google.com with SMTP id a9so1525609wmm.2 for ; Tue, 01 Sep 2020 08:10:55 -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=Jbksy4iz9bPmXR8w0o3ISYR8zxgojvmlpky+rQ+82Pg=; b=oAIFrBQ4x/Krec63THB3EZH5RUP88KHAMdxjdE4PzVt19u331Sw2oTxXwFytgqUqXS Y4O/juNtKlqwJFy+rtwBtplKvcWa3UY6F++3qS1wE6sa6p1KD+Y7is1mXkvBnHZ6wXzn SS0aOWs8TpkAE+p2i+nHWyuLjVFIg1dEdYvIaSzKTFw6dQmwMg7IVHoEotvcCTp/EyQd HBlrGSqdHeKwnAPwsnd14NWI+P5kRzNW7meHuKlkVvEX+gR7aCuOaKSJPZIUW2FK9Jid hB3/2958NIiGf+T0kInxHEuYzdq7maNX9NGb1XyXA/lcpPG7aSvk7pCdNqnQDghuIbMj HR3w== 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=Jbksy4iz9bPmXR8w0o3ISYR8zxgojvmlpky+rQ+82Pg=; b=C7uWJ4G3Ny/aZaH45gItbIpD0TKEmVBtCyQ1LPY7oOqO/noevXeA6/DNfvz3V0GRBK vGcDXK19qWNihDN56qE/3WUwwCIczIRwXNRiiC+YHIV8/zZscv/Humvm00T1QzVaNGkR H+QPmt4nVF9UxjKuxeX3S/8E+X2b9MRzMOVawJWK49fcbPerRMGeExwAvoELoChirxEz Pm8pbGEkYQIsAFDQYAuARpGuiRixzl+rfnlAYVtHO08jOOxQC9hJmV9jyINs01B0L2DU 9CtzHvw4S0Lcq0hNw4IqizznnXUgnPZE87Cm9gmv8ZtCzuZI68x3wOtrBSs2Ik2g/BAz KUKA== X-Gm-Message-State: AOAM530lv+A6d/99O0yn2HWbcFE4HuTHMku2BHWcACmgiBKbVtLKEjHp Dcnml8LtdY4z8IXqknmWR4yT65sjVNE= X-Google-Smtp-Source: ABdhPJydDIL+uLRmrH+AgdPdfWEggKQuj8l5PodubJekKcfGh3ZRemw2Lybo6NrGG23e4fBaURKD6w== X-Received: by 2002:a7b:c76e:: with SMTP id x14mr2182154wmk.176.1598972628062; Tue, 01 Sep 2020 08:03:48 -0700 (PDT) Received: from localhost.localdomain ([81.2.169.31]) by smtp.gmail.com with ESMTPSA id l18sm2655252wrm.52.2020.09.01.08.03.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 08:03:47 -0700 (PDT) From: Derek Buitenhuis To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Sep 2020 16:03:33 +0100 Message-Id: <20200901150335.103855-2-derek.buitenhuis@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901150335.103855-1-derek.buitenhuis@gmail.com> References: <20200901150335.103855-1-derek.buitenhuis@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/4] avformat/mov: Do not try and seek to an mfra if the reader can't seek 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: dalecurtis@chromium.org Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Derek Buitenhuis --- libavformat/mov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index f0b4edc2ed..49c2d05d21 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -5094,7 +5094,7 @@ static int mov_read_sidx(MOVContext *c, AVIOContext *pb, MOVAtom atom) // See if the remaining bytes are just an mfra which we can ignore. is_complete = offset == stream_size; - if (!is_complete) { + if (!is_complete && (pb->seekable & AVIO_SEEKABLE_NORMAL)) { int64_t ret; int64_t original_pos = avio_tell(pb); int32_t mfra_size; From patchwork Tue Sep 1 15:03:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derek Buitenhuis X-Patchwork-Id: 22050 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 6A52D449EA5 for ; Tue, 1 Sep 2020 18:12:13 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4F19968AD4C; Tue, 1 Sep 2020 18:12:13 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E163368AD1A for ; Tue, 1 Sep 2020 18:12:06 +0300 (EEST) Received: by mail-wm1-f66.google.com with SMTP id o21so1542961wmc.0 for ; Tue, 01 Sep 2020 08:12:06 -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=D7jzkJ+h8JsR5zuKxNiVLjZ+IzHltnGYcK5KKCRVt9U=; b=n8TYRrbW8mXBqOxAiHSEi/DWXibYJi9F4xfn47LN/dc+BifREAew/iSRVA13cMyMKa mSS9sRCAFN85SHnYuNC6RGVdMktVuMTld8Dzsu8MZNEoRTuD+YDiG6cHai4afXao6DVo CbWnv3OQiLLLm1q0SDQR/lxMhM2+vlHswYEdAdRWL/yOEFcjMdN2vtdi3iiqFgrDNmpD RqrjH1MxcEz3d4BZd259T7f2pQx9y/OhDHKB0HyY9L4N19zifVI4Moi06zmcDOiLzvFK weKCJcS8QEx3AAi5d3vFSEsYsYMj436l1kY0PY414igAMZcXSmRDtrqvVaZVTfNP33nC BeKg== 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=D7jzkJ+h8JsR5zuKxNiVLjZ+IzHltnGYcK5KKCRVt9U=; b=KyR77y8ZxpRS0lMYMX9rNd/z4WmSAglgGWx4RJ0hCx3mU6eSWBy1jqVVPJKL2jQ03/ Pa1IZjujm6b/5yJBaiyGuebEEs2sNSbueawUe12upvLsVrwFALkM+MZ5ThvwOEpE7jy7 9DFl+MRNTVplkm6vyYf4WVvEaswpS/00cNtZO7Vl+TRMSrh9kcw0Q0M0e2ZSHfvpGDtP nhz+UFBDG6AwHsHCC+d61VM91BGccMd5kB3/M4pNXVDZgQBYHNoiRaxGaM4Zj4mnK/Ji I6gqPYQp0WFs9SnObihB7y2gSZTl+4+o6sF0a/tX9TUnf7FuwXUHA2lZ91kM2hhhMtjm 7eig== X-Gm-Message-State: AOAM532JXXBgKcwDBF7QVkImrTB+T2vWQqVKSZ19xHLFaD7zTwQPNSYn DkH8SbcRXXT6MhmnuAVlcTER6QTa8p4= X-Google-Smtp-Source: ABdhPJxCA27U7tQJhQj7YtvBJrxeCQOs7LGhXqRUjx8W0UPfZFF03Dk3tuiQlKHxwBb6gviUwa9hcQ== X-Received: by 2002:a1c:ed16:: with SMTP id l22mr2083635wmh.80.1598972629692; Tue, 01 Sep 2020 08:03:49 -0700 (PDT) Received: from localhost.localdomain ([81.2.169.31]) by smtp.gmail.com with ESMTPSA id l18sm2655252wrm.52.2020.09.01.08.03.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 08:03:48 -0700 (PDT) From: Derek Buitenhuis To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Sep 2020 16:03:34 +0100 Message-Id: <20200901150335.103855-3-derek.buitenhuis@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901150335.103855-1-derek.buitenhuis@gmail.com> References: <20200901150335.103855-1-derek.buitenhuis@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/4] avformat/mov: Only read the mfra size once during sidx parsing 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: dalecurtis@chromium.org Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" On files with more than one sidx box, like live fragmented MP4 files, it was previously re-reading and seeking on every singl sidx box, leading to extremely poor performance on larger files, especially over the network. Only do it on the first one, and stash its result. Signed-off-by: Derek Buitenhuis --- libavformat/isom.h | 2 ++ libavformat/mov.c | 16 +++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/libavformat/isom.h b/libavformat/isom.h index 41a9c64c11..78495fd336 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -291,6 +291,8 @@ typedef struct MOVContext { int decryption_key_len; int enable_drefs; int32_t movie_display_matrix[3][3]; ///< display matrix from mvhd + int have_read_mfra_size; + uint32_t mfra_size; } MOVContext; int ff_mp4_read_descr_len(AVIOContext *pb); diff --git a/libavformat/mov.c b/libavformat/mov.c index 49c2d05d21..e33031f158 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -5097,14 +5097,16 @@ static int mov_read_sidx(MOVContext *c, AVIOContext *pb, MOVAtom atom) if (!is_complete && (pb->seekable & AVIO_SEEKABLE_NORMAL)) { int64_t ret; int64_t original_pos = avio_tell(pb); - int32_t mfra_size; - if ((ret = avio_seek(pb, stream_size - 4, SEEK_SET)) < 0) - return ret; - mfra_size = avio_rb32(pb); - if (offset + mfra_size == stream_size) + if (!c->have_read_mfra_size) { + if ((ret = avio_seek(pb, stream_size - 4, SEEK_SET)) < 0) + return ret; + c->mfra_size = avio_rb32(pb); + c->have_read_mfra_size = 1; + if ((ret = avio_seek(pb, original_pos, SEEK_SET)) < 0) + return ret; + } + if (offset + c->mfra_size == stream_size) is_complete = 1; - if ((ret = avio_seek(pb, original_pos, SEEK_SET)) < 0) - return ret; } if (is_complete) { From patchwork Tue Sep 1 15:03:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derek Buitenhuis X-Patchwork-Id: 22048 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 02391449BE3 for ; Tue, 1 Sep 2020 18:09:09 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D4F5868AC37; Tue, 1 Sep 2020 18:09:08 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1B11168A585 for ; Tue, 1 Sep 2020 18:09:02 +0300 (EEST) Received: by mail-wm1-f44.google.com with SMTP id c19so1166675wmd.1 for ; Tue, 01 Sep 2020 08:09:02 -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=ba1u49SX4tgGEOmHAF0LhCWx0HByqN1MWyfAifASitQ=; b=i2GIeZ9URZURoQhyVGqvjsHzzoM35EqZLHR0ShtF+yMFVPshz9Ck0f7fuKohhbzEXi 5KwDyyEeSxl4Rn+Hl7AoM0f2rRdHPnpodWkaoJP0xtwjj+xUv9X2CCPtvbGJt4m0s+LU ZQkl7tn2lyuSMFXyNzojMrBsw2LnciW5iq4ZqQ4JJhK/UTUEFTwJy/iLpavMKACvCAy5 G8MuHQoftKhIT25bdz9C/U8Kq9h2u5ggAMQV9r1a8WqPPeoHYBT+d1qkGGk2jTjJhPNc /bT+9b/77wb2xiNXpqChc6QVqXEll/+OH0baENuKo2J5MyHnEEyYomdB9BfG41N51MGH hFCA== 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=ba1u49SX4tgGEOmHAF0LhCWx0HByqN1MWyfAifASitQ=; b=FEI7qustY0mdP+IoMhkkHQ2c1vJuYrr9Pdie5clN3d+all7oQfBqc0YKGRYFnhjeUa w/OEP38OFH8JJGLP75hX3b5xXs8t1kMf1Xwm2bUMalkmmAcAnEvItw5LiDo6YH9ds6FB C1G/HVeIosVMHI3oZaOeCJcCmraWKhXZJoI343vGUgpB58UqIQgbI8XKHVD+1lyfMAXv 94ZmxWLOaqkDDlNgo7dB2pEEOOzKKlev/OOFIfpP6Du9zn8GND1P2DwuYlsJj8BiGtNH m7c33DFGwiNPDfX18NsEE8TOQ82TcFDHg356w/wVUAJPVeElkHWySHswbxFm3Rd+I8Et 18cw== X-Gm-Message-State: AOAM530F4ZYJgbO8IEyZdfHj0eGsF4KaISh941V69K+s6GMmkO77Wa2m o3LTrEoP2fiSj4taiHnbTOT5RVPgcO8= X-Google-Smtp-Source: ABdhPJybXTfUXnok4JWcAayEK8gzWAy11Crk/fJJZHRqbXM/fyVGzVgd4pTuV4+RWF/qK+yl1l/IUw== X-Received: by 2002:a05:600c:2183:: with SMTP id e3mr2311228wme.49.1598972631022; Tue, 01 Sep 2020 08:03:51 -0700 (PDT) Received: from localhost.localdomain ([81.2.169.31]) by smtp.gmail.com with ESMTPSA id l18sm2655252wrm.52.2020.09.01.08.03.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 08:03:49 -0700 (PDT) From: Derek Buitenhuis To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Sep 2020 16:03:35 +0100 Message-Id: <20200901150335.103855-4-derek.buitenhuis@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901150335.103855-1-derek.buitenhuis@gmail.com> References: <20200901150335.103855-1-derek.buitenhuis@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/4] avformat/mov: Stash mfra size if we're reading it anyway 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: dalecurtis@chromium.org Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This also changes a check for mfra_size from < 0 to == 0, since it was always wrong, as avio_rb32 returns an unsigned integer. Signed-off-by: Derek Buitenhuis --- libavformat/mov.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index e33031f158..e901eb527f 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -7499,22 +7499,22 @@ static int mov_read_mfra(MOVContext *c, AVIOContext *f) int64_t stream_size = avio_size(f); int64_t original_pos = avio_tell(f); int64_t seek_ret; - int32_t mfra_size; int ret = -1; if ((seek_ret = avio_seek(f, stream_size - 4, SEEK_SET)) < 0) { ret = seek_ret; goto fail; } - mfra_size = avio_rb32(f); - if (mfra_size < 0 || mfra_size > stream_size) { + c->mfra_size = avio_rb32(f); + c->have_read_mfra_size = 1; + if (c->mfra_size == 0 || c->mfra_size > stream_size) { av_log(c->fc, AV_LOG_DEBUG, "doesn't look like mfra (unreasonable size)\n"); goto fail; } - if ((seek_ret = avio_seek(f, -mfra_size, SEEK_CUR)) < 0) { + if ((seek_ret = avio_seek(f, -c->mfra_size, SEEK_CUR)) < 0) { ret = seek_ret; goto fail; } - if (avio_rb32(f) != mfra_size) { + if (avio_rb32(f) != c->mfra_size) { av_log(c->fc, AV_LOG_DEBUG, "doesn't look like mfra (size mismatch)\n"); goto fail; }