From patchwork Fri Dec 3 05:06:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?emhpbGl6aGFvKOi1teW/l+eriyk=?= X-Patchwork-Id: 31897 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp211245iog; Thu, 2 Dec 2021 21:07:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJzY+E2hE429yfkxghg/BmAEXCzld2uHU76km/sJ8EF0bhMoGbose9qzk1yixF7E1vmogbxr X-Received: by 2002:a05:6402:3595:: with SMTP id y21mr23799400edc.332.1638508058773; Thu, 02 Dec 2021 21:07:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638508058; cv=none; d=google.com; s=arc-20160816; b=QXsBl1HU5FZ9Sby2NbLl5oMNuQeA37ukfWacHnA9puKRuEeHqTxGvpzKhCcQ7ER8m4 cauPH3p2vORwYtlACv6m5UlrLHDerneSaNw3aqoPROu8givQT322+UHc0Heb/gs8lof8 TTkc8eqF4MxycQoMrxFOVOQ+yS149ZMsJxYMckg76u2RuAFX8PC4gCKKAMHNMfBwcYcd ry1K4GzwuLTyzTNnihoPzzxnIDrfD6/njABmEMP9CgyjoXi2ndMcGVFzRWfGPnTUce+R y/Ryf0gxFsIZgq43djFtK0U9gTOPnrmXcE/Ljh15f3oPN5HwVGXAMYNW7azTSAg09wzf Q99A== 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:date:to:from:message-id :dkim-signature:delivered-to; bh=puTeHt5ZFm5ovaDS/Xp0w523QUe5nA0RupMw2FblAdU=; b=NtoZ7m1WSLgpuOV4bgvqwfB/b7S5cG4TsyfxSdw36ninu4Onn86G8ItIR8jB76gig+ KkdRdaqkfRrCasTC5wbx0iY6BpniMHAagwS826N3/bHtZzC82aCk66fRnrCAxGayybpE X3J3wyaemwE2EaBd65l7q88fC3X8walfUUh2Hb21aUNqFufXTdiCcDXZRR0aEhEEInqh t3WPwlfcUiZP78xqUqT8P+nBXq1GSM5Vg6kC1oF9Hm2bySH+oxFFliDSOCOSFyRA0Wd/ lbejvg7SKDXdwRSDzYLNviV2v1dUUv7U8K2gVkCSwTjttL5UhX42Y6nZY+vmM/rwDOEV TIhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=h1bUJnvN; 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=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id x35si2982720ede.327.2021.12.02.21.07.38; Thu, 02 Dec 2021 21:07:38 -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=@foxmail.com header.s=s201512 header.b=h1bUJnvN; 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=NONE dis=NONE) header.from=foxmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E125F68AE5D; Fri, 3 Dec 2021 07:07:24 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out203-205-251-72.mail.qq.com (out203-205-251-72.mail.qq.com [203.205.251.72]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 356AB68AC4D for ; Fri, 3 Dec 2021 07:07:15 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1638508030; bh=P8SwBIaeRks9hzEsi8LxcGnkUa83H4Xw6+izo+asFhI=; h=From:To:Cc:Subject:Date; b=h1bUJnvNGSN27xcbUVBjdK6ByNa9E9J1d88GjvHb2XhyVlYKZVpjY9pPeA2mdVJTu EgszR+tUmJsK+8UwzUX1x2Jv/ChrpnnlfQtOpOVnRpha3pTGwsNwutTmw8JL1HYb4e ayQBinUUo8u09cv2k3jbsRFPiyNalEioQwz7hCLU= Received: from ZHILIZHAO-MB2.tencent.com ([113.108.77.56]) by newxmesmtplogicsvrszb6.qq.com (NewEsmtp) with SMTP id 1C926A18; Fri, 03 Dec 2021 13:07:09 +0800 X-QQ-mid: xmsmtpt1638508029t6i4ay0zd Message-ID: X-QQ-XMAILINFO: NzOHSugmTg7XAyR6qh1VtOERT9alF9NezAh5xYA5VK5GZd2iIlJMjxqFz6/sU6 yRaw32jopJa3pr/N8MaIYk0VmRyrGIDS9ozAZJEw1jJxpE5K+gCOJk1dhCvBNRSqgyrLQ7t0fSdq FT9f4NpbQkN2c/RAPJtMhg8eRp7LJhz5eivh9x+NKJgdZN4pGhCDrM0gebso6Lm+I5ZbOk4KJlgO CAMQ835YenmzOzgo6Bk3B8iM2dPDbRrUvF9a84AzQxb7q3Qn0eV2eyAHT7AWWcIoMkI34CByajY7 bM0YazfOwzquRHuMX1TAM+p5jGMK/tAcv0FFa5Ph7u9W2ksiuPAnDTkYfbaFdlz9cbm+ckt0RSPz n2VsJpay0ITZrelcO2iJjZm9JF0zulwYkkS92rdj6Yrs1n/z5DSf343okP9nBbjHtgzY8CM6cuk7 NuRU7a8yZHGKupVS/miAUGBmNVvhcJ/Abe//a+qSwqSKWqNp0Y1mkvlr9b2L3cUIn9NzB5RfN4ed YjdKF3ad79XKP86Ja40D9+7EA/oOgaOmaD/oTG/0Br7vE9G7OilDGcSi20zr9UKAGuefJngZsABy FsP9oagpFwU69cwmbCg+ssIyv+Lx6Yu6uXK40XgMIdMG9TD9PspFNn0GODXVeyWNlBdkhWxWjb1l j4L6Zw7tdAAmxO1isj+tUH7zj3XR50WhqcwH75GCnoePmVzJIl0zqz33XJ/dXy9kQlZPZRgRKc9t j/wgaINThwuYcPynZs40WYFpRXuMKhXyD1FYtWMVRmwZH9qKqmw1WhE+8roaHhvtj5zBzkX/DOZJ VGIAR3YfY/6eAGn5lVZiF2yhFds2ebKvJYC+2KUrcizEL+fryIkwrm From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Fri, 3 Dec 2021 13:06:53 +0800 X-OQ-MSGID: <20211203050657.72755-1-quinkblack@foxmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/5] avformat/movenc: remove unused argument from get_sample_flags() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Zhao Zhili Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: rYw4iXECZ2/4 --- libavformat/movenc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 38ff90833a..634a829f28 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -4427,7 +4427,7 @@ static int mov_write_mfhd_tag(AVIOContext *pb, MOVMuxContext *mov) return 0; } -static uint32_t get_sample_flags(MOVTrack *track, MOVIentry *entry) +static uint32_t get_sample_flags(MOVIentry *entry) { return entry->flags & MOV_SYNC_SAMPLE ? MOV_FRAG_SAMPLE_FLAG_DEPENDS_NO : (MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES | MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC); @@ -4487,7 +4487,7 @@ static int mov_write_tfhd_tag(AVIOContext *pb, MOVMuxContext *mov, /* Set the default flags based on the second sample, if available. * If the first sample is different, that can be signaled via a separate field. */ if (track->entry > 1) - track->default_sample_flags = get_sample_flags(track, &track->cluster[1]); + track->default_sample_flags = get_sample_flags(&track->cluster[1]); else track->default_sample_flags = track->par->codec_type == AVMEDIA_TYPE_VIDEO ? @@ -4512,11 +4512,11 @@ static int mov_write_trun_tag(AVIOContext *pb, MOVMuxContext *mov, flags |= MOV_TRUN_SAMPLE_DURATION; if (track->cluster[i].size != track->default_size) flags |= MOV_TRUN_SAMPLE_SIZE; - if (i > first && get_sample_flags(track, &track->cluster[i]) != track->default_sample_flags) + if (i > first && get_sample_flags(&track->cluster[i]) != track->default_sample_flags) flags |= MOV_TRUN_SAMPLE_FLAGS; } if (!(flags & MOV_TRUN_SAMPLE_FLAGS) && track->entry > 0 && - get_sample_flags(track, &track->cluster[0]) != track->default_sample_flags) + get_sample_flags(&track->cluster[0]) != track->default_sample_flags) flags |= MOV_TRUN_FIRST_SAMPLE_FLAGS; if (track->flags & MOV_TRACK_CTTS) flags |= MOV_TRUN_SAMPLE_CTS; @@ -4538,7 +4538,7 @@ static int mov_write_trun_tag(AVIOContext *pb, MOVMuxContext *mov, avio_wb32(pb, moof_size + 8 + track->data_offset + track->cluster[first].pos); /* data offset */ if (flags & MOV_TRUN_FIRST_SAMPLE_FLAGS) - avio_wb32(pb, get_sample_flags(track, &track->cluster[first])); + avio_wb32(pb, get_sample_flags(&track->cluster[first])); for (i = first; i < end; i++) { if (flags & MOV_TRUN_SAMPLE_DURATION) @@ -4546,7 +4546,7 @@ static int mov_write_trun_tag(AVIOContext *pb, MOVMuxContext *mov, if (flags & MOV_TRUN_SAMPLE_SIZE) avio_wb32(pb, track->cluster[i].size); if (flags & MOV_TRUN_SAMPLE_FLAGS) - avio_wb32(pb, get_sample_flags(track, &track->cluster[i])); + avio_wb32(pb, get_sample_flags(&track->cluster[i])); if (flags & MOV_TRUN_SAMPLE_CTS) avio_wb32(pb, track->cluster[i].cts); } From patchwork Fri Dec 3 05:06:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?emhpbGl6aGFvKOi1teW/l+eriyk=?= X-Patchwork-Id: 31898 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp211364iog; Thu, 2 Dec 2021 21:07:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJzKXArBO5YTS/7Qms7LRWiNPv90U8KKW37YwJWQQEsXnpfJAsHdA9MBRr+I0kX4m1t9iTt3 X-Received: by 2002:a05:6402:d05:: with SMTP id eb5mr24023923edb.360.1638508069736; Thu, 02 Dec 2021 21:07:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638508069; cv=none; d=google.com; s=arc-20160816; b=K8RjbM/CswOFcnc5m+wHaePmOuYEf3kx6gK86gjjWuf4Ik0nAyqq3J6Npv6MB6MuZt VBrD+ftSKLKFDO1sqSzTaZy2gncy8kfuXLYjW+npsX0+4/xXEWq+MTs4at+EkbzMxVrs lDJjLv3bF6dlxPVzsBqkT+b2bpiDk2sLAZHfHQTYQcBvd8Ihaa7BjApFcG9NeKfLuhQ8 ZOCgT1ZLL9smtVYfbXDHk0ZCURrI0pQR4d7HGSCtW7DofOjsma03vSTRySvP4jKNlBJH tyDnynqXb08Dt3CvI9/ZermTOsNjsV6ebvC78bm2T11jf3Hl37KoHwurZ4ZREtIr+/9S g2CQ== 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:date :to:from:message-id:dkim-signature:delivered-to; bh=ez9xElHmnYUnUdL05vJu78U3w13Cgo3Zq/T0JA4T+Qg=; b=RHmggDkcyhZxZ3/QWLMgMUVogop3luHrONV1yjpXILKv8s0L06L2X6lyQIEQFZGzDX 3JWe2RUIjI7oxMSH7rsnN8KY84JUWYhy7+/uxnLi/taZceV57UUX/L389WtapBQ06CtF lsqzLR4z3dBJ9z4csSOohmzDb3N0rXzAhm4BhSJonXV0Z5HZNbNzxJqQjTehYEQ3gg1/ v/5tHKpCh71SgF1tAsNpws5IkZBcBV87J6prSYwweIO/l2Xzr8oP4bK+bk4COXT+X1Gm ApnmzWEvcA55o6Qcwj4X8BEvkU7kVb91lz9909Rx5zURrUHFHVVZ2AuPzaccZ+OD+Dlf MIVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=rf+jCv2H; 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=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ka22si2009058ejb.262.2021.12.02.21.07.48; Thu, 02 Dec 2021 21:07:49 -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=@foxmail.com header.s=s201512 header.b=rf+jCv2H; 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=NONE dis=NONE) header.from=foxmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E92C568AE7A; Fri, 3 Dec 2021 07:07:25 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out203-205-251-80.mail.qq.com (out203-205-251-80.mail.qq.com [203.205.251.80]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 30BAE689988 for ; Fri, 3 Dec 2021 07:07:15 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1638508031; bh=IsF2kkI5hEA0SvCh1URJ954DJ61fKYYFTk/nbwANUBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=rf+jCv2HTWgRc9q1S5xVwf2IrG3FU/hYXTujySSd7GFNSDbUG50AozbihkqRDcL0/ elganW5TO44KzFnQikMd114bB7kSPjQcKpg6HTS9Zu0bsK6yDSF9p+uXnKjAyHc2H5 sFWULSn6gwh0cXClWcc7cY7RJbuyvk3JRmMksITA= Received: from ZHILIZHAO-MB2.tencent.com ([113.108.77.56]) by newxmesmtplogicsvrszb6.qq.com (NewEsmtp) with SMTP id 1C926A18; Fri, 03 Dec 2021 13:07:09 +0800 X-QQ-mid: xmsmtpt1638508030tvv58hlan Message-ID: X-QQ-XMAILINFO: ND3CPZxVFFQcKTep8b4Vb5+B6s6C871vx0sMuZ+mQYXI6l5WNON730d8rmpt0f ML5P4FXjXVgkmHkM5PW5KDYfjhh+DHTAvY22FJksdVXQCdt5u9J/sKhK8XohDcnHO3BqWOWdG/5x V4ReIxVOq7jcTIFyS3E3JhvoZwLtF9uFPdMMEIbSx/s9lCseVWeziJySRaZPDNV9UO+E9jkSw8c1 m1ZfbdJji5JWBZNU/zGmm3tjFr02gAZKHzkNgIfJBOp6TspL5KxLSONCVj3k8vLNOzdb82DjnbKz D2Wt9R3GcSBXrBXs0RwTzOzhQZPPKZgUs3h+cZja5CB61lwbzUsOQti3WCwdiTiNZbQXg9skupef 6I1cJokkPo9TIXpzDxpz7Ukzxj+mWUuHTMZrLc/dwx+zx3f5S6Bm1w2vDZV0/zyH6gnwQTWoP6PS DjwHvqAPKU2kwc+9kNiAStV3QSR+tL07gLdmF02HxfU0W4a7RqDMa++61RlMhysJlGx2gHim7+Ox +oSz/Ka3u2B9a9gcT/GBqQnOYHS/m6PPuwB+Cjt9csa0zBwvoTGtiK8jdp7nKX13pcZRNHmw43ne IeJDAUPV79q6vkijCybcPBvTHkMX/KIXD6ZelyEjGxkc9kCKOFikLXPiL6VaiuLFqDfiDMGlKM/f rnyR4Xcb3InTlxTJXdGirYsFtE6wRdouih8j/10NnG5duYHn8bx+R11dHGb2P7Rl19BMnOlfH4Gd 0pbp+zVyBKFQ9cIXKZL14cQJ/dEk88//cSkeDyA2nVZ5JSDykuPnLvQbBuVL6MUFfkicprzEqG4y vNAR02RlTNsQfsgDrjCzRfJOVvRSGwoYbmXQycnC//fMmilzCJxMKmqSCfpjf4ObA= From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Fri, 3 Dec 2021 13:06:54 +0800 X-OQ-MSGID: <20211203050657.72755-2-quinkblack@foxmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211203050657.72755-1-quinkblack@foxmail.com> References: <20211203050657.72755-1-quinkblack@foxmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/5] avformat/movenc: fix tfra including non-sync entries X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Zhao Zhili Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: unzgS9zhTtnv --- libavformat/movenc.c | 17 ++++++++++++++++- libavformat/movenc.h | 1 + tests/ref/fate/movenc | 4 ++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 634a829f28..06d3819591 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -4650,6 +4650,7 @@ static int mov_add_tfra_entries(AVIOContext *pb, MOVMuxContext *mov, int tracks, info->time = track->cluster[0].dts + track->cluster[0].cts; info->duration = track->end_pts - (track->cluster[0].dts + track->cluster[0].cts); + info->first_sample_flags = track->cluster[0].flags; // If the pts is less than zero, we will have trimmed // away parts of the media track using an edit list, // and the corresponding start presentation time is zero. @@ -4932,8 +4933,20 @@ static int mov_write_moof_tag(AVIOContext *pb, MOVMuxContext *mov, int tracks, static int mov_write_tfra_tag(AVIOContext *pb, MOVTrack *track) { int64_t pos = avio_tell(pb); + int number_of_entry = 0; int i; + /* We can't write and then update number_of_entry, because we cannot fix + * the case when number_of_entry is zero, since zero indicates that every + * sample is a sync sample. So get number_of_entry first. + */ + for (i = 0; i < track->nb_frag_info; i++) { + if (track->frag_info[i].first_sample_flags & MOV_SYNC_SAMPLE) + number_of_entry++; + } + if (!number_of_entry) + return 0; + avio_wb32(pb, 0); /* size placeholder */ ffio_wfourcc(pb, "tfra"); avio_w8(pb, 1); /* version */ @@ -4941,8 +4954,10 @@ static int mov_write_tfra_tag(AVIOContext *pb, MOVTrack *track) avio_wb32(pb, track->track_id); avio_wb32(pb, 0); /* length of traf/trun/sample num */ - avio_wb32(pb, track->nb_frag_info); + avio_wb32(pb, number_of_entry); for (i = 0; i < track->nb_frag_info; i++) { + if (!(track->frag_info[i].first_sample_flags & MOV_SYNC_SAMPLE)) + continue; avio_wb64(pb, track->frag_info[i].time); avio_wb64(pb, track->frag_info[i].offset + track->data_offset); avio_w8(pb, 1); /* traf number */ diff --git a/libavformat/movenc.h b/libavformat/movenc.h index 40077b1afe..f73604d6f3 100644 --- a/libavformat/movenc.h +++ b/libavformat/movenc.h @@ -80,6 +80,7 @@ typedef struct MOVFragmentInfo { int64_t duration; int64_t tfrf_offset; int size; + uint32_t first_sample_flags; } MOVFragmentInfo; typedef struct MOVTrack { diff --git a/tests/ref/fate/movenc b/tests/ref/fate/movenc index 81ea75f372..70c66b7fd7 100644 --- a/tests/ref/fate/movenc +++ b/tests/ref/fate/movenc @@ -138,8 +138,8 @@ write_data len 504, time 800000, type boundary atom moof write_data len 420, time 1266667, type boundary atom moof write_data len 668, time 1566667, type sync atom moof write_data len 440, time 2233333, type boundary atom moof -write_data len 262, time nopts, type trailer atom - -a5d087611a9229ba91eb0964cf2f17d9 4209 vfr-noduration-interleave +write_data len 205, time nopts, type trailer atom - +2dd052ab30624c1a415184c5bf973670 4152 vfr-noduration-interleave write_data len 1231, time nopts, type header atom ftyp write_data len 916, time 0, type sync atom moof write_data len 908, time 1000000, type sync atom moof From patchwork Fri Dec 3 05:06:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?emhpbGl6aGFvKOi1teW/l+eriyk=?= X-Patchwork-Id: 31896 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp211472iog; Thu, 2 Dec 2021 21:08:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOAiTNOue7oR864J4W18rfjhQVOQ01nlkoB/or34vd/nTJX2UlXfmsO/O4Sb4YZcr7Kh16 X-Received: by 2002:a50:fe1a:: with SMTP id f26mr23119079edt.132.1638508080236; Thu, 02 Dec 2021 21:08:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638508080; cv=none; d=google.com; s=arc-20160816; b=wHgGGKytckYsMBYrltS0WvAbBewnGmyozqdaTtPdLEQrt7p+j79nXqSuqvxW1B2vfv j8hKUlACVYpRY/tWRFazuk9dhbMNrlPn+hFZfLpUoJkpcJzQ5HNiYRVyINu+YoLqmD6i vr8BhUSObe3TJsQiDaZaGt0deE9WGX0czp4fyNIV3R7mwZAeergQVK8ywJc+zKDjGOUk iJw9l0HPWU/cWBk26WMssCB+uhVdY1RaiTcOZMb7QP/9XBoyEwCpKLtIGdAcVv4w+tTK HO05IN+wT3QKqiiQ2oR599QgxBlyO+K/QG5o7AXFPBr9BkxdlfojV/F9XKTCqvZ+9fzu SSTg== 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:date :to:from:message-id:dkim-signature:delivered-to; bh=EMyzYJ/vQtnFww4x2naEACQcjh+YB0+y3SONrahWjMw=; b=BVIugVp9QkCqjwuTMOE9xVIQAPelwgybeZkF4yFCNdzMNqDqXE8JIJwypLahDJzLlb C/DO0NT8Y8DKI0VCl387I0K2oAYBvdecqJkCR2wvWsIYo1NKCYaZFEnXVXO6zRTe8GrF QDuoVLDGJZ7HTvpENyqbKL2ZBTHqRahO86EcBnMxkHFz9GNVqtZkW5tI77chqd3kDqGc y3VE8WgwVSn30QfUOTQwcw+I6VnUoQNHl+XcbGzoeyuCjjri+iFkSujd7Ttu+Wr/9lrc midsJjYg1fH8Jusil6OXQdYJZRP0FqcHrlnd2k5L40VJHWThJTHGKUXc2Cyno/fqRnin OuUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=YiKXuIBS; 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=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q8si2143801ejr.568.2021.12.02.21.07.59; Thu, 02 Dec 2021 21:08:00 -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=@foxmail.com header.s=s201512 header.b=YiKXuIBS; 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=NONE dis=NONE) header.from=foxmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DC35268A825; Fri, 3 Dec 2021 07:07:26 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out203-205-251-84.mail.qq.com (unknown [203.205.251.84]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3358D68A825 for ; Fri, 3 Dec 2021 07:07:14 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1638508031; bh=Z8g0rYW3Ky1NrS6abwQArXLSTgjG/2AuKv35EOkKhiY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YiKXuIBS28qgri5xa5TMykKHQxSa2+1sQRzLUQIVKZqEtAe5yIRDn97u1pdLCHxhA kydGSd/gHA40qufJ6d7/uqbTmXkVw0CrSTGkMDzp0KLFM6yZChBqBXEz4G2LOLC1or 1Y0US7nOJ+g92K4CO84Kfzf8f5u6ZtnIUfjROiGg= Received: from ZHILIZHAO-MB2.tencent.com ([113.108.77.56]) by newxmesmtplogicsvrszb6.qq.com (NewEsmtp) with SMTP id 1C926A18; Fri, 03 Dec 2021 13:07:09 +0800 X-QQ-mid: xmsmtpt1638508030txp1p06dw Message-ID: X-QQ-XMAILINFO: NWth7vBa++Gd7vU8ezA7WROoEuZ5ksu5c01RJC1IxzunvSjJbi5mWL4qXnxe+F oz2C9OxLjh7umsP4mWTWaTXUSuS/r7joi6nPkHwkzF8IZ1gRIfj0ucq5JL73MiqWUYNTINFhMqaJ 7F+ny9X4vhdjBcR/B1QfIgB3xHY3udEz8PqFCPbxea0tX3f6o5DlcUmGNr+I01kUHJ9GOecdJNhP OSekngOzwvkn1vmtlzHgL/VUwUuzSahz4yj25KVVVJxiv1ZXptMajnd70SVThhBhI/AH9QrM8tCa 5o+VxsOnmmAadfRM30yi+2FbISk2uAR1chqQJl7FxJcFN4RPzAVE6jjlA+tOEhnYNh3TUIr9n1mX nBV1DnaW3Eslm8wYIYA4E7p64M8XrazM2PqHhWZlQ8X1SZIDxeEIgRy5TBCZRaeTF8Rlv2eXpWgD m6fk2dFK+xhy+vMQ/DbY8dux0re4ql+qyof26K2LGL8C9U7WyoAoW3fE00KQAg1VGIxFIdTWPaX8 qOKXY2vHGnOWta3USCxG5ARYX3Ps6GToejr5qJamcJlHRU4Ddp0ybiahM6ecrptdU3W1j5H2WsW4 O5PwItTU3eWnqaKmUv2wa7pWgDpbXGogJhbNkcJJvR36X7W1N+k9pAf65ih4bnl+sw34PBGNGaZi 92EMDVwy9VB/SSRvdvF0nFRwZbe9vwE8nMyJ0FdE3ZsXvTQReNdh60YtOpVokQqXZHByUmytEChq NVSlMAftkxNspXCCrR3IM7mV94jCVqvUzXBAFFVsQjE+Gj9NVzAtHGNR7gNpt7JPjtnX9AStFFZx 2PoiFpat/EsFw1dB1no/pHcMAL2Ur6ZkVfUG50/SrfwPMxLNbGQE0DF/bODxAKbP5p9a9hFxWN5w == From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Fri, 3 Dec 2021 13:06:55 +0800 X-OQ-MSGID: <20211203050657.72755-3-quinkblack@foxmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211203050657.72755-1-quinkblack@foxmail.com> References: <20211203050657.72755-1-quinkblack@foxmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/5] avformat/movenc: fix traf_number field inside tfra box X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Zhao Zhili Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: qHGv8yYHmXbw traf_number indicates the ‘traf’ number that contains the sync sample. The number ranges from 1 (the first ‘traf’ is numbered 1) in each ‘moof’. For A-V interleaved fmp4 with two traf boxes inside a moof, tfra box was broken. --- libavformat/movenc.c | 4 +++- libavformat/movenc.h | 2 ++ tests/ref/fate/movenc | 28 ++++++++++++++-------------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 06d3819591..f8731d33c5 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -4628,6 +4628,7 @@ static int mov_add_tfra_entries(AVIOContext *pb, MOVMuxContext *mov, int tracks, int size) { int i; + uint32_t index = 0; for (i = 0; i < mov->nb_streams; i++) { MOVTrack *track = &mov->tracks[i]; MOVFragmentInfo *info; @@ -4659,6 +4660,7 @@ static int mov_add_tfra_entries(AVIOContext *pb, MOVMuxContext *mov, int tracks, info->time = 0; } info->tfrf_offset = 0; + info->traf_index = ++index; mov_write_tfrf_tags(pb, mov, track); } return 0; @@ -4960,7 +4962,7 @@ static int mov_write_tfra_tag(AVIOContext *pb, MOVTrack *track) continue; avio_wb64(pb, track->frag_info[i].time); avio_wb64(pb, track->frag_info[i].offset + track->data_offset); - avio_w8(pb, 1); /* traf number */ + avio_w8(pb, track->frag_info[i].traf_index); /* traf number */ avio_w8(pb, 1); /* trun number */ avio_w8(pb, 1); /* sample number */ } diff --git a/libavformat/movenc.h b/libavformat/movenc.h index f73604d6f3..e3a5e2864a 100644 --- a/libavformat/movenc.h +++ b/libavformat/movenc.h @@ -81,6 +81,8 @@ typedef struct MOVFragmentInfo { int64_t tfrf_offset; int size; uint32_t first_sample_flags; + /* ranges from 1 (the first ‘traf’ is numbered 1) in each ‘moof’ */ + uint32_t traf_index; } MOVFragmentInfo; typedef struct MOVTrack { diff --git a/tests/ref/fate/movenc b/tests/ref/fate/movenc index 70c66b7fd7..529a1c6da5 100644 --- a/tests/ref/fate/movenc +++ b/tests/ref/fate/movenc @@ -2,17 +2,17 @@ write_data len 36, time nopts, type header atom ftyp write_data len 2429, time nopts, type header atom - write_data len 788, time 1000000, type sync atom moof write_data len 110, time nopts, type trailer atom - -6f06e338c71468d56580df40ff265066 3363 non-empty-moov +e38b4db4d6542159a18a231df1f8a17a 3363 non-empty-moov write_data len 36, time nopts, type header atom ftyp write_data len 2761, time nopts, type header atom - write_data len 908, time 966667, type sync atom moof write_data len 110, time nopts, type trailer atom - -caf0876986b5f033efc0958c338289cc 3815 non-empty-moov-elst +aced0fb08e209f7b892fc69319de4c6c 3815 non-empty-moov-elst write_data len 36, time nopts, type header atom ftyp write_data len 2669, time nopts, type header atom - write_data len 908, time 1000000, type sync atom moof write_data len 110, time nopts, type trailer atom - -e106084014ed245ed7c4a30f1d11a3ac 3723 non-empty-moov-no-elst +d2879ae4007bec11714c47ed9c4606c9 3723 non-empty-moov-no-elst write_data len 24, time nopts, type header atom ftyp write_data len 1171, time nopts, type header atom - write_data len 728, time 0, type sync atom moof @@ -26,29 +26,29 @@ write_data len 1123, time nopts, type header atom - write_data len 796, time 0, type sync atom moof write_data len 788, time 1000000, type sync atom moof write_data len 148, time nopts, type trailer atom - -08f4b3ad3a3ea224b2ee731476b9056b 2891 empty-moov +7c8bbc289e14ae747ad3f9c73107912b 2891 empty-moov write_data len 36, time nopts, type header atom ftyp write_data len 1123, time nopts, type header atom - write_data len 1068, time 0, type sync atom moof write_data len 908, time 1000000, type sync atom moof write_data len 148, time nopts, type trailer atom - -d7a2dcb43eb0f95f92669f55fc7adeba 3283 empty-moov-no-elst +0c6a543b723d16f5bb2bbb1204625a41 3283 empty-moov-no-elst write_data len 36, time nopts, type header atom ftyp write_data len 1123, time nopts, type header atom - write_data len 900, time -33333, type sync atom moof write_data len 908, time 966667, type sync atom moof write_data len 148, time nopts, type trailer atom - -ea70ca697306976879be408431c27aee 3115 empty-moov-no-elst-no-adjust +f99a6f2437e513d6dcf521f8d167f342 3115 empty-moov-no-elst-no-adjust write_data len 1159, time nopts, type header atom ftyp write_data len 796, time 0, type sync atom moof write_data len 788, time 1000000, type sync atom moof write_data len 148, time nopts, type trailer atom - -08f4b3ad3a3ea224b2ee731476b9056b 2891 delay-moov +7c8bbc289e14ae747ad3f9c73107912b 2891 delay-moov write_data len 1231, time nopts, type header atom ftyp write_data len 916, time -33333, type sync atom moof write_data len 908, time 966667, type sync atom moof write_data len 148, time nopts, type trailer atom - -314cc3b6296f4ee583b328a34be50b2f 3203 delay-moov-elst +a7ddf0bfd32683de9dd22afe3b1135a4 3203 delay-moov-elst write_data len 1195, time nopts, type header atom ftyp write_data len 836, time 0, type sync atom moof write_data len 67, time nopts, type trailer atom - @@ -117,12 +117,12 @@ write_data len 1223, time nopts, type header atom ftyp write_data len 2572, time -333333, type sync atom sidx write_data len 996, time 5166667, type sync atom sidx write_data len 148, time nopts, type trailer atom - -d37a7eda807912b9ed05ccfe003a9e4f 4939 vfr +0009ab3c8ebc80a286e5b10dfacc8ef3 4939 vfr write_data len 1223, time nopts, type header atom ftyp write_data len 2572, time -333333, type sync atom sidx write_data len 996, time 5166667, type sync atom sidx write_data len 148, time nopts, type trailer atom - -d37a7eda807912b9ed05ccfe003a9e4f 4939 vfr-noduration +0009ab3c8ebc80a286e5b10dfacc8ef3 4939 vfr-noduration write_data len 1231, time nopts, type header atom ftyp write_data len 1500, time -333333, type sync atom moof write_data len 1500, time nopts, type unknown atom - @@ -131,7 +131,7 @@ write_data len 1500, time 9666667, type sync atom moof write_data len 1500, time nopts, type unknown atom - write_data len 1004, time nopts, type unknown atom - write_data len 148, time nopts, type trailer atom - -08b6401dc81912e5264245b7233c4ab3 9299 large_frag +9549eeeac8731d820dc395bc73aa605f 9299 large_frag write_data len 1231, time nopts, type header atom ftyp write_data len 684, time -33333, type sync atom moof write_data len 504, time 800000, type boundary atom moof @@ -139,15 +139,15 @@ write_data len 420, time 1266667, type boundary atom moof write_data len 668, time 1566667, type sync atom moof write_data len 440, time 2233333, type boundary atom moof write_data len 205, time nopts, type trailer atom - -2dd052ab30624c1a415184c5bf973670 4152 vfr-noduration-interleave +9ec014d07518b90a5321d792d737bfc0 4152 vfr-noduration-interleave write_data len 1231, time nopts, type header atom ftyp write_data len 916, time 0, type sync atom moof write_data len 908, time 1000000, type sync atom moof write_data len 148, time nopts, type trailer atom - -d81c3a0ce5940a2db74c99ad435e0560 3203 delay-moov-elst-neg-cts +b8076064cedf2fefc242d9af67cdaeba 3203 delay-moov-elst-neg-cts write_data len 36, time nopts, type header atom ftyp write_data len 1123, time nopts, type header atom - write_data len 900, time 0, type sync atom moof write_data len 908, time 1000000, type sync atom moof write_data len 148, time nopts, type trailer atom - -3be575022e446855bca1e45b7942cc0c 3115 empty-moov-neg-cts +c1307485f65c4a00a06ca82f5e0b1361 3115 empty-moov-neg-cts From patchwork Fri Dec 3 05:06:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?emhpbGl6aGFvKOi1teW/l+eriyk=?= X-Patchwork-Id: 31902 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp211098iog; Thu, 2 Dec 2021 21:07:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJxa1M8XK1oPsL3DmIR9jPjekdrjBeD567NkEpsw48P3XSxDSeqdoMYA+57KBFM6UlceFYbY X-Received: by 2002:a17:906:3a4a:: with SMTP id a10mr20466662ejf.253.1638508047855; Thu, 02 Dec 2021 21:07:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638508047; cv=none; d=google.com; s=arc-20160816; b=fa57ZJU6T6XsneZZmqrEow2xTiy41oCoz5sPPtsxixyBJNfO4I2w64CBVrC1nPY3Cn q/M7jijsyCmijFFPmHYJje8ijyGcCq8lAW4+PT6Iejfa8AmACXRU2Bh3xqRteSt/gRcJ gvqyCToqiwCz+JVkza5FTeibvKDx8zDNFWe1AOBhOOGrt3D6Cq5fOeRxNLW4VVTI3658 Gpd/TuqfLVzeqEmvkNw1TdZt4xPOrlF78McFLt4bCS3YZuLWBebnJTguKdEd7b95irrN Wx4uj3+p0py1sgi6Hzx9Ukv5N+J2p+hJvcDt2NTAkvsVTOaTT2CqmVXT1bJ45qZSBO7P 65Gg== 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:date :to:from:message-id:dkim-signature:delivered-to; bh=duUDxYhH4I5ePrHEMczMx9Gw9HeoS0Q4qj1Q4Q7sg6s=; b=VpNcpUAyLpMNg3VCpEBqnN7eSl5C5WuRwXFz2X4kNnQBw2supfPANqTPWsuWDr4nc4 LxFwtw58FtGawOEfvBfMjGpWsZfQrzbrC/yrTiEBg0VYgyhwOGa++JpsSKSAY3M38QcR bZvPBT0cJZrwMXPYzXo3849ju2BAOw03UaKAlWO+ql75foMpZvZzg0oDiaNRxwEPnF/m 46K8ObYydRWaecywsZtwRh4lNEJ7J7dJGFVShCPKkOW1yQta51D9hAf4Qm0qdUaqPJzD 0zPTE5cSQ53bYSmcW4KCneKq+IDyqRPrDwnbTO/U4zzOChY9P6vvmgaLiRJ0DCbQ802o bT7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=Qnh8pwrQ; 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=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id cs15si3357704ejc.331.2021.12.02.21.07.27; Thu, 02 Dec 2021 21:07:27 -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=@foxmail.com header.s=s201512 header.b=Qnh8pwrQ; 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=NONE dis=NONE) header.from=foxmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9667968ADDE; Fri, 3 Dec 2021 07:07:23 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out203-205-221-153.mail.qq.com (out203-205-221-153.mail.qq.com [203.205.221.153]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2D7CF68921B for ; Fri, 3 Dec 2021 07:07:15 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1638508032; bh=nqwdYuDKjtTKGBY3AQjg1y1lqW4MSDKWU34zKqKd+7s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Qnh8pwrQDjpvIoA1wf2xg8IdXwFMPwmSlpVGHOnUi5kQv9QZCIG0HE8Dk0z/DpuQk pKRHLlCZ7+FHWhhZxJ8lF+voTg5BJ+OVLH1vCPUMLvYrxO9XbBi9rzd4Ou/dbZOlop iXNn3811wyMlovYIuYkQwKKXjw8xGwMQlzo8TE1Y= Received: from ZHILIZHAO-MB2.tencent.com ([113.108.77.56]) by newxmesmtplogicsvrszb6.qq.com (NewEsmtp) with SMTP id 1C926A18; Fri, 03 Dec 2021 13:07:09 +0800 X-QQ-mid: xmsmtpt1638508031tmwsxo5m6 Message-ID: X-QQ-XMAILINFO: MSzaE5xMQTbtAE0d2QLiq1sOg3t0/e4h1dcIJ8Zs/U1juEeL46NzokKEqI9xFL 2oUHfgg//RxF+/y4sW+0dt9bK1tvJUGnPU46EfVu3QWEVyZURn0T3aC2EVqvHkqowAObuk71WYCg F828CIOACCr3Bbs5isVm2BR8KeV0/EmqSedIWZYm8olyuzgH3GneEG5zjCLrv0pRMnzQD618noo8 EtUR3NIsbBRe/nOpL9KY2Nn31MCURTaMexHZiIwBHCsk3bq1C7J+xCHFwY9BkZNaMzhkkNq+W3Ed +ksa6gGj79YKk5h5WRw64ORMWRaxQfrYLU/seiFWRxsjKcQrVPrNSJ7ssLAg35IAQ+kfcDD0PQZr 7ie+3VVkAPnk0BN7p//N3AGBBxGTktztC8tqNUynf4xSN6N5HPL3Bw5KgXI3c7TXFa0SWe+2mH76 VoE/6gqb319fpiD46m8ylxLUUb4RAtSKFf1hZQfrnsCkztNBH5tZXlrWzTQ195frUzvVR9KcEx29 fXoTuuke6++2Wua/+/H3ooYC1xGJ3jmtD9s/vUFVrkHpKK6GidhO8tYosWn4OgbgvBMX/Wknl0Zs fpoOz1aRV3AA3/RFxO+cPWgaAnTu4urUqlsSWZAHydWBgJLd8cK5wEFu41z0qLI70JjrwbGD4tVj wNWCI72VDKEwdNnztjX9LHa6F1N9RPIKdXCfjv/Nvd6Bd3NmWnYZKXyNhgBYhjwJ4BYT/XdR1gDf mbJFmooHrQzpuFXVLB+IZ2InPNWWuDmZnFYROctGA2G2jiYE0efx9y49emsQbHe+MKD1x3c276si 2+73lHeE8+5qBU/0NABy4Bvek9Y6UQ2bIhw+qvpB0BgYWTle9VvZx1dne2VPHpAd7a0QYkPBxfVv DtOl1Hg+uN From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Fri, 3 Dec 2021 13:06:56 +0800 X-OQ-MSGID: <20211203050657.72755-4-quinkblack@foxmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211203050657.72755-1-quinkblack@foxmail.com> References: <20211203050657.72755-1-quinkblack@foxmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/5] avformat/movenc: reduce tfra box size when every sample is a sync sample X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Zhao Zhili Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: J/j7UQLrr2j0 --- libavformat/movenc.c | 8 +++++ libavformat/movenc.h | 1 + tests/ref/fate/movenc | 80 +++++++++++++++++++++---------------------- 3 files changed, 49 insertions(+), 40 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index f8731d33c5..01dfd21a43 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -4938,6 +4938,7 @@ static int mov_write_tfra_tag(AVIOContext *pb, MOVTrack *track) int number_of_entry = 0; int i; + if (!track->every_sample_keyframe) { /* We can't write and then update number_of_entry, because we cannot fix * the case when number_of_entry is zero, since zero indicates that every * sample is a sync sample. So get number_of_entry first. @@ -4948,6 +4949,7 @@ static int mov_write_tfra_tag(AVIOContext *pb, MOVTrack *track) } if (!number_of_entry) return 0; + } avio_wb32(pb, 0); /* size placeholder */ ffio_wfourcc(pb, "tfra"); @@ -4956,6 +4958,9 @@ static int mov_write_tfra_tag(AVIOContext *pb, MOVTrack *track) avio_wb32(pb, track->track_id); avio_wb32(pb, 0); /* length of traf/trun/sample num */ + if (track->every_sample_keyframe) { + avio_wb32(pb, 0); + } else { avio_wb32(pb, number_of_entry); for (i = 0; i < track->nb_frag_info; i++) { if (!(track->frag_info[i].first_sample_flags & MOV_SYNC_SAMPLE)) @@ -4966,6 +4971,7 @@ static int mov_write_tfra_tag(AVIOContext *pb, MOVTrack *track) avio_w8(pb, 1); /* trun number */ avio_w8(pb, 1); /* sample number */ } + } return update_size(pb, pos); } @@ -5999,6 +6005,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) trk->cluster[trk->entry].flags |= MOV_DISPOSABLE_SAMPLE; trk->has_disposable++; } + trk->every_sample_keyframe &= !!(pkt->flags & AV_PKT_FLAG_KEY); prft = (AVProducerReferenceTime *)av_packet_get_side_data(pkt, AV_PKT_DATA_PRFT, &prft_size); if (prft && prft_size == sizeof(AVProducerReferenceTime)) @@ -6769,6 +6776,7 @@ static int mov_init(AVFormatContext *s) if (track->language < 0) track->language = 32767; // Unspecified Macintosh language code track->mode = mov->mode; + track->every_sample_keyframe = 1; track->tag = mov_find_codec_tag(s, track); if (!track->tag) { av_log(s, AV_LOG_ERROR, "Could not find tag for codec %s in stream #%d, " diff --git a/libavformat/movenc.h b/libavformat/movenc.h index e3a5e2864a..e78a08c2dd 100644 --- a/libavformat/movenc.h +++ b/libavformat/movenc.h @@ -97,6 +97,7 @@ typedef struct MOVTrack { long chunkCount; int has_keyframes; int has_disposable; + int every_sample_keyframe; #define MOV_TRACK_CTTS 0x0001 #define MOV_TRACK_STPS 0x0002 #define MOV_TRACK_ENABLED 0x0004 diff --git a/tests/ref/fate/movenc b/tests/ref/fate/movenc index 529a1c6da5..3a593dcb9b 100644 --- a/tests/ref/fate/movenc +++ b/tests/ref/fate/movenc @@ -1,54 +1,54 @@ write_data len 36, time nopts, type header atom ftyp write_data len 2429, time nopts, type header atom - write_data len 788, time 1000000, type sync atom moof -write_data len 110, time nopts, type trailer atom - -e38b4db4d6542159a18a231df1f8a17a 3363 non-empty-moov +write_data len 91, time nopts, type trailer atom - +cc672db4650646c640508579e7c08c3a 3344 non-empty-moov write_data len 36, time nopts, type header atom ftyp write_data len 2761, time nopts, type header atom - write_data len 908, time 966667, type sync atom moof -write_data len 110, time nopts, type trailer atom - -aced0fb08e209f7b892fc69319de4c6c 3815 non-empty-moov-elst +write_data len 91, time nopts, type trailer atom - +9f4f458599a3c5e064295d8bede69a5b 3796 non-empty-moov-elst write_data len 36, time nopts, type header atom ftyp write_data len 2669, time nopts, type header atom - write_data len 908, time 1000000, type sync atom moof -write_data len 110, time nopts, type trailer atom - -d2879ae4007bec11714c47ed9c4606c9 3723 non-empty-moov-no-elst +write_data len 91, time nopts, type trailer atom - +eff9b48e62ae0d52676a154328a2db5f 3704 non-empty-moov-no-elst write_data len 24, time nopts, type header atom ftyp write_data len 1171, time nopts, type header atom - write_data len 728, time 0, type sync atom moof write_data len 828, time nopts, type unknown atom - write_data len 728, time 999999, type sync atom moof write_data len 812, time nopts, type unknown atom - -write_data len 148, time nopts, type trailer atom - -92ce825ff40505ec8676191705adb7e7 4439 ismv +write_data len 110, time nopts, type trailer atom - +6e76f6cd18354c43eafbc342a236323f 4401 ismv write_data len 36, time nopts, type header atom ftyp write_data len 1123, time nopts, type header atom - write_data len 796, time 0, type sync atom moof write_data len 788, time 1000000, type sync atom moof -write_data len 148, time nopts, type trailer atom - -7c8bbc289e14ae747ad3f9c73107912b 2891 empty-moov +write_data len 110, time nopts, type trailer atom - +334ccaacc76cfc292fafdf6b0031ba83 2853 empty-moov write_data len 36, time nopts, type header atom ftyp write_data len 1123, time nopts, type header atom - write_data len 1068, time 0, type sync atom moof write_data len 908, time 1000000, type sync atom moof -write_data len 148, time nopts, type trailer atom - -0c6a543b723d16f5bb2bbb1204625a41 3283 empty-moov-no-elst +write_data len 110, time nopts, type trailer atom - +2914a8737c86d5194c655cf540a26ccb 3245 empty-moov-no-elst write_data len 36, time nopts, type header atom ftyp write_data len 1123, time nopts, type header atom - write_data len 900, time -33333, type sync atom moof write_data len 908, time 966667, type sync atom moof -write_data len 148, time nopts, type trailer atom - -f99a6f2437e513d6dcf521f8d167f342 3115 empty-moov-no-elst-no-adjust +write_data len 110, time nopts, type trailer atom - +5919754b902a696df1bbe92afd3eea7d 3077 empty-moov-no-elst-no-adjust write_data len 1159, time nopts, type header atom ftyp write_data len 796, time 0, type sync atom moof write_data len 788, time 1000000, type sync atom moof -write_data len 148, time nopts, type trailer atom - -7c8bbc289e14ae747ad3f9c73107912b 2891 delay-moov +write_data len 110, time nopts, type trailer atom - +334ccaacc76cfc292fafdf6b0031ba83 2853 delay-moov write_data len 1231, time nopts, type header atom ftyp write_data len 916, time -33333, type sync atom moof write_data len 908, time 966667, type sync atom moof -write_data len 148, time nopts, type trailer atom - -a7ddf0bfd32683de9dd22afe3b1135a4 3203 delay-moov-elst +write_data len 110, time nopts, type trailer atom - +d09ca12c5c03fa58d6c5776d25c597b9 3165 delay-moov-elst write_data len 1195, time nopts, type header atom ftyp write_data len 836, time 0, type sync atom moof write_data len 67, time nopts, type trailer atom - @@ -64,65 +64,65 @@ write_data len 1123, time nopts, type header atom - write_data len 796, time 0, type sync atom moof write_data len 788, time 1000000, type sync atom moof 289ee982188d66988a374a462b0b5376 1584 empty-moov-content -write_data len 148, time nopts, type trailer atom - +write_data len 110, time nopts, type trailer atom - write_data len 1159, time nopts, type header atom ftyp 351ae2c8b6d35d98b4848c309cce6704 1159 delay-moov-header write_data len 796, time 0, type sync atom moof write_data len 788, time 1000000, type sync atom moof 289ee982188d66988a374a462b0b5376 1584 delay-moov-content -write_data len 148, time nopts, type trailer atom - +write_data len 110, time nopts, type trailer atom - write_data len 28, time nopts, type header atom - write_data len 1123, time nopts, type header atom - write_data len 884, time 0, type sync atom sidx write_data len 876, time 1000000, type sync atom sidx c0307f99a2a362205b7e3d65b1066f86 876 empty-moov-second-frag -write_data len 148, time nopts, type trailer atom - +write_data len 110, time nopts, type trailer atom - write_data len 28, time nopts, type header atom - write_data len 1123, time nopts, type header atom - write_data len 876, time 1000000, type sync atom sidx c0307f99a2a362205b7e3d65b1066f86 876 empty-moov-second-frag-discont -write_data len 110, time nopts, type trailer atom - +write_data len 91, time nopts, type trailer atom - write_data len 1223, time nopts, type header atom - write_data len 876, time 1000000, type sync atom sidx c0307f99a2a362205b7e3d65b1066f86 876 delay-moov-second-frag-discont -write_data len 110, time nopts, type trailer atom - +write_data len 91, time nopts, type trailer atom - write_data len 1223, time nopts, type header atom ftyp b3811928793ed0749927eb2f7958421c 1223 delay-moov-elst-init write_data len 988, time -33333, type sync atom sidx write_data len 996, time 966667, type sync atom sidx 0df125407c7e81978ce722e0ae4f6f84 996 delay-moov-elst-second-frag -write_data len 148, time nopts, type trailer atom - +write_data len 110, time nopts, type trailer atom - write_data len 1223, time nopts, type header atom ftyp b3811928793ed0749927eb2f7958421c 1223 delay-moov-elst-init-discont write_data len 996, time 966667, type sync atom sidx 0df125407c7e81978ce722e0ae4f6f84 996 delay-moov-elst-second-frag-discont -write_data len 110, time nopts, type trailer atom - +write_data len 91, time nopts, type trailer atom - write_data len 1223, time nopts, type header atom ftyp 041ac8efc35a0d023c26d05eedb20403 1223 delay-moov-elst-signal-init write_data len 1004, time -33333, type sync atom sidx write_data len 996, time 966667, type sync atom sidx 5a583d89318827d2569eecbeaa18c238 996 delay-moov-elst-signal-second-frag -write_data len 148, time nopts, type trailer atom - +write_data len 110, time nopts, type trailer atom - write_data len 1223, time nopts, type header atom ftyp 041ac8efc35a0d023c26d05eedb20403 1223 delay-moov-elst-signal-init-discont write_data len 996, time 966667, type sync atom sidx 5a583d89318827d2569eecbeaa18c238 996 delay-moov-elst-signal-second-frag-discont -write_data len 110, time nopts, type trailer atom - +write_data len 91, time nopts, type trailer atom - write_data len 1247, time nopts, type header atom ftyp 80511a51d1ac9cde62337eed7176ae03 1247 delay-moov-elst-signal-init-discont-largets write_data len 996, time 279621233333, type sync atom sidx dc695d65e8a0cdafee28acd8a5ccf81a 996 delay-moov-elst-signal-second-frag-discont-largets -write_data len 110, time nopts, type trailer atom - +write_data len 91, time nopts, type trailer atom - write_data len 1223, time nopts, type header atom ftyp write_data len 2572, time -333333, type sync atom sidx write_data len 996, time 5166667, type sync atom sidx -write_data len 148, time nopts, type trailer atom - -0009ab3c8ebc80a286e5b10dfacc8ef3 4939 vfr +write_data len 110, time nopts, type trailer atom - +a7cf74137808890eef675c2d3d104818 4901 vfr write_data len 1223, time nopts, type header atom ftyp write_data len 2572, time -333333, type sync atom sidx write_data len 996, time 5166667, type sync atom sidx -write_data len 148, time nopts, type trailer atom - -0009ab3c8ebc80a286e5b10dfacc8ef3 4939 vfr-noduration +write_data len 110, time nopts, type trailer atom - +a7cf74137808890eef675c2d3d104818 4901 vfr-noduration write_data len 1231, time nopts, type header atom ftyp write_data len 1500, time -333333, type sync atom moof write_data len 1500, time nopts, type unknown atom - @@ -130,24 +130,24 @@ write_data len 916, time nopts, type unknown atom - write_data len 1500, time 9666667, type sync atom moof write_data len 1500, time nopts, type unknown atom - write_data len 1004, time nopts, type unknown atom - -write_data len 148, time nopts, type trailer atom - -9549eeeac8731d820dc395bc73aa605f 9299 large_frag +write_data len 110, time nopts, type trailer atom - +1d86c7a4ff34ef48b17e0424ef83c60a 9261 large_frag write_data len 1231, time nopts, type header atom ftyp write_data len 684, time -33333, type sync atom moof write_data len 504, time 800000, type boundary atom moof write_data len 420, time 1266667, type boundary atom moof write_data len 668, time 1566667, type sync atom moof write_data len 440, time 2233333, type boundary atom moof -write_data len 205, time nopts, type trailer atom - -9ec014d07518b90a5321d792d737bfc0 4152 vfr-noduration-interleave +write_data len 110, time nopts, type trailer atom - +52fe35e68d8f522f247e9cdfb9677f1a 4057 vfr-noduration-interleave write_data len 1231, time nopts, type header atom ftyp write_data len 916, time 0, type sync atom moof write_data len 908, time 1000000, type sync atom moof -write_data len 148, time nopts, type trailer atom - -b8076064cedf2fefc242d9af67cdaeba 3203 delay-moov-elst-neg-cts +write_data len 110, time nopts, type trailer atom - +efd24aed8e3d17d6ee7ca5e764391c61 3165 delay-moov-elst-neg-cts write_data len 36, time nopts, type header atom ftyp write_data len 1123, time nopts, type header atom - write_data len 900, time 0, type sync atom moof write_data len 908, time 1000000, type sync atom moof -write_data len 148, time nopts, type trailer atom - -c1307485f65c4a00a06ca82f5e0b1361 3115 empty-moov-neg-cts +write_data len 110, time nopts, type trailer atom - +fe10ded5223335608980555f972902cc 3077 empty-moov-neg-cts From patchwork Fri Dec 3 05:06:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?emhpbGl6aGFvKOi1teW/l+eriyk=?= X-Patchwork-Id: 31899 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp211616iog; Thu, 2 Dec 2021 21:08:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJykSj4jDhjp+kR99NY5IOfZye9I/4EMWVNqrWhs7p/x8XUiqQ0D5OwukNRaIGNOsBXgADDR X-Received: by 2002:a17:906:cd18:: with SMTP id oz24mr20729763ejb.166.1638508090999; Thu, 02 Dec 2021 21:08:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638508090; cv=none; d=google.com; s=arc-20160816; b=dD8WtYNEHfGiLhx4EeaOqIakVcvqkUWNhBg7+J+DB8WatP4QakLShPZSdfR/kS82ow aeKAnb5S5AeNME2yYZx7v4Z8YrpYxQQpJ9wzp3qxmqv6HzKjVQ++lYXMFJG1pJpvXTnb 2w5raEO+EmN+LC6STIVMTvYT2rQY5o4nzNUoqCsxGL+zINIiChVEBlJve1/XW4LWxRBO iOIeMQ6WTUv67cnL9O1HpEji3vSxn1jOOVSayB7rpCN+0XNv+uE964hqBcTTfo9ay+vw Zapv12ZK1eAfazp/takpcpd57s9tsTw5VTER+7+SSnwx3JawSSgUdMEJHvo4bztIwv2s IWGQ== 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:date :to:from:message-id:dkim-signature:delivered-to; bh=KgSMgp5XJkehrl2Wb5veYpMlEAIxUIwJ26cygFABmmU=; b=LezzE3VtHdKc13T20V639M9qGoT2JnS8q1h/scZVhx7tzMxevmbfsjUzpJxIkXW++f qBDzn96fWI1/kWJRY/CZi0kGpY2sK0Km0pJqTwS+NuILdxTu8LlITbzK2hTUVLfj/uTQ CQS5jq1ACkLmHse4en+xP9Fh8ktoKyEx9vuxLox0m6JdaWc7/XPfAeat80dMhfMoIV3r t6XO5ZyN/y7SMdH7rbeknS9P9PtxE4/DT4tzskjLzWZRkRCKs4KU3QqPzRqCHpijAWIa gAQFU0uQ6mYL/zT+hbeH/jLcNiZ+bp+xn6ktcGLk3/fdjv+L1GNfhACu7r5l8WT4GTpK RdQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=arZeVJiQ; 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=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id nd17si2330956ejc.722.2021.12.02.21.08.10; Thu, 02 Dec 2021 21:08:10 -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=@foxmail.com header.s=s201512 header.b=arZeVJiQ; 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=NONE dis=NONE) header.from=foxmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D4D8C68AE9D; Fri, 3 Dec 2021 07:07:27 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out203-205-221-239.mail.qq.com (out203-205-221-239.mail.qq.com [203.205.221.239]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4935468ACC3 for ; Fri, 3 Dec 2021 07:07:15 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1638508032; bh=oSRdmobONfEwaJFLwHF+YkRiQd/5J7cyJttI8zFvtXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=arZeVJiQaNU47Aa6svW8ZC2K72Nbew+9GDdpiD4V+kOm97ypW34yS3iaAUJJy8az8 yAOk7wdQqa7Zy3hXwDvWVsRf5fGyoZj7xYOwHq9+rP+74JUKtEbv9fsoraP9/PMbVE SFu5bWuLQ6e+xzq/eLK1lkSRiSFmfnEwV6Ff7cV8= Received: from ZHILIZHAO-MB2.tencent.com ([113.108.77.56]) by newxmesmtplogicsvrszb6.qq.com (NewEsmtp) with SMTP id 1C926A18; Fri, 03 Dec 2021 13:07:09 +0800 X-QQ-mid: xmsmtpt1638508032tocsay95y Message-ID: X-QQ-XMAILINFO: NM+HyBNiu6fqdh7AKW0DEb7gQGE6ROFKR0fLwNKHCuX++26Dg3/GOG5aeV66gH ehvay/SlMwcYwHYv2olKPq/fMibHkfoxeZsayFnpZqbw4NZl8MHbdRhLN3mxskV4SZJ45RMX3McH sn95PZHcNPvB5n0Q2BNXKiIeOe6GPd22qoeawQimd8/Gdmd0DWq9B62kOCOOZu2a43oNJLau72J4 sYxGY3cazsah7n5Sb0XgNw0Mp4fHRU+tOvi84eaFKpMK13t7EU3jWGJjJFlBHVKN5i25HFW+osXe aWMBeSokHSQEeCMzg5DJVA0TMbXx2ZMRessMel9WtLlte3yCgAUZP5RObAyRv/se4kraKKQ3rKoo Mqb9pwEkVx8ULVW8T1hn7w/rukEaAAd6hBr1/bkSLm7e6kEajUAnGOuLUN4G4f1gMMm1mrezGM07 KNtqffi903Wj+uCvnpPZVRrBsKWPCuGsUTZkRVm2UqeNZIZUcKoLIUSzPhqVj5fvscpoOT2XbSkf 3p49BlHupy8b/ZbXkdTw7GD+5+TMhh9C+KbEKtJNa4xA/NkCJO52RIfr1i+CBzmSVk4vkzhP08CA N46TrReH5TO86Mn9TzvOSsH9SL/GbfqBkHh1ebeknrmKS2veN01+PRoj0/rPpRvh5Vd3nPPrWZAK lF20Ro9M+G3n50rKTjR8Pd1vjvQxPJeUhcZCDkpPZZGx+IJM9meOvkJjaB2XVGlml/LfpYQolofz Fk6Rsqr1O6ib/3KnNmD5JuP3R4FCY06GkCt0PmjjIcEUslnlI2YY4VXAhImJF+Jwy02IFGRmoswZ jQ9GCld1n+tVCki0sBILyRgcd4FJ2ijoZ5EDtVxNj1h1ce8b/P0hd1aaPm/8dZdkQ= From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Fri, 3 Dec 2021 13:06:57 +0800 X-OQ-MSGID: <20211203050657.72755-5-quinkblack@foxmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211203050657.72755-1-quinkblack@foxmail.com> References: <20211203050657.72755-1-quinkblack@foxmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/5] avformat/movenc: reindent after last commit X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Zhao Zhili Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Ln3viHt6V9J5 --- libavformat/movenc.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 01dfd21a43..3c7c951c7d 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -4939,16 +4939,16 @@ static int mov_write_tfra_tag(AVIOContext *pb, MOVTrack *track) int i; if (!track->every_sample_keyframe) { - /* We can't write and then update number_of_entry, because we cannot fix - * the case when number_of_entry is zero, since zero indicates that every - * sample is a sync sample. So get number_of_entry first. - */ - for (i = 0; i < track->nb_frag_info; i++) { - if (track->frag_info[i].first_sample_flags & MOV_SYNC_SAMPLE) - number_of_entry++; - } - if (!number_of_entry) - return 0; + /* We can't write and then update number_of_entry, because we cannot fix + * the case when number_of_entry is zero, since zero indicates that every + * sample is a sync sample. So get number_of_entry first. + */ + for (i = 0; i < track->nb_frag_info; i++) { + if (track->frag_info[i].first_sample_flags & MOV_SYNC_SAMPLE) + number_of_entry++; + } + if (!number_of_entry) + return 0; } avio_wb32(pb, 0); /* size placeholder */ @@ -4959,18 +4959,18 @@ static int mov_write_tfra_tag(AVIOContext *pb, MOVTrack *track) avio_wb32(pb, track->track_id); avio_wb32(pb, 0); /* length of traf/trun/sample num */ if (track->every_sample_keyframe) { - avio_wb32(pb, 0); + avio_wb32(pb, 0); } else { - avio_wb32(pb, number_of_entry); - for (i = 0; i < track->nb_frag_info; i++) { - if (!(track->frag_info[i].first_sample_flags & MOV_SYNC_SAMPLE)) - continue; - avio_wb64(pb, track->frag_info[i].time); - avio_wb64(pb, track->frag_info[i].offset + track->data_offset); - avio_w8(pb, track->frag_info[i].traf_index); /* traf number */ - avio_w8(pb, 1); /* trun number */ - avio_w8(pb, 1); /* sample number */ - } + avio_wb32(pb, number_of_entry); + for (i = 0; i < track->nb_frag_info; i++) { + if (!(track->frag_info[i].first_sample_flags & MOV_SYNC_SAMPLE)) + continue; + avio_wb64(pb, track->frag_info[i].time); + avio_wb64(pb, track->frag_info[i].offset + track->data_offset); + avio_w8(pb, track->frag_info[i].traf_index); /* traf number */ + avio_w8(pb, 1); /* trun number */ + avio_w8(pb, 1); /* sample number */ + } } return update_size(pb, pos);