From patchwork Fri Jun 2 07:39:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dai, Jianhui J" X-Patchwork-Id: 41948 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c51c:b0:10c:5e6f:955f with SMTP id gm28csp1040821pzb; Fri, 2 Jun 2023 00:40:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7tuvJCoxdAOmnlUcYCx++AMCJX7TPj0J6PByCAvKAGyE6Q4nMqhgvz/SoDWo6NhMSwHDMP X-Received: by 2002:a17:907:9415:b0:974:527c:b79c with SMTP id dk21-20020a170907941500b00974527cb79cmr2472415ejc.39.1685691636974; Fri, 02 Jun 2023 00:40:36 -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 b11-20020aa7df8b000000b00514b8791a4esi444276edy.590.2023.06.02.00.40.36; Fri, 02 Jun 2023 00:40:36 -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=@intel.com header.s=Intel header.b=DvHEQtOR; arc=fail (body hash mismatch); 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C3BCA68C30D; Fri, 2 Jun 2023 10:40:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B3EC968C2FE for ; Fri, 2 Jun 2023 10:40:26 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685691632; x=1717227632; h=from:to:subject:date:message-id: content-transfer-encoding:mime-version; bh=26jTb0g9m47hmFA2LB8UovQCQaGjWS8s9fLkHtt+zRU=; b=DvHEQtORkufLPJiTaO0N7yfm1QssR+p6nrTplczaz3jOf32Jg7cSWsPI nn53iDOvQVlGR3XzT2bbDACi3nt5iG8tPj7Dovxpkr19ArOb+jDLAIcOc 2goYS8hVO2ugLdaXK3MU7ZRQdrOr6h/ftbK591AaJqyVnNFKak+vPOUVT Zw/n+XgOwzE+0fMw9ayhTQwhaFedXubjZTQN708FT23ZzS789p1aaIEM1 Q25bmFWVW5FZJaCoz7Kjf7VO+gVfF3xqgjf6QGYRZj7BaxcXKLjmG/mR8 6gC6y4hJdDxCOIGXGKefDuPmERawuSeG0ebv9sMuMIRVo4p/86dT0Rv3U g==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="340431359" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="340431359" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 00:40:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="707747531" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="707747531" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga002.jf.intel.com with ESMTP; 02 Jun 2023 00:39:07 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 2 Jun 2023 00:39:06 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Fri, 2 Jun 2023 00:39:06 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.108) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Fri, 2 Jun 2023 00:39:06 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cpPr3a0Ie2jg2LHy8Ip36SbMSomO0OUVSkvOVRZRVm812ebQAXSzReHXclFsczDiP5W0c5M7h8HyFxDdgh3YgxNvMnFc/bYVS9fkq9gwoeiWjagBE0g1H+CM3VZxRq4w8/RtBQZtQIIObN+xcqz9JLCVjWQ5L8lMHnA5a6LDVSvXC1j+IhQN7OgEJfgeZbgom4gHxs2StRQ9RvYMrBGQ89TLartmgRWSNxUfsgd/tVM2pNDvuWQH6UTDY0P1DTIc6lvsLh9IVhGEAtp3/y4g7noaJAsrfvwUCY9KMOsWbPCSLE8rrKOubA15FadjZlpO+HTaD3LaazRor5xPzxnEEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mygrai/w+FQ6KHu5hBkLMO0dRSqBmAmKfK5TTRnuhl0=; b=E9gxOu3QkXMqEdbiZpWst2rFAOLrBWyjOryI8G14dS/FuzWabQrE+FcQhmwXiCFDNIS/23CNaOAzrVJ66OZYketo9gZ6DBdcjVmt5nV+eOsOGN6x0/ggC5Oz5as3aLkLpa7ZP6+VRa1Yv1VLeMc4HIrW2dVl4yQh+i0yHfAyirtXYLMD8K4o9rZCOmp8PVXQrmkOhUvUxnvqzNsruIdTwnsKEiSSuiZqmCvIVdGQ0BgWf70tAqLpQYFHPBPsa+sNPZCPfovDaRMuhTwFQZkNuHS+eM7rEu2NPa6hXMhkhebaHt56JmBhSR8QbFoMCHmKMk3T0wqiuWc1L3mu8VzBSw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from DM6PR11MB2681.namprd11.prod.outlook.com (2603:10b6:5:bd::33) by DM4PR11MB5970.namprd11.prod.outlook.com (2603:10b6:8:5d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.23; Fri, 2 Jun 2023 07:39:04 +0000 Received: from DM6PR11MB2681.namprd11.prod.outlook.com ([fe80::534e:f5e7:4c88:ba3b]) by DM6PR11MB2681.namprd11.prod.outlook.com ([fe80::534e:f5e7:4c88:ba3b%6]) with mapi id 15.20.6455.025; Fri, 2 Jun 2023 07:39:04 +0000 From: "Dai, Jianhui J" To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH v1] avformat/ivfenc: Set the "number of frames" in IVF header Thread-Index: AdmVIhp9Ix79HF5ZSy+ovww/5TleBw== Date: Fri, 2 Jun 2023 07:39:03 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DM6PR11MB2681:EE_|DM4PR11MB5970:EE_ x-ms-office365-filtering-correlation-id: 10a75ae6-e5a8-4e85-ee19-08db633c7091 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Ilbl9YFSefIGVm059FBjDuN9p4kKMAdHoybr5GgVVixBIRaSE2dghmtMcnekux+C/gJGFKEleLCvg0aYqPWhb0r3pm5ATC6GS/awQQdWkCg3L/UVEhffpE61kfpmt0zOyh9q5rka7PofO8ZydtVA5fKI1h2s770gauuSHoKqu5K6/E5Zvk11rOrJoBF8U+snW35/vyQC/nrzhsejcON785yIbxr9XiforzCGZAePLKAK4ovW+8gkfpaO/m5+uzRcmDrP1bU9epl/auF4PZDXh7LHCI4JrujRhxHc/aT2E4wXn3Y+ONO+bCBAX+WI+lZJP6iFNSxmZnR58bFm+2/m99JJdBPkGsj5OYSNFRs97B23HD25/q2/jxx/GAFE0xK9KYUpVLRpkfydEVX8QMgZnKL9He4RDob9NCpKpXm6kjYFfV4g2A4uwMgBS690Kv7euJicdKFhfhGy+0qT6elUkgBK5el6ovrR+OGMMT5wblfvP8WBqJM/iTJS8378qlMvqa3HqvgXj3Z/X9+HsTf2yzysgENHRgIjyeXF2xoBJftmAs2oFtXchIT1y9WGpGScCGL71Yjt8BIK74WIEk6AmGdQBloFKlOQfdwHu755Z+I= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR11MB2681.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(366004)(376002)(39860400002)(136003)(346002)(396003)(451199021)(55016003)(83380400001)(66556008)(5660300002)(52536014)(8676002)(8936002)(26005)(6506007)(9686003)(86362001)(38070700005)(2906002)(66946007)(7696005)(478600001)(71200400001)(966005)(316002)(64756008)(6916009)(66446008)(122000001)(41300700001)(38100700002)(82960400001)(66476007)(76116006)(16799955002)(186003)(33656002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: aQED3EMNAC5+kzW6aysdMxKurDsJalm2Y+DuW+8d8k65kHtmnS4bc7k9UrRpuLsBK9uEwJRoq3w7BsILDXP6YFmyAJNs/AT1SxCRaydkqh8ljafDbq8ly5dP95ugmK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ndX29K3y7DNWfC5Frwg3WdNcsFlIpwT3pXlYAY+gt9Wkw6WtTymTMSrf4PoJtPsOIP4LBcXApmq0J9xcxKpEukZptfKy8nKa85xslQ+uoWXUs0wkIcqlQI3LKURXbx/XGD1XdksNve/UfpQ6WSEKSjFPGOTt/KUV8f4fgRyfaAy6toNheu/gYSPPC8pIbeRAvqlIUAPYQr+DKoOeAzaZZmSbNOPCd2uMzIv15YNI0OgbFHSo35kR3zmyOnkuWRZFE/luusJXQ9GIAO7VKPwzxH+LnaDP1COM9o400dTLgqnCH1VoLyY0vPjWvCRxeAAAFu7a0FGkHVEA0ZQetdM/gqhB7jU/s4/3d/CA/xzBy+m0oEEwP5dZ+hiNqHSHUo+Co+JnyJmm5QF1XhD2LF6YkJ9s55yj2P MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB2681.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 10a75ae6-e5a8-4e85-ee19-08db633c7091 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Jun 2023 07:39:04.0459 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 24PjCAhzptumZ58F1RrPsA+34hu46yw5PU4GJDZmswsT3IgEW03o7LTft97o7OaFYZiLjFroicscqWoi2CW1zg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB5970 X-OriginatorOrg: intel.com Subject: [FFmpeg-devel] [PATCH v1] avformat/ivfenc: Set the "number of frames" in IVF header 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: W31fwYyoNNkl Should set "number of frames" to bytes 24-27 of IVF header, not duration. It is described by [1]. Also confirm it by parsing IVF files in [2]. [1] Duck IVF - MultimediaWiki https://wiki.multimedia.cx/index.php/Duck_IVF [2] webm/vp8-test-vectors - Git at Google https://chromium.googlesource.com/webm/vp8-test-vectors Signed-off-by: Jianhui Dai --- libavformat/ivfenc.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/libavformat/ivfenc.c b/libavformat/ivfenc.c index 47b4efbcd1..88399099d4 100644 --- a/libavformat/ivfenc.c +++ b/libavformat/ivfenc.c @@ -72,7 +72,8 @@ static int ivf_write_header(AVFormatContext *s) avio_wl16(pb, par->height); avio_wl32(pb, s->streams[0]->time_base.den); avio_wl32(pb, s->streams[0]->time_base.num); - avio_wl64(pb, 0xFFFFFFFFFFFFFFFFULL); // length is overwritten at the end of muxing + avio_wl32(pb, 0xFFFFFFFF); // "number of frames" is overwritten at the end of muxing + avio_wl32(pb, 0); // unused return 0; } @@ -99,16 +100,12 @@ static int ivf_write_trailer(AVFormatContext *s) AVIOContext *pb = s->pb; IVFEncContext *ctx = s->priv_data; - if ((pb->seekable & AVIO_SEEKABLE_NORMAL) && - (ctx->frame_cnt > 1 || (ctx->frame_cnt == 1 && ctx->last_pkt_duration))) { + // overwrite the "number of frames" + if ((pb->seekable & AVIO_SEEKABLE_NORMAL)) { int64_t end = avio_tell(pb); avio_seek(pb, 24, SEEK_SET); - // overwrite the "length" field (duration) - avio_wl32(pb, ctx->last_pkt_duration ? - ctx->sum_delta_pts + ctx->last_pkt_duration : - ctx->frame_cnt * ctx->sum_delta_pts / (ctx->frame_cnt - 1)); - avio_wl32(pb, 0); // zero out unused bytes + avio_wl32(pb, ctx->frame_cnt); avio_seek(pb, end, SEEK_SET); }