From patchwork Mon Oct 3 23:37:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 856 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.66 with SMTP id o63csp1859298vsd; Mon, 3 Oct 2016 16:40:54 -0700 (PDT) X-Received: by 10.28.133.70 with SMTP id h67mr896447wmd.61.1475538054587; Mon, 03 Oct 2016 16:40:54 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id g185si1531444wma.68.2016.10.03.16.40.53; Mon, 03 Oct 2016 16:40:54 -0700 (PDT) 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; 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 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 0C524689CD5; Tue, 4 Oct 2016 02:39:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oi0-f67.google.com (mail-oi0-f67.google.com [209.85.218.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9B14E6803BC for ; Tue, 4 Oct 2016 02:39:19 +0300 (EEST) Received: by mail-oi0-f67.google.com with SMTP id r132so9093042oig.1 for ; Mon, 03 Oct 2016 16:39:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=kYKco45ipu87ZsFEpazo0EOkZuusBuA0WPJeLfYK9go=; b=qNqrdcWK3QknlX4w9xhCBgnOE0Wec8fr5MkR5uEBcwRhkfOOBuRekUhA7sCDuzAsDQ xt+h+xkJmLL2aNdMR4o+uYfVoxCJQ/PSaEIZpMIseEwGMkTF0f2IxXaslo37IjflBPyE MX8vxYYRFwBgUgLZKeMFka6upYfJ1aMF/Fpr9mqUvJHmAefDngko3AT6qbq2ctoFVPe1 5vRBmzdBFDnX63gvQAk6NO193flveh1YNLrFTbUk4mW5eHZ7GEgjTM1FgBSvUpp+Cse2 +zebKn5oV4z/nmPY1Pl43IY2+PfAj975SAag2SDqbd8D+w/alohYf62qkiSU3Z+bLbnr XQPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=kYKco45ipu87ZsFEpazo0EOkZuusBuA0WPJeLfYK9go=; b=YBYbh5t6oaijYC+K+I4dxCrFG7F4MzVOTQe6dfPKafYsSUzExA/ipAg2P/PraJtWbB /0BvGg/K5oH3LnlqCBxOepe1Lb62Yq5kb3958En/LpiwLNf5whUpFP/B7aV3s84pEImV tqS98LJ/Q254dzXqwvOr+JHQbxe7ZvZMQeq+cqkniPlPKa8evWtU4DXmWmLJoZr1xBPU mrLW3iXW4Tyg2q90HL73louXAz+hkavXsbsHkiR7Ej84U18Tpo3Les+AxIRT6MhV0xay 468jt2kkz2RqsZJGgwYMUzxDj0eRQ+Y1lEjOIlqAYSXnSkePuhJOv9r30271Qnh2UDNL Cu+Q== X-Gm-Message-State: AA6/9RnPgFkU24eu4q5DMOSaw8AqT7mKpQdIwl/Bqozt9GhFgfwLTssyb5+XKEig0nRqsQ== X-Received: by 10.202.221.138 with SMTP id u132mr490151oig.120.1475537972835; Mon, 03 Oct 2016 16:39:32 -0700 (PDT) Received: from localhost.localdomain ([181.22.58.118]) by smtp.gmail.com with ESMTPSA id m66sm183582oia.25.2016.10.03.16.39.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Oct 2016 16:39:32 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 3 Oct 2016 20:37:04 -0300 Message-Id: <20161003233707.3624-9-jamrial@gmail.com> X-Mailer: git-send-email 2.9.1 In-Reply-To: <20161003233707.3624-1-jamrial@gmail.com> References: <20161003233707.3624-1-jamrial@gmail.com> Subject: [FFmpeg-devel] [PATCH 08/11] avformat/matroskaenc: write a CRC32 element on Chapters 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Implements part of ticket #4347 Signed-off-by: James Almer --- libavformat/matroskaenc.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index d2b158f..9687833 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1254,7 +1254,7 @@ static int mkv_write_tracks(AVFormatContext *s) static int mkv_write_chapters(AVFormatContext *s) { MatroskaMuxContext *mkv = s->priv_data; - AVIOContext *pb = s->pb; + AVIOContext *dyn_cp, *pb = s->pb; ebml_master chapters, editionentry; AVRational scale = {1, 1E9}; int i, ret; @@ -1265,10 +1265,12 @@ static int mkv_write_chapters(AVFormatContext *s) ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_CHAPTERS, avio_tell(pb)); if (ret < 0) return ret; - chapters = start_ebml_master(pb, MATROSKA_ID_CHAPTERS , 0); - editionentry = start_ebml_master(pb, MATROSKA_ID_EDITIONENTRY, 0); - put_ebml_uint(pb, MATROSKA_ID_EDITIONFLAGDEFAULT, 1); - put_ebml_uint(pb, MATROSKA_ID_EDITIONFLAGHIDDEN , 0); + ret = start_ebml_master_crc32(pb, &dyn_cp, &chapters, MATROSKA_ID_CHAPTERS, 0); + if (ret < 0) return ret; + + editionentry = start_ebml_master(dyn_cp, MATROSKA_ID_EDITIONENTRY, 0); + put_ebml_uint(dyn_cp, MATROSKA_ID_EDITIONFLAGDEFAULT, 1); + put_ebml_uint(dyn_cp, MATROSKA_ID_EDITIONFLAGHIDDEN , 0); for (i = 0; i < s->nb_chapters; i++) { ebml_master chapteratom, chapterdisplay; AVChapter *c = s->chapters[i]; @@ -1282,22 +1284,22 @@ static int mkv_write_chapters(AVFormatContext *s) return AVERROR_INVALIDDATA; } - chapteratom = start_ebml_master(pb, MATROSKA_ID_CHAPTERATOM, 0); - put_ebml_uint(pb, MATROSKA_ID_CHAPTERUID, c->id + mkv->chapter_id_offset); - put_ebml_uint(pb, MATROSKA_ID_CHAPTERTIMESTART, chapterstart); - put_ebml_uint(pb, MATROSKA_ID_CHAPTERTIMEEND, chapterend); - put_ebml_uint(pb, MATROSKA_ID_CHAPTERFLAGHIDDEN , 0); - put_ebml_uint(pb, MATROSKA_ID_CHAPTERFLAGENABLED, 1); + chapteratom = start_ebml_master(dyn_cp, MATROSKA_ID_CHAPTERATOM, 0); + put_ebml_uint(dyn_cp, MATROSKA_ID_CHAPTERUID, c->id + mkv->chapter_id_offset); + put_ebml_uint(dyn_cp, MATROSKA_ID_CHAPTERTIMESTART, chapterstart); + put_ebml_uint(dyn_cp, MATROSKA_ID_CHAPTERTIMEEND, chapterend); + put_ebml_uint(dyn_cp, MATROSKA_ID_CHAPTERFLAGHIDDEN , 0); + put_ebml_uint(dyn_cp, MATROSKA_ID_CHAPTERFLAGENABLED, 1); if ((t = av_dict_get(c->metadata, "title", NULL, 0))) { - chapterdisplay = start_ebml_master(pb, MATROSKA_ID_CHAPTERDISPLAY, 0); - put_ebml_string(pb, MATROSKA_ID_CHAPSTRING, t->value); - put_ebml_string(pb, MATROSKA_ID_CHAPLANG , "und"); - end_ebml_master(pb, chapterdisplay); + chapterdisplay = start_ebml_master(dyn_cp, MATROSKA_ID_CHAPTERDISPLAY, 0); + put_ebml_string(dyn_cp, MATROSKA_ID_CHAPSTRING, t->value); + put_ebml_string(dyn_cp, MATROSKA_ID_CHAPLANG , "und"); + end_ebml_master(dyn_cp, chapterdisplay); } - end_ebml_master(pb, chapteratom); + end_ebml_master(dyn_cp, chapteratom); } - end_ebml_master(pb, editionentry); - end_ebml_master(pb, chapters); + end_ebml_master(dyn_cp, editionentry); + end_ebml_master_crc32(pb, &dyn_cp, mkv, chapters); mkv->wrote_chapters = 1; return 0;