From patchwork Wed Apr 29 22:21:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 19386 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 08C3844B57C for ; Thu, 30 Apr 2020 01:22:37 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E31B968C22F; Thu, 30 Apr 2020 01:22:36 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D8A0768C207 for ; Thu, 30 Apr 2020 01:22:27 +0300 (EEST) Received: by mail-wr1-f66.google.com with SMTP id g13so4446955wrb.8 for ; Wed, 29 Apr 2020 15:22:27 -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=1cfSbp+TmO1AkHTCtZPLzGypBNbhMAohFtp3UfQfG2U=; b=eB2SpXalmxPP9fEFUGAG172rwQIrwVtmTT0ojN8RqlXDvEhb+3+tQ4RuQuRla9SIvC 61YYp/O4DQalfj85ipSGFSbK8hiilfLhBK8tpeO4G08E7/2i2QyqkDSiz4cLWlTKK6P1 zMBI8D0s7fMkDwXI/i/M08jct/8Ty9veUHkYzUvJSUmVKfWeoAKPpYABInWAC5fNEWJD G56v98arJ/UZgladXfGrJJSl7f6gMvRfIEdaffw3Wt6qVO7VVvxn0H0wTWkP/5dLBFLX cTI66+YZDrKgGZ+cnXRfMCePdd9qeSRAIqM+rkgYaV30+7HQOadBWz9xzhMhYnX10YgS ms5Q== 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=1cfSbp+TmO1AkHTCtZPLzGypBNbhMAohFtp3UfQfG2U=; b=PGTcM49exHLPDm2zp4Orn4kMH1tvem53zvWVGNbVkRKUVrcet24ncbVsIzqlItAz79 tQtt1By3/i45fWobLHZlDTZm2gvSPDWTwZlDkLLIhk4GjpB3RmGSgk6ptkFL5qWOkwLE 40GSJY3KoVFsisvHwZEVYFA4bBfWWTKKybf3FoX/AEzvv2hztawkF9n0GI2qbuW0YlIQ hQzjhejjButizVRZT0VQhJEoTWzA8Ml4svq59t6LljG2dymbU9L+S49fA7bns99kA84q YMIs4s3+MnLKx+/HYqYUZ8N4j2RAqKsa81tf1Q33412g52jpVTugk13EEQVqhrSbYnNK RBzw== X-Gm-Message-State: AGi0PuY9KPyIcciCpifwDbDi7+ElrZ+s/N7qyhAPLetu2kO079D5xywC yX72vChzuxgQSPtBAeFGczTN6ShG X-Google-Smtp-Source: APiQypIl6qNunWX8BkKmUZEosuhVuQ/L8oSS8t948/QrNInMIqGfM8kYVLWwswazX+FKLcYTpzEhKg== X-Received: by 2002:adf:82cf:: with SMTP id 73mr95017wrc.411.1588198947018; Wed, 29 Apr 2020 15:22:27 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id x6sm1071555wrg.58.2020.04.29.15.22.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2020 15:22:25 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 30 Apr 2020 00:21:54 +0200 Message-Id: <20200429222156.29129-4-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200429222156.29129-1-andreas.rheinhardt@gmail.com> References: <20200429222156.29129-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/6] avformat/matroskaenc: Simplify writing buffer 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" If one already has the contents of a master elements in a buffer of known size, then writing a EBML master element is no different from writing an EBML binary element. It is overtly complicated to use start/end_ebml_master() as these functions first write an unkown-length size field of the appropriate length, then write the buffer's contents, followed by a seek to the length field to overwrite it with the real size (obtained via avio_tell() although it was already known in advance), followed by another seek to the previous position. Just use put_ebml_binary() instead. 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 36c9ea1d9c..e671a572a8 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -893,9 +893,7 @@ static void mkv_write_video_color(AVIOContext *pb, const AVCodecParameters *par, colorinfo_size = avio_tell(dyn_cp); if (colorinfo_size) { - ebml_master colorinfo = start_ebml_master(pb, MATROSKA_ID_VIDEOCOLOR, colorinfo_size); - avio_write(pb, colour, colorinfo_size); - end_ebml_master(pb, colorinfo); + put_ebml_binary(pb, MATROSKA_ID_VIDEOCOLOR, colour, colorinfo_size); } }