From patchwork Wed Mar 27 11:18:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diego Felix de Souza via ffmpeg-devel X-Patchwork-Id: 12484 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 9BC54448DC9 for ; Wed, 27 Mar 2019 13:21:42 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 86AA268A8D9; Wed, 27 Mar 2019 13:21:42 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A2B8F68A8A0 for ; Wed, 27 Mar 2019 13:21:41 +0200 (EET) Received: by mail-wr1-f65.google.com with SMTP id q1so18110090wrp.0 for ; Wed, 27 Mar 2019 04:21:41 -0700 (PDT) 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=Z4Nhl+NArqt6QeKYKN5Mjm3qzLg4eXoJDmzkMGaWJgw=; b=txkyHL1k7C1G990kQ116i7CvvJv7LnAJhMTl2stTjXTEXPRl8py28s/JlY2o5WYoBw zTTK9waiFMkUrP2e5SiNBA/WvvCS/Oa3SUZQhJBZsNGIWpjh8u050dzsIK8UXlwsd/lR jHlRIGMTQeF3oJO/oY0AQaGJ2UayPkORlfL7NgPJRKRQ9UUyA9QqmJgF5AjLCeqrDIbI ZX5mJ/jneygNkKsfmujdGa3ufKJrCLXvh1Tca539nVVT1+SrAOAls2nAnSTVpRKslsc7 2tjHNNyLyBotLzixp6RLQ8Ui3WnS0RH7OsFz+Fa0IhtOV4LO+Aym9IVgdBk9OvY7ReOM n2MA== X-Gm-Message-State: APjAAAWweTDemYbLowVWvGjCrl/Jal9KvMyQax/pW4QR9ZhbFefsR9K4 LcuBL9SMS6q3GfznAMVSajDEDS1RQTQ= X-Google-Smtp-Source: APXvYqziIyy7BU5qSVZLrT+L3FGRNFz40JlxudA+dsNcfoRyzjEvI+dZ+l/f7jd/TmAYybkTJRRkWA== X-Received: by 2002:adf:ef0f:: with SMTP id e15mr22116758wro.323.1553685700929; Wed, 27 Mar 2019 04:21:40 -0700 (PDT) Received: from localhost.localdomain (ipbcc08c44.dynamic.kabel-deutschland.de. [188.192.140.68]) by smtp.googlemail.com with ESMTPSA id h10sm31745448wrs.27.2019.03.27.04.21.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Mar 2019 04:21:40 -0700 (PDT) To: ffmpeg-devel@ffmpeg.org Date: Wed, 27 Mar 2019 12:18:48 +0100 Message-Id: <20190327111852.3784-18-andreas.rheinhardt@googlemail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190327111852.3784-1-andreas.rheinhardt@googlemail.com> References: <20190308092604.3752-1-andreas.rheinhardt@googlemail.com> <20190327111852.3784-1-andreas.rheinhardt@googlemail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 17/21] avformat/matroskadec: Don't reset cluster position 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: , X-Patchwork-Original-From: Andreas Rheinhardt via ffmpeg-devel From: Diego Felix de Souza via ffmpeg-devel Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt , robux4@ycbcr.xyz Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The new code does not rely on whether the cluster's position is set or not to infer whether a cluster needs to be closed or not (instead, the levels are closed during ebml_parse), so there is no need to reset the cluster's position at all any more. It will be automatically set to the correct value when a cluster is entered. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskadec.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index fc8c3f936c..3adcb3e86d 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -747,7 +747,6 @@ static int matroska_reset_status(MatroskaDemuxContext *matroska, { matroska->current_id = id; matroska->num_levels = 1; - matroska->current_cluster.pos = 0; if (position >= 0) return avio_seek(matroska->ctx->pb, position, SEEK_SET); @@ -1679,8 +1678,8 @@ static int matroska_parse_seekhead_entry(MatroskaDemuxContext *matroska, } } - /* Seek back - notice that in all instances where this is used it is safe - * to set the level to 1 and unset the position of the current cluster. */ + /* Seek back - notice that in all instances where this is used + * it is safe to set the level to 1. */ matroska_reset_status(matroska, saved_id, before_pos); return ret; @@ -3535,7 +3534,6 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska) } if (matroska->num_levels == 2) { - int err = 0; /* We are inside a cluster. */ res = ebml_parse(matroska, matroska_cluster_parsing, cluster); @@ -3544,7 +3542,7 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska) uint8_t* additional = block->additional.size > 0 ? block->additional.data : NULL; - err = matroska_parse_block(matroska, block->bin.buf, block->bin.data, + res = matroska_parse_block(matroska, block->bin.buf, block->bin.data, block->bin.size, block->bin.pos, cluster->timecode, block->duration, is_keyframe, additional, block->additional_id, @@ -3552,14 +3550,8 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska) block->discard_padding); } - if (res == LEVEL_ENDED) - cluster->pos = 0; - ebml_free(matroska_blockgroup, block); memset(block, 0, sizeof(*block)); - - if (err < 0) - return err; } else if (!matroska->num_levels) { matroska->done = 1; return AVERROR_EOF;