From patchwork Wed Jan 22 19:27:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 17475 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 A06CC44B208 for ; Wed, 22 Jan 2020 21:27:48 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 89A8668B469; Wed, 22 Jan 2020 21:27:48 +0200 (EET) 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 28AD768B45F for ; Wed, 22 Jan 2020 21:27:41 +0200 (EET) Received: by mail-wm1-f66.google.com with SMTP id t14so271874wmi.5 for ; Wed, 22 Jan 2020 11:27:41 -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=2BdvTe6DsRf88oYiCn7g0XJn0tsZhmiuNhJg11z0F4Y=; b=nQhmN6PEEIZpFL70wuIkHKx164yxcVhjt2ZhcKOpbyElbXs6vVimHMs2+uLOkpKcJo ZteCFXXy2FNocY/a2wsspk6+oxIEktPea5YZAB8TmXczyhJS9kAxO8a7JoqN6EPeI6+O QUcEQ8mL2BLFyiovEmUMm4Oax2V0/4KZC11wZt4iZAyto3wPYuSRwziqi/vS5yPdtKcs OX5u+uz4TcURFGsFnK8VBqisZhnid7LPFEHwESVCnlqQ5TfrMmaE8nTz8udftPwvCyt1 8nwu0p1RyrXyfWyChvZ9h/wiwovVRDwjmJ0OyfAyf6hwcedsyRbIH2KKrXtKrhnQvFBj /puw== 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=2BdvTe6DsRf88oYiCn7g0XJn0tsZhmiuNhJg11z0F4Y=; b=rG8P1B6I1wP0H+95oopKus3BQr6ionUDIldE66KFzrbdSQ5ydNxcrdstby9fP2pe8z aqxqUGpKiPib2RRsd/De5E9Uo/EVNZ4hMQi83KtQ59tg3p8AXHMNQsqOZfEmzIcYbA9j nly8uHLJWv7B1VKWYdJXr/7ZfDxS3qYTZWpXrNNvNrurFlFr8wxJThi8hix0loKFh9Kd 3GBsgeHbY91sd1Rjb1bAJQY8PlwI4ghjH0btvPVVe9Ip/FcGwmvJbyZ3m+ycQiuaF685 rE8gBpkj5McLUBX3FK3Gkwb6qoJdOMTJYnZ+LZhgy/PnFtXbGAbYsf3zep8VvL4pXRUX F3Bw== X-Gm-Message-State: APjAAAX0+82vDhFA29L2u8WtxlyR/tmQPHNMZAMAa9xtG3Die1LwVadv 0Oji/WLROGS65uXFAWhUQJIe+QDc X-Google-Smtp-Source: APXvYqwwC3OPzE8HSOQ/P20ej8JsoDhAtLbNlkJ8Idl8Td5fd6pqwXMD7Ysy5nZgx0OWRtu9BKNaxA== X-Received: by 2002:a1c:96c4:: with SMTP id y187mr4629142wmd.112.1579721259615; Wed, 22 Jan 2020 11:27:39 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc08bbf.dynamic.kabel-deutschland.de. [188.192.139.191]) by smtp.gmail.com with ESMTPSA id v3sm58196792wru.32.2020.01.22.11.27.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2020 11:27:39 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 22 Jan 2020 20:27:17 +0100 Message-Id: <20200122192717.11678-3-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200101005837.11356-1-andreas.rheinhardt@gmail.com> References: <20200101005837.11356-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 28/28] avformat/matroskaenc: Improve checks for updating Tags 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" When updating the Tags at the end, the Matroska muxer would twice check for whether (!mkv->is_live) is true, despite this code being only executed if it is. Furthermore, a loop iterates over all the streams even when there is no Tags element to update at all, because the check for whether there are Tags is only performed later. This commit fixes this. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 354096266d..444032b431 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2567,7 +2567,7 @@ static int mkv_write_trailer(AVFormatContext *s) end_ebml_master_crc32(pb, &mkv->tracks_bc, mkv, MATROSKA_ID_TRACKS, 0, 0); // update stream durations - if (!mkv->is_live) { + if (mkv->tags_bc) { int i; for (i = 0; i < s->nb_streams; ++i) { AVStream *st = s->streams[i]; @@ -2589,8 +2589,7 @@ static int mkv_write_trailer(AVFormatContext *s) put_ebml_binary(mkv->tags_bc, MATROSKA_ID_TAGSTRING, duration_string, 20); } } - } - if (mkv->tags_bc && !mkv->is_live) { + avio_seek(pb, mkv->tags_pos, SEEK_SET); end_ebml_master_crc32(pb, &mkv->tags_bc, mkv, MATROSKA_ID_TAGS, 0, 0); }