From patchwork Thu May 16 22:30:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 13162 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 DD6CA44966A for ; Fri, 17 May 2019 01:45:42 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 04C8768A642; Fri, 17 May 2019 01:43:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1688A68A4BD for ; Fri, 17 May 2019 01:43:33 +0300 (EEST) Received: by mail-wm1-f68.google.com with SMTP id i3so5113903wml.4 for ; Thu, 16 May 2019 15:43:33 -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=OTMpgxk182DumlIYwHftvsoDL4sz9URdzPVf9d/DKEg=; b=Zx9P1YuIVzApuIc+6OBPD7NdzMdxhhWOFi3XhCphrxXuLL27Yuojt7NPIPes4Yzj+W kc/6NMAXQlC2Zqr7WaeI+N5x5tBJNgRXXQIXBgMBFrDqSIb2FDAGRydb6auCRN13S5UK 1pBhRk/G0lqqr67iTWXdMxKqH2HCD8QnWTHONzw6XZD13JJH6tyvAsgXMp5D2CeKn4St AURJ0rApIILg07suk78gol4sYkDA+wHhJZi/kum/cMTvF1EMrdq5ANiVshV7BBYzrHlT 0Zr0oqC44Jjf6UJD81/SP6kn2It7WGS1Pi09E5ExCyY4QQGe47YgKr/qMnlbzjz0ppxc 3pSA== 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=OTMpgxk182DumlIYwHftvsoDL4sz9URdzPVf9d/DKEg=; b=VsiVCTx+Eq1oPHb4W47RdWTSym98+o4lwqBM8yUNDDNw3z3dryW2qXS/P7sGcVyhJH 58/EY684NQwPqelqWhOPE5ICAot+4tN1YVgxdGC4nzIcLHseD9PvISqWg3ee2EIfdxfI Rv9jKcNSvXWTBqOzNJrsRqZoeRFdOBEhTywub9HHBUs6bGEFBuIHr2VSKBwzyJ3a6l/h H8NDVBEMEWPfxH9hhL18ZS88SvhyrV9xJVmIwtPZHALhw19FHj5obzKEHLi6dkHzrzI7 m0/FCzpN9SSfgW72VcwJKg/kBXFBFV+I1amZyXq6rI/1WDmC7lXs1eruJI1ibJo/Ros3 9/zw== X-Gm-Message-State: APjAAAVQdT9QCBdXwm4rsxgiuyXaHfqYBoIuB1aKXs5HWtuHZo2muzs/ CTPgM57PMAo5SHpuyDuV0OIH+kcG X-Google-Smtp-Source: APXvYqzi/SuqNyHs7pOuTmoZ4TNKQxOyGmwZUykHNSLliM8TJ0y7/FvCX8wFQ8gjaLgLhXDFQm5YJg== X-Received: by 2002:a1c:e1d7:: with SMTP id y206mr92843wmg.104.1558046612417; Thu, 16 May 2019 15:43:32 -0700 (PDT) Received: from localhost.localdomain (ipbcc18715.dynamic.kabel-deutschland.de. [188.193.135.21]) by smtp.gmail.com with ESMTPSA id i185sm11168725wmg.32.2019.05.16.15.43.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 May 2019 15:43:31 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 17 May 2019 00:30:20 +0200 Message-Id: <20190516223018.30827-37-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190516223018.30827-1-andreas.rheinhardt@gmail.com> References: <20190516223018.30827-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 36/37] avformat/matroskadec: Use file offsets for level 1 elements 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" This commit converts the MatroskaLevel1Element struct to use file-based offsets, as opposed to the current practice of using offsets relative to the beginning of the segment in it. This also includes a change from uint64_t to int64_t. This is in preparation to another patch that improves the check for duplicate level 1 elements. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskadec.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index d200dc9061..0bf6477b0e 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -330,7 +330,7 @@ typedef struct MatroskaCluster { } MatroskaCluster; typedef struct MatroskaLevel1Element { - uint64_t pos; + int64_t pos; uint32_t id; int parsed; } MatroskaLevel1Element; @@ -1787,16 +1787,14 @@ static void matroska_convert_tags(AVFormatContext *s) } static int matroska_parse_seekhead_entry(MatroskaDemuxContext *matroska, - uint64_t pos) + int64_t pos) { uint32_t saved_id = matroska->current_id; int64_t before_pos = avio_tell(matroska->ctx->pb); - int64_t offset; int ret = 0; /* seek */ - offset = pos + matroska->segment_start; - if (avio_seek(matroska->ctx->pb, offset, SEEK_SET) == offset) { + if (avio_seek(matroska->ctx->pb, pos, SEEK_SET) == pos) { /* We don't want to lose our seekhead level, so we add * a dummy. This is a crude hack. */ if (matroska->num_levels == EBML_MAX_DEPTH) { @@ -1834,8 +1832,8 @@ static void matroska_execute_seekhead(MatroskaDemuxContext *matroska) for (i = 0; i < seekhead_list->nb_elem; i++) { MatroskaSeekhead *seekheads = seekhead_list->elem; - uint32_t id = seekheads[i].id; - uint64_t pos = seekheads[i].pos; + uint32_t id = seekheads[i].id; + int64_t pos = seekheads[i].pos + matroska->segment_start; MatroskaLevel1Element *elem = matroska_find_level1_elem(matroska, id); if (!elem || elem->parsed)