Message ID | 20200101005837.11356-9-andreas.rheinhardt@gmail.com |
---|---|
State | Accepted |
Headers | show
Delivered-To: andriy.gelman@gmail.com Received: by 2002:a05:6214:1865:0:0:0:0 with SMTP id eh5csp218408qvb; Tue, 31 Dec 2019 17:00:42 -0800 (PST) X-Google-Smtp-Source: APXvYqxEc+qH/U4aqsynvsrJvzrm0Br0FoFfr0gq0rvTmDykyDPqNulTYU8jlWTCnh85OMUx4dSF X-Received: by 2002:aa7:c5d0:: with SMTP id h16mr79258556eds.116.1577840442835; Tue, 31 Dec 2019 17:00:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577840442; cv=none; d=google.com; s=arc-20160816; b=sHYGlYp3ip3uwFX+3d5L6zPgW+kDGQHBrEWTe11CyUTr5858RUpz+3BE3hS3u0ZBTA 3UyNBqXNi0UkBJPiRgd/l3hH/4WibbDv8G8kh7mV8T80UjmMxZAo+HxDoL1Hil6oQ2Y3 /QlPJLAZD/zghE1EXfm5Y3LPLIXAkxUvOhyGXdUq7BWRFMNy1L28DD5+dxNySJaeq1Fv 7IYimSTkSLD6sMMohtKOJjWADufRq/4sJYtfTz/RG/Rfe8y6Sml4n6oeNvt0z59aSKfx LUcUhw4I7SZKjldKcTr5cRRJtnEfnLBLhfZclA283Bo1PEYAO9ppje1IuWd7g/YIzaOt tBjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=Gm5Grv6LraLCXGlkiwxiLiESbfZ1Ro4Jzf2So8hzdTk=; b=GP9vR2P6q3h/Btks4WMWzkqE6C8YaJAEtY+KW3n0xP6tHIPOTZI1BR1sgl8h0Z+XFK jBVb9CDleMFczCAVB6cWJ1r+ERRckIcWuhOhQVQL6JF8nFdXRDS1H4/KAQ5desDdwYjc zh04wu4t8GfzRwopDxQoSh9aACLNaaQQPmUL/E48XslIKcobwBkTJj/uMPQV19YyYfSJ 3FL2TRU2FW07hyA+fveAgDSFi/xm1l/XicC5B5/+/lhBSW6zc02STMsFKQb9iKjqAsvq 5a5rPLLmvQguR6xBxczZH6Exk0atJyVyMFvx5NxG/G/YoOAGwf5NwFxocSsRoREZY1/R lI4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=UzYUsQMr; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: <ffmpeg-devel-bounces@ffmpeg.org> Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id qp6si32080582ejb.21.2019.12.31.17.00.42; Tue, 31 Dec 2019 17:00:42 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=UzYUsQMr; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C8D5B68ADEA; Wed, 1 Jan 2020 02:59:19 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0D46368AD82 for <ffmpeg-devel@ffmpeg.org>; Wed, 1 Jan 2020 02:59:08 +0200 (EET) Received: by mail-wr1-f67.google.com with SMTP id z7so36141742wrl.13 for <ffmpeg-devel@ffmpeg.org>; Tue, 31 Dec 2019 16:59:08 -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=q/23xalTh7Hfwf+EwD72G6dmtd6gphEDzH2SgE4mDbg=; b=UzYUsQMriGrcrw98qBcLMeyId1ytHKC/RlQqV01yYHzCAKqsqTCKG6lFgNRqJwOq8m 4bKVlSsTyaqqfpjbCKF1gllIXm1s7ALbsIBEgpVdsP5gvYMD1bMkxV3A1NWK42cLuT27 AlYeDV/5ptF5dXDxozquvwvu6mxoDJPXZiQnX7KEKpVZ1blweuk5W5Zeewf7UFa4Za+C is9wFoSLI+AvrnJzLLuEPBY9jDBxTWXTXH5JcZEApeLWVf6ih0igB3ekvzZrAz9MaDTz v2O84kjqOL1rSI7aj734hhujF5JwHTEweFFhADGLqQUKeKqxnICwVd6xD9bq3xM98T8Q jrRg== 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=q/23xalTh7Hfwf+EwD72G6dmtd6gphEDzH2SgE4mDbg=; b=KOXMmsLoT27FvdHSQx4v5WUm4oaTIYQG1MIUOfx5mem4MDRlZ5CXYtl/iPKSf/6W4g /C6v1YxXIBcO8CnLZoQ8Okqmu4Lcq1i1El4DtTwKQyNLBj9Uf62FM14h0jeVyy8ZZI0q XnInPNUyccswGuyL7Goz93aJGgg7sOSgggPC5puJzuqBL5ZVu4D60AWrn35AYmZeu5Ea EkVWWgmo+1BIlyIeY9Z0VPiD6d8NN+5ef5Zz5LocSImtaq5fA4+476hHfR81pc4nF4Cy BxILoNtzaN2o4clsaNGoFlQGu1oBUnRb99/h8Vq922VkdSIXJpj5xhPaZe/N4622vyYF YBUA== X-Gm-Message-State: APjAAAVfK+4CviP0AomwVgeFe8emWtGyFHeevMnKOm5pXrMzwbjkvnfF 2k0O6rdIUzT0cR1P8TphMg11ybGw X-Received: by 2002:a05:6000:1052:: with SMTP id c18mr74066878wrx.268.1577840347467; Tue, 31 Dec 2019 16:59:07 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc08bbf.dynamic.kabel-deutschland.de. [188.192.139.191]) by smtp.gmail.com with ESMTPSA id w17sm52431655wrt.89.2019.12.31.16.59.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Dec 2019 16:59:07 -0800 (PST) From: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> To: ffmpeg-devel@ffmpeg.org Date: Wed, 1 Jan 2020 01:58:25 +0100 Message-Id: <20200101005837.11356-9-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 08/20] avformat/matroskaenc: Improve calculating EBML ID size X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org> List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>, <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe> List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel> List-Post: <mailto:ffmpeg-devel@ffmpeg.org> List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help> List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>, <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe> Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Cc: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org> X-TUID: xn78vk2Ccx6N Content-Length: 2440 |
Series |
Matroska muxer patches
|
expand
|
Context | Check | Description |
---|---|---|
andriy/ffmpeg-patchwork | success | Make fate finished |
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 25ad337844..cecf7589e5 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -183,7 +183,7 @@ typedef struct MatroskaMuxContext { static int ebml_id_size(uint32_t id) { - return (av_log2(id + 1) - 1) / 7 + 1; + return (av_log2(id) + 7U) / 8; } static void put_ebml_id(AVIOContext *pb, uint32_t id)
When the Matroska muxer writes an EBML ID, it calculates the length of said ID before; and it does this as if this were a number that needs to be encoded as EBML number: The formula used is (av_log2(id + 1) - 1) / 7 + 1. But the constants used already contain the VINT_MARKER (the leading bit indicating the length of the EBML number) and therefore the algorithm used makes no sense. Instead the position of the most significant byte set gives the desired length. The algorithm used until now worked because EBML numbers are subject to restrictions: If the EBML number takes up k bytes, then the bit 1 << (7 * k) is set and av_log2(id) is 7 * k. So the current algorithm produces the correct result unless the EBML ID is of the form 7 * k - 1 because of the "id + 1". But contrary to encoding lengths as EBML number (where the + 1 exists to avoid the encodings reserved for unknown length), such EBML numbers are simply forbidden as EBML IDs and as such none of them were ever written. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> --- libavformat/matroskaenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)