From patchwork Tue Apr 2 13:32:52 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: 12588 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 EC371447FF3 for ; Tue, 2 Apr 2019 16:35:11 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D069E68ACA5; Tue, 2 Apr 2019 16:35:11 +0300 (EEST) 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 A78A568AC9E for ; Tue, 2 Apr 2019 16:35:05 +0300 (EEST) Received: by mail-wr1-f67.google.com with SMTP id g3so16681156wrx.9 for ; Tue, 02 Apr 2019 06:35:05 -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=xxxxe6qjTYeN5PgOrxSZU0BdA+cQZGYnCy0Z46lAZSo=; b=FlDGfgGk2VX3FZHOhQTUOAL9jHgL+hdAcij/cKjL3Q0Y+VIR3iFwwyYoceA58IZ2o+ s9CRug2IQxCEiZZMGHlF9VktAfUu9PD8PptrZPXBBXp10qEUDXxyYoN5OPBA6dcg4kOs jI3PN7o/jX2PcdZtskl4qIyel1qhcVTEm1blMW2wJZ6PEpF5upnvBnigmLjsaRB0JQTC VOI3KOF8TRpkxaM7AeVXPO9LZ1Tme9C3wOKp+yDDKCKTfFJbB6wsdFEJb4EDEuHewkDV 64qc+ewpwutM2nQsrp3AVY5i55J73IYDk12md/vfxcb4Xb+5vg6n93p44VtdgYRjHvXV wWFw== X-Gm-Message-State: APjAAAWIdvpvfSSr3NBsJ1mZIkfohpwofU5YkQVX8e49SNOKYzj1N97q sY8LZrj0gQOzYieFfywczM0EYsi6 X-Google-Smtp-Source: APXvYqxvBKwUVco+raWrboNXzIqGr3EONCy3M46heGO9Dioclv9Wop96UmMB+SILGuJoA3UNhoGiVQ== X-Received: by 2002:a5d:54c4:: with SMTP id x4mr43673983wrv.296.1554212104999; Tue, 02 Apr 2019 06:35:04 -0700 (PDT) Received: from localhost.localdomain (ipbcc08c44.dynamic.kabel-deutschland.de. [188.192.140.68]) by smtp.googlemail.com with ESMTPSA id t24sm15566886wmi.10.2019.04.02.06.35.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Apr 2019 06:35:04 -0700 (PDT) To: ffmpeg-devel@ffmpeg.org Date: Tue, 2 Apr 2019 15:32:52 +0200 Message-Id: <20190402133305.3328-3-andreas.rheinhardt@googlemail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190402133305.3328-1-andreas.rheinhardt@googlemail.com> References: <20190402133305.3328-1-andreas.rheinhardt@googlemail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/15] avformat/matroskaenc: Fix BlockGroup size calculation 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The earlier code included the size of the BlockGroup's length field and the EBML ID in the calculation of the size for the payload and ignored the size of the duration's length field. This meant that Blockgroups corresponding to packets with size 2^(7n) - 17 - n - i, i = 0,..., n - 1, n = 1,..., 8 (i.e. 110, 16364, 16365, 2097130..2097132, ...) were written with length fields that are unnecessarily long. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 394109ffe3..90f9d0a35e 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2057,9 +2057,7 @@ static int mkv_blockgroup_size(int pkt_size) int size = pkt_size + 4; size += ebml_num_size(size); size += 2; // EBML ID for block and block duration - size += 8; // max size of block duration - size += ebml_num_size(size); - size += 1; // blockgroup EBML ID + size += 9; // max size of block duration incl. length field return size; }