From patchwork Tue Sep 3 21:56:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 14888 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 CA130448A9A for ; Wed, 4 Sep 2019 00:57:51 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B8D2B680BCF; Wed, 4 Sep 2019 00:57:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f195.google.com (mail-qt1-f195.google.com [209.85.160.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7774B6804F5 for ; Wed, 4 Sep 2019 00:57:45 +0300 (EEST) Received: by mail-qt1-f195.google.com with SMTP id u40so13359395qth.11 for ; Tue, 03 Sep 2019 14:57:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=gDiu/Cz6vE13kKXm5rXCLVaA5/qn8pHl9SeAux3A3gc=; b=DJw4wuvwXUyoxeDjFdM/Vnd+D5anoPOLYHYXMTje3DCV+8a1VLbj+9sg5cfi0S8caQ rHMsdA/rdf/p8Y3dtqAO/w3Y5F4f52zyS+8zo2APuuPYOEmbmK7XdHc7M5CfjncGWrVu 9q92VdgzUR4IeGhTwZHXc4cKACAk43oz86zFSk3R5M2YbyxvQAPxJuA6A531f/QZt7e3 ahNFvGWE21ltvOyf3c1iS5Iy7OzI7x4/ZPWHtICO0cEdYMgrHYY/E/I/99Ezeaa2GGV4 CM8ctX9Sy5xzgCUixMcr4C9LmjnwRIwYN9pfa94pjYgu6n/I7tk3ZDnOwAS+tp+5pPf+ NWIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gDiu/Cz6vE13kKXm5rXCLVaA5/qn8pHl9SeAux3A3gc=; b=ihkUodqBzpJzMEbZabL2mHxjUlyMAghvVyx5oL1LaxXK09pSBQdyj3+L8D3/rxrFY4 mwI3un6rBPq/9IsiSvhFmFHB7hv6v0lqcf8yt66H5LTtz3lVRSr6/PdXQsaFrvoIWRWN rcmdcjhzzUWGx1O7kPQ3QAouviCXtNW2EZSDLK2hcyinJzIebSkc7j9hNj8lb+BrbYNA 6vUvi6VTjYyoVGJf3+1aZijrmYy0LNB+OrV+ecES5xrioXJKTq8Lb2ovWucziw8YO9Ej JJHyg6HBv4PsILjBP9npmbHGza3Ou5PBsAw1TeiOiU5HmqFHI4nrXGkyfh5QrtlEZtkJ wjnA== X-Gm-Message-State: APjAAAUltQ2cJGlVJ89FhZn9smUNkja87xIzPA3CJYQ8JEsyUNHEaSua 0p3dk8deusC3QRVQmYIedfvCwkag X-Google-Smtp-Source: APXvYqw7R3qCneKEAhnr7KBjTsKcPo5gZ5mgPBKTs793HQTFJBBsFW+sVW1u5K+QncmGbSlXYc5DPQ== X-Received: by 2002:aed:30e2:: with SMTP id 89mr21182178qtf.237.1567547863825; Tue, 03 Sep 2019 14:57:43 -0700 (PDT) Received: from localhost.localdomain ([191.83.220.27]) by smtp.gmail.com with ESMTPSA id t189sm9372571qkd.56.2019.09.03.14.57.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2019 14:57:43 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Tue, 3 Sep 2019 18:56:58 -0300 Message-Id: <20190903215658.745-2-jamrial@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190903215658.745-1-jamrial@gmail.com> References: <20190903215658.745-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] avformat/matroskadec: use av_fast_realloc to reallocate ebml list arrays 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Speeds up the process considerably. Fixes ticket #8109. Suggested-by: nevcairiel Suggested-by: cehoyos Signed-off-by: James Almer --- libavformat/matroskadec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 439ee462a5..fe45c4fd7f 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -110,6 +110,7 @@ typedef const struct EbmlSyntax { typedef struct EbmlList { int nb_elem; + unsigned int alloc_elem_size; void *elem; } EbmlList; @@ -1236,8 +1237,9 @@ static int ebml_parse(MatroskaDemuxContext *matroska, data = (char *) data + syntax->data_offset; if (syntax->list_elem_size) { EbmlList *list = data; - void *newelem = av_realloc_array(list->elem, list->nb_elem + 1, - syntax->list_elem_size); + void *newelem = av_fast_realloc(list->elem, + &list->alloc_elem_size, + (list->nb_elem + 1) * syntax->list_elem_size); if (!newelem) return AVERROR(ENOMEM); list->elem = newelem;