From patchwork Thu May 16 22:30:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 13154 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 771ED44964F for ; Fri, 17 May 2019 01:43:27 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 640CD68A376; Fri, 17 May 2019 01:43:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 512D4689D15 for ; Fri, 17 May 2019 01:43:23 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id e15so5061705wrs.4 for ; Thu, 16 May 2019 15:43:23 -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=n2T0ygomXBotN8EWOScj8/wMwwu31GhN0iKBdrOb8kg=; b=utzrPo5UK1ERK9Kw2ap3OPewieUynmPBinZuNFqRgdoje/0eznKyKsOCH17O1HF5hw nNhsDd3jH80/vyYceIb2qtNqTJNB7+GjCDvSOcBslgqDXIeh14JtEckfKiCTgX0SoGH7 RM//pAkkeWPq5k9ANT3RrybxmMkVq3pwcRQdz/Lb5R9iMUtdcu3AiQgeMvUhfyu2owy8 x/39JnCcFvugPOI2tFSOHLTY7wE32kpvYe7G4XWAMeLE0gx3ZHeqgKVyFtapHklf4GGj XvgHcNzT7wN6Y1m0ys1ePD54NDo1R4SczcFgz6eGQ5jjiW5S0biOS6Y3n0DwaEAZd6j3 cDNQ== 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=n2T0ygomXBotN8EWOScj8/wMwwu31GhN0iKBdrOb8kg=; b=q7ihyHDErE9yQcEixJLhm6sHzxpuJSsQkRrg4iNsVmW1RWil9tDyPb+iCypw1kjfLb kv0nGpkfzStRXdm7JxcoAqllCv8S+XsRJ9GEf4m7Mv4go25pzuykjPERZUEA3kfGIwnz btfiVTpOqqw+huix7id5kvQEZ57/+3U1YwxnVpzxyx+Jm7nZ2nY6sru/CKHDibvqu0cJ DwQzRnE0hYulIfWT6NOyjRWl/Sv1N6R4lYadtl97zPVEaQHwgAFgKwAGfb7JyslCDDCM eMMOb+N8v4M5dWu7s985Bju0nOkv7n5sxx6PapkYp/Y8cqVODplvzle3a14J4qO2pr/3 Iqhg== X-Gm-Message-State: APjAAAXFoYyguYfZrpgaJMX/1sdPzGKvCSOHjn56aAR8csubq4F0n2bE IPy/Rocsnlr05WUjjyLvkYL9VEM5 X-Google-Smtp-Source: APXvYqxCVlPsliLutnmjQ1xTLj27zhJBR3ROPJTPV1k4JNwqtBMuGxVbi1oSSYOrCN9xTz21SlqFQQ== X-Received: by 2002:adf:f788:: with SMTP id q8mr32574468wrp.181.1558046602687; Thu, 16 May 2019 15:43:22 -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.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 May 2019 15:43:22 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 17 May 2019 00:30:09 +0200 Message-Id: <20190516223018.30827-26-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 25/37] 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: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt 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, this is done in 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 4fe9978321..727d438481 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -770,7 +770,6 @@ static int matroska_reset_status(MatroskaDemuxContext *matroska, matroska->current_id = id; matroska->num_levels = 1; - matroska->current_cluster.pos = 0; matroska->resync_pos = avio_tell(matroska->ctx->pb); if (id) matroska->resync_pos -= (av_log2(id) + 7) / 8; @@ -1742,8 +1741,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; @@ -3598,7 +3597,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); @@ -3607,7 +3605,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, @@ -3615,14 +3613,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;