From patchwork Fri Oct 7 09:10:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawid Kozinski X-Patchwork-Id: 38594 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4d9:b0:9c:f4b:4e41 with SMTP id 25csp173215pzd; Fri, 7 Oct 2022 02:11:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7rIhXfcmUAofmxCQWXoTuzwjGvbsuMxcfb70PAF++mJlXpCf4w1nvzeTy5MvvrrQmF9Fr2 X-Received: by 2002:a17:907:7614:b0:78d:10e9:7179 with SMTP id jx20-20020a170907761400b0078d10e97179mr3074746ejc.533.1665133864362; Fri, 07 Oct 2022 02:11:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665133864; cv=none; d=google.com; s=arc-20160816; b=Ee8ImWDnMV4tgp6ZmWDAigkPz+tWabNP6n0uM/+2lcmpH3uZkd3GgxIC4KmSYPdoTn /r3n4HZrSbbsPfkBZY60Ih/94rwLtpuvHabSLnkiB2sZ4wye2bhEiDGFvarqAke19Gz1 JfWX1pwl6xx1IF5fcO/NhUlX6ol9C7fpN8Na1FYPuweNJjGToo41Czp/YhIuIrtZL+Ch zjD2Sfg/hqCIn7tmLydZ4y19yN9vCmeUR8spPo30/bkxRiDfSPsQ13eJLSfmyedfqeE7 HFc/yMKjAohSSVoId4iI1kdyydgsOgNgLKbuoMszSIrzFeB2u+H+CnedRrucpaclftL8 ltMA== 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:references:cms-type:mime-version :message-id:date:to:from:dkim-signature:dkim-filter:delivered-to; bh=X9vuCQ/6PwHE2JJOvwWtXE/IGsqfeg7DrkdNHKW36gs=; b=mH2bNl3gY2UVqdA5xnKfie5cZw6xe5Ch62uEHN0GJnsB5zMB4QcCGdw+9LvpX+mw3b dX8anPtmAlA244v712+9DWV7btQaGKCIFoWwoJlye3LoI3n8Xk9fClfcdLHYxQXtNITW EPigELBthc/r9hqqfvJoj3d3cD6umgIrdIl+Acb+EJvGett8QEf0+F1hzghFUcOS5Kt+ t3ZA9/gIsDruyV+vp4xMCl+EfBNb6GmEQMFv4ED8ZvHiGY0ngHTgLZl/dR6tGQdtlqFy L7ekvuQoEq6E5axaeK44oB7XwC/K3bd7b13eLJ6tptFZML/Q1afKIfhZe/eFRbdyZ93R iw8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=pkHad2jH; 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=samsung.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id sb29-20020a1709076d9d00b00741a18d4a5asi1660801ejc.994.2022.10.07.02.11.03; Fri, 07 Oct 2022 02:11:04 -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=@samsung.com header.s=mail20170921 header.b=pkHad2jH; 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=samsung.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7F9C968BBA1; Fri, 7 Oct 2022 12:10:59 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BA9B868AF9F for ; Fri, 7 Oct 2022 12:10:52 +0300 (EEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20221007091049euoutp018f597d6fe84e2cd2e5bcc76fa5fbbf12~bvmntM4132432224322euoutp01A for ; Fri, 7 Oct 2022 09:10:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20221007091049euoutp018f597d6fe84e2cd2e5bcc76fa5fbbf12~bvmntM4132432224322euoutp01A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1665133849; bh=fRnQXkRSrma+P5AlM3fHcJI9FW1CR2rGE285y5zqZqY=; h=From:To:Cc:Subject:Date:References:From; b=pkHad2jHiQFgqN371dmQIxmvxtZyjktsQTcOChH3fssls4kjrYKWgeBMw8/ZnDV7x gV5VilqjBsfV6qgnIKnuywnEp/fUBmPdKmdjQgvI2zAiWD9OU6nvX0NPk/Ka5Qwf8H 9eMltph5Qyo6tRw+b+/yzmubtscTE2PPhVGMF4mM= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20221007091049eucas1p246b14f2b2d24a384608eed1ba57a626e~bvmneCZUb2445224452eucas1p2m; Fri, 7 Oct 2022 09:10:49 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 80.9D.29727.81DEF336; Fri, 7 Oct 2022 10:10:48 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20221007091048eucas1p237947c66368d790f2f1bffc762f577d7~bvmmoz0m32439924399eucas1p2g; Fri, 7 Oct 2022 09:10:48 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20221007091048eusmtrp2566f4778bb5f018381abe610dd38387f~bvmmoESPx0058000580eusmtrp2D; Fri, 7 Oct 2022 09:10:48 +0000 (GMT) X-AuditID: cbfec7f2-21dff7000001741f-6f-633fed180fd8 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 98.FE.07473.81DEF336; Fri, 7 Oct 2022 10:10:48 +0100 (BST) Received: from AMDN5164.EU.corp.samsungelectronics.net (unknown [106.210.132.171]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20221007091047eusmtip14b4351fd15c10a8f9f2d880aa001f120~bvmmVdN_50438404384eusmtip1U; Fri, 7 Oct 2022 09:10:47 +0000 (GMT) From: Dawid Kozinski To: d.frankiewic@samsung.com, ffmpeg-devel@ffmpeg.org Date: Fri, 7 Oct 2022 11:10:35 +0200 Message-Id: <20221007091035.956-1-d.kozinski@samsung.com> X-Mailer: git-send-email 2.37.3.windows.1 MIME-Version: 1.0 X-Unsent: 1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDIsWRmVeSWpSXmKPExsWy7djPc7oSb+2TDX7vV7H4cu0Ls8XKb79Z LL59OsPswOzxZ9FmFo++LasYA5iiuGxSUnMyy1KL9O0SuDJ+z+5hLfgqXdH7bAJzA+NP0S5G Tg4JAROJjz/ns3QxcnEICaxglDg6oZcZwvnCKNG19gU7hPOZUWLLgwusMC2Np+ZBtSxnlOg4 9heqpZ1J4uPRVywgVWwCuhIvPzxiArFFBEwlTjbvZQOxmQW0Jdbd/Q5mCws4S3Qc2go2lUVA VWJt31ewOK+ApUTH9DvsENs0JSZsmcMEEReUODnzCQtEnFti3axLrBAz5SWat84GO0JC4Ce7 xK4VS6FOdZFo3TYfapCwxKvjW6BsGYn/O+cDDeUAsoslDvU7QJg1Eod+pENUWEu8bTzOCBJm Bjph/S59iLCjxP9lrVCNfBI33gpCHMAnMWnbdGaIMK9ER5sQhKki0dcpBtEoJfF02RxmCNtD 4uL+n2wTGBVnIflqFpJPZiGsXcDIvIpRPLW0ODc9tdgwL7Vcrzgxt7g0L10vOT93EyMwQZz+ d/zTDsa5rz7qHWJk4mA8xCjBwawkwrtzp12yEG9KYmVValF+fFFpTmrxIUZpDhYlcV62GVrJ QgLpiSWp2ampBalFMFkmDk6pBiY28XsHa1Liowyfzt8xb6tZ/EW32nU72mU17id5nnmf5d3z Wia3t3/xDvbJ1TO+N99YfTD5RvMN5+krXQ/c+XB7hvWv1skeO+0nLrWSUzCVdT06VXC5lIrS pL3RCyV3Wifbq7ks1Tviz+S5QOvhjfxrKitvz49QD5y+UTyy332275/L9yw8TKIef/k0v+jo pRtTDgarHeB9Ejs/YcKtRd3+D2Kenb4TEbk2areu3sWsvLDMDUetN+wu3lH1t072/uL/Aq+f aHT2XQmbc+Fs+q0sm2MSnqlsM12umk8I42R1rL76wVrLabXwkjlHDLoVLt/60n35cWVdixNP ye2oTSzMaQE6zhNWtl30i/lZVFysxFKckWioxVxUnAgAlGKJgn8DAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrILMWRmVeSWpSXmKPExsVy+t/xu7oSb+2TDQ4e4bb4cu0Ls8XKb79Z LL59OsPswOzxZ9FmFo++LasYA5ii9GyK8ktLUhUy8otLbJWiDS2M9AwtLfSMTCz1DI3NY62M TJX07WxSUnMyy1KL9O0S9DJ+z+5hLfgqXdH7bAJzA+NP0S5GTg4JAROJxlPzWEBsIYGljBKv 21kh4lISS5cuYoSwhSX+XOti62LkAqppZZJoWnOFHSTBJqAr8fLDIyYQW0TAXOLiultgDcwC 2hLr7n5nA7GFBZwlOg5tBRvKIqAqsbbvK1icV8BSomP6HXaIBZoSE7bMYYKIC0qcnPmEBSLO LbFu1iVWiJnyEs1bZzNPYOSfhaRsFpLUAkamVYwiqaXFuem5xYZ6xYm5xaV56XrJ+bmbGIFh u+3Yz807GOe9+qh3iJGJg/EQowQHs5II786ddslCvCmJlVWpRfnxRaU5qcWHGE2Bbp3ILCWa nA+MnLySeEMzA1NDEzNLA1NLM2MlcV7Pgo5EIYH0xJLU7NTUgtQimD4mDk6pBqbqRT8WTVE0 LmgzKrj+9NNc1uKWxaETqiJlZ9wNuSYeN/dcn8e1RBU/69NHju6+l/Ff5f5axY9n8rb2uyxd euR4s2u95FrzidZr3tVv+LHshlukw5PY45b+4aw5/7588lt2cRK3suoV7VO1P0zljx3zEe8z YZ0kzaCuzmP1lstaYdeZbSu8Go+4bT1z5LxBrUHjxOr2Pd1lvon8jE+3nurf96/QkSW+SvEU yyWVkAmHmLQuPrxsuWzO57r8iy+1o58ccghYa8gruLhPWcaXQyxym+nfqL/fw6Pvv9G7FeYm mC4glCR5/ZipmmC+QLbb3e6p0Tu+y/oH3cnw/Xn5Svp+42DNcwFMs6Z2yZ/tP6zEUpyRaKjF XFScCADZDcUn5AIAAA== X-CMS-MailID: 20221007091048eucas1p237947c66368d790f2f1bffc762f577d7 X-Msg-Generator: CA X-RootMTR: 20221007091048eucas1p237947c66368d790f2f1bffc762f577d7 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20221007091048eucas1p237947c66368d790f2f1bffc762f577d7 References: Subject: [FFmpeg-devel] [PATCH v13 1/9] avcodec/evc: MPEG-5 EVC codec registration 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: Dawid Kozinski Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: bUI2yMLAw23Q Added prerequisites that must be met before providing support for the MPEG-5 EVC codec - Added new entry to codec IDs list - Added new entry to the codec descriptor list - Bumped libavcodec minor version - Added profiles for EVC codec Signed-off-by: Dawid Kozinski --- libavcodec/avcodec.h | 3 +++ libavcodec/codec_desc.c | 8 ++++++++ libavcodec/codec_id.h | 1 + libavcodec/profiles.c | 6 ++++++ libavcodec/profiles.h | 1 + libavcodec/version.h | 2 +- 6 files changed, 20 insertions(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 7365eb5cc0..43f3732b58 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1668,6 +1668,9 @@ typedef struct AVCodecContext { #define FF_PROFILE_KLVA_SYNC 0 #define FF_PROFILE_KLVA_ASYNC 1 +#define FF_PROFILE_EVC_BASELINE 0 +#define FF_PROFILE_EVC_MAIN 1 + /** * level * - encoding: Set by user. diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 93b18f9072..6f745e5499 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -1916,6 +1916,14 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("Media 100i"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, }, + { + .id = AV_CODEC_ID_EVC, + .type = AVMEDIA_TYPE_VIDEO, + .name = "evc", + .long_name = NULL_IF_CONFIG_SMALL("MPEG-5 EVC (Essential Video Coding)"), + .props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_REORDER, + .profiles = NULL_IF_CONFIG_SMALL(ff_evc_profiles), + }, /* various PCM "codecs" */ { diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h index 82874daaa3..84cb9edc0b 100644 --- a/libavcodec/codec_id.h +++ b/libavcodec/codec_id.h @@ -319,6 +319,7 @@ enum AVCodecID { AV_CODEC_ID_RADIANCE_HDR, AV_CODEC_ID_WBMP, AV_CODEC_ID_MEDIA100, + AV_CODEC_ID_EVC, /* various PCM "codecs" */ AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c index 7af7fbeb13..a31244e0db 100644 --- a/libavcodec/profiles.c +++ b/libavcodec/profiles.c @@ -181,4 +181,10 @@ const AVProfile ff_arib_caption_profiles[] = { { FF_PROFILE_UNKNOWN } }; +const AVProfile ff_evc_profiles[] = { + { FF_PROFILE_EVC_BASELINE, "Baseline" }, + { FF_PROFILE_EVC_MAIN, "Main" }, + { FF_PROFILE_UNKNOWN }, +}; + #endif /* !CONFIG_SMALL */ diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h index 41a19aa9ad..cf92b5f126 100644 --- a/libavcodec/profiles.h +++ b/libavcodec/profiles.h @@ -72,5 +72,6 @@ extern const AVProfile ff_sbc_profiles[]; extern const AVProfile ff_prores_profiles[]; extern const AVProfile ff_mjpeg_profiles[]; extern const AVProfile ff_arib_caption_profiles[]; +extern const AVProfile ff_evc_profiles[]; #endif /* AVCODEC_PROFILES_H */ diff --git a/libavcodec/version.h b/libavcodec/version.h index ade18cddcd..f8abc803b6 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 50 +#define LIBAVCODEC_VERSION_MINOR 51 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ From patchwork Fri Oct 7 09:11:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawid Kozinski X-Patchwork-Id: 38595 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4d9:b0:9c:f4b:4e41 with SMTP id 25csp173394pzd; Fri, 7 Oct 2022 02:11:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5S11FGsjdl49IUOfQM1ZuSn+r3be4DXlO/EH/E8uy4mDoa6al+tXPmuRKbKRyk9xqfifvC X-Received: by 2002:a05:6402:2693:b0:450:a807:6c91 with SMTP id w19-20020a056402269300b00450a8076c91mr3654975edd.33.1665133898545; Fri, 07 Oct 2022 02:11:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665133898; cv=none; d=google.com; s=arc-20160816; b=CxEIb/caXcYmAFnWbDE5IFtGL1WwB8nvx/yY7ySvVvJAZM0GJvZkWIbJVBL1AoGaU3 Epv2YcLmxa2hEHOR/xGv8weRBClxuOt/++GNuiWSsWDFpCJTZ8dNFl000u/lGJ9hj0AL 40FCpJHinrHFJRqrciLnD9vAQuYmgCTOZoLSflNJnBMwMV6QSuT/9M7y/TIhcp9kejBF X7aWUGisXmTSGPFKLLKOrkGyvywa5R9Jvb/YHvZdNYgIPa4BfctfPsXCgPdQyoViIwQI 6IPyovAttWoj2iuhRhtRVad+IV4urUj6q2gSgsgawRVhRpgJZx6HQNquJP3K0X+6MH+c HznQ== 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:references:cms-type:mime-version :message-id:date:to:from:dkim-signature:dkim-filter:delivered-to; bh=c8R1y9P7pFkx76APsnQnVe2xiqtGN6ROwoxMp0shTzM=; b=ZpX6KyFN9oS7mQZo93Mu59LtfskrLXRc0Nrx3jCbCIgYgIWqn+TME6uFpsbuUlQWkv xV9IG4TW0V/apmoe8bWZDeHMo9ErTro79pI52x0jrVxk39uCYdZgaG0ks6XmYyYp/qZ4 v8RJVSyJiy/Fo2xPhny2ewBvvyqp+aScQZVq5RaxUCdVV3yXB//nRhtrMCCKNXoubarI H2Qxr06HdaR/poHF3S18P2V7nG3gQNQQWJzfRI5N/uJlqxefxCrcrVSsOjF2mtTuEmRt w60w8hhdjO6EY86cizzWcqnjA6bUrGOgTtMq7/Y1HUxEonSIRe/qBzhEuZCd11UPmS4u xz5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=rvicZCAV; 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=samsung.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id v9-20020a056402348900b004511944f801si1857829edc.270.2022.10.07.02.11.37; Fri, 07 Oct 2022 02:11:38 -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=@samsung.com header.s=mail20170921 header.b=rvicZCAV; 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=samsung.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B051668BBB9; Fri, 7 Oct 2022 12:11:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D6E9568A72F for ; Fri, 7 Oct 2022 12:11:28 +0300 (EEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20221007091127euoutp02ef4524ad6fd13f7315c740d6f08d0546~bvnLQitBA2052420524euoutp02J for ; Fri, 7 Oct 2022 09:11:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20221007091127euoutp02ef4524ad6fd13f7315c740d6f08d0546~bvnLQitBA2052420524euoutp02J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1665133887; bh=svp6ybk8L2qfsH5vNFRhd7i/q5hY/VA9HLszC7Dp5DY=; h=From:To:Cc:Subject:Date:References:From; b=rvicZCAVClzqQyx8y+8RmvK+NXGYycgj7m/GA66rspx7rPp+qvHvwxors49vp+Ipp /i3RrjwOJiCYnYww+oxschm4yWOXmXCussSW8jWFIjgP2Bgf1xSa6oPJ3MBdb/XNvb w82DzTBErCVf+GCYz3slT5c8Se8WkcIH6FCEh5Fc= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20221007091127eucas1p148606710e24f9960b38eeb9f5e8c4321~bvnKw641O2034720347eucas1p14; Fri, 7 Oct 2022 09:11:27 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 9B.65.07817.E3DEF336; Fri, 7 Oct 2022 10:11:26 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20221007091126eucas1p16499c4717a1c8dc52e10a58c6f5d67af~bvnKIPEuQ3247532475eucas1p18; Fri, 7 Oct 2022 09:11:26 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20221007091126eusmtrp2e6e2f5bda0505010a69054aef57f3ed9~bvnKHijSl0156801568eusmtrp2d; Fri, 7 Oct 2022 09:11:26 +0000 (GMT) X-AuditID: cbfec7f4-893ff70000011e89-c4-633fed3eb898 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 06.1F.07473.E3DEF336; Fri, 7 Oct 2022 10:11:26 +0100 (BST) Received: from AMDN5164.EU.corp.samsungelectronics.net (unknown [106.210.132.171]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20221007091125eusmtip2c72d4496a69aaf5d545d917d83c5772c~bvnJud9kt2044320443eusmtip2D; Fri, 7 Oct 2022 09:11:25 +0000 (GMT) From: Dawid Kozinski To: d.frankiewic@samsung.com, ffmpeg-devel@ffmpeg.org Date: Fri, 7 Oct 2022 11:11:13 +0200 Message-Id: <20221007091113.27-1-d.kozinski@samsung.com> X-Mailer: git-send-email 2.37.3.windows.1 MIME-Version: 1.0 X-Unsent: 1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrLIsWRmVeSWpSXmKPExsWy7djP87p2b+2TDX5/MLX4cu0Ls8XKb79Z LL59OsPswOzxZ9FmFo++LasYA5iiuGxSUnMyy1KL9O0SuDJOz/jDVnB+ElPFzjvL2RsYrx9g 7GLk5JAQMJG48XgfUxcjF4eQwApGietzz7FBOF8YJf4vXMgC4XxmlFj4+ghcy6PFDxghEssZ JdY8fssK4bQzSdxbcIEdpIpNQFfi5YdHTCC2iICpxMnmvWwgNrOAtsS6u9/BbGGBCInn7/rB 6lkEVCX6ju9jAbF5BSwk3l1/zwyxTVNiwpY5TBBxQYmTM5+wQMS5JdbNusQKMVNeonnrbGaQ IyQEvrJLTJx/FsjhAHJcJPp2qEHUC0u8Or6FHcKWkfi/cz4TREmxxKF+BwizRuLQj3SICmuJ t43HGUHCzEAXrN+lDxF2lNjy/xI7RDWfxI23ghD7+SQmbZsOtZJXoqNNCMJUkejrFINolJJ4 umwO1EceEu29s5kmMCrOQvLULCSPzEJYu4CReRWjeGppcW56arFRXmq5XnFibnFpXrpecn7u JkZgijj97/iXHYzLX33UO8TIxMF4iFGCg1lJhHfnTrtkId6UxMqq1KL8+KLSnNTiQ4zSHCxK 4rxsM7SShQTSE0tSs1NTC1KLYLJMHJxSDUxxS3bJGshukDuoe+v00m0hm/V6Tcq9v5RlKd8W XdUUo71iTm/wpnNpp3on3FA8mbw9dguzmmq0VLPLtobns8vsX0iaVG3mti8qaNQXuGYjOu/1 Hk+xQL7KODH5I3cnH256wNp6Zprf0yj+ys+ecZParZ+7td5/I5R1TGf5eTHuvZXvaps3m+hN kG4/o37b1//2G57OqskPYiYKe0805XpwfaNDkNAMgVnHVQ/qPWHX0Sla1Pp35r+D7e9fXQyt EVWz+K+m79X3M/ovb8r86VlLj0m67+tkZvSfcv7XBEfnpFcanyWFmmy5XrzbJ2fOEn33DZP9 vicuT6avbzjouCiYPUX8o5J0tMcsDs6LyUosxRmJhlrMRcWJAJewSsaAAwAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrCLMWRmVeSWpSXmKPExsVy+t/xe7p2b+2TDfoe81p8ufaF2WLlt98s Ft8+nWF2YPb4s2gzi0ffllWMAUxRejZF+aUlqQoZ+cUltkrRhhZGeoaWFnpGJpZ6hsbmsVZG pkr6djYpqTmZZalF+nYJehmnZ/xhKzg/iali553l7A2M1w8wdjFyckgImEg8WvwAyObiEBJY yihxtX8yE0RCSmLp0kVQRcISf651sUEUtTJJLH/WzAySYBPQlXj54RFYg4iAucTFdbfAGpgF tCXW3f3OBmILC4RJtP+6AlbDIqAq0Xd8HwuIzStgIfHu+ntmiAWaEhO2zGGCiAtKnJz5hAUi zi2xbtYlVoiZ8hLNW2czT2Dkn4WkbBaS1AJGplWMIqmlxbnpucWGesWJucWleel6yfm5mxiB wbvt2M/NOxjnvfqod4iRiYPxEKMEB7OSCO/OnXbJQrwpiZVVqUX58UWlOanFhxhNgW6dyCwl mpwPjJ+8knhDMwNTQxMzSwNTSzNjJXFez4KORCGB9MSS1OzU1ILUIpg+Jg5OqQYmkSd3onPb a5xS580OU+5YyPZKki15+axHJ2/GmC5+vuyiVN0mhTtRsZ2LBQT5HTN1rBqldynqGomWbeE7 2XL7x+MZXvYMy26Lp01k2Z3Hlxu1oVx8g0y72kG55Bsxk29nRi3siXK+XpGR2OEUenDVopuS PSeXTXV/xmHXH7S+vNmba8fFmhvpATGbt3fJNU+byfW3NctaI8+gKezzLc/KRX8VOrIDP/3c 9Ybjr3lq5bPViU5i0bvnOZ9JSZXz7KjnNa+c2V3UJZ2xTkrcR9+q5M6LGe++HQ69YL9KLL3d xMzv2sutadFCeqLeRuyz157z8Dp6R6fKeenWmz1WvF/lp+1US7Kq3LvDOCXKTImlOCPRUIu5 qDgRAPJpZhbnAgAA X-CMS-MailID: 20221007091126eucas1p16499c4717a1c8dc52e10a58c6f5d67af X-Msg-Generator: CA X-RootMTR: 20221007091126eucas1p16499c4717a1c8dc52e10a58c6f5d67af X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20221007091126eucas1p16499c4717a1c8dc52e10a58c6f5d67af References: Subject: [FFmpeg-devel] [PATCH v13 2/9] avcodec/evc_parser: Added parser implementaion for EVC format 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: Dawid Kozinski Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: V9RE6jmwtR8D Signed-off-by: Dawid Kozinski --- libavcodec/Makefile | 1 + libavcodec/evc.h | 155 +++++++++ libavcodec/evc_parser.c | 725 ++++++++++++++++++++++++++++++++++++++++ libavcodec/parsers.c | 1 + 4 files changed, 882 insertions(+) create mode 100644 libavcodec/evc.h create mode 100644 libavcodec/evc_parser.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 592d9347f6..0fdf141d54 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1134,6 +1134,7 @@ OBJS-$(CONFIG_DVAUDIO_PARSER) += dvaudio_parser.o OBJS-$(CONFIG_DVBSUB_PARSER) += dvbsub_parser.o OBJS-$(CONFIG_DVD_NAV_PARSER) += dvd_nav_parser.o OBJS-$(CONFIG_DVDSUB_PARSER) += dvdsub_parser.o +OBJS-$(CONFIG_EVC_PARSER) += evc_parser.o OBJS-$(CONFIG_FLAC_PARSER) += flac_parser.o flacdata.o flac.o OBJS-$(CONFIG_FTR_PARSER) += ftr_parser.o OBJS-$(CONFIG_G723_1_PARSER) += g723_1_parser.o diff --git a/libavcodec/evc.h b/libavcodec/evc.h new file mode 100644 index 0000000000..b3e648796c --- /dev/null +++ b/libavcodec/evc.h @@ -0,0 +1,155 @@ +/* + * EVC definitions and enums + * Copyright (c) 2022 Dawid Kozinski + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_EVC_H +#define AVCODEC_EVC_H + +// The length field that indicates the length in bytes of the following NAL unit is configured to be of 4 bytes +#define EVC_NAL_UNIT_LENGTH_BYTE (4) /* byte */ +#define EVC_NAL_HEADER_SIZE (2) /* byte */ + +/** + * @see ISO_IEC_23094-1_2020, 7.4.2.2 NAL unit header semantic + * Table 4 - NAL unit type codes and NAL unit type classes + */ +enum EVCNALUnitType { + EVC_NOIDR_NUT = 0, /* Coded slice of a non-IDR picture */ + EVC_IDR_NUT = 1, /* Coded slice of an IDR picture */ + EVC_RSV_VCL_NUT02 = 2, + EVC_RSV_VCL_NUT03 = 3, + EVC_RSV_VCL_NUT04 = 4, + EVC_RSV_VCL_NUT05 = 5, + EVC_RSV_VCL_NUT06 = 6, + EVC_RSV_VCL_NUT07 = 7, + EVC_RSV_VCL_NUT08 = 8, + EVC_RSV_VCL_NUT09 = 9, + EVC_RSV_VCL_NUT10 = 10, + EVC_RSV_VCL_NUT11 = 11, + EVC_RSV_VCL_NUT12 = 12, + EVC_RSV_VCL_NUT13 = 13, + EVC_RSV_VCL_NUT14 = 14, + EVC_RSV_VCL_NUT15 = 15, + EVC_RSV_VCL_NUT16 = 16, + EVC_RSV_VCL_NUT17 = 17, + EVC_RSV_VCL_NUT18 = 18, + EVC_RSV_VCL_NUT19 = 19, + EVC_RSV_VCL_NUT20 = 20, + EVC_RSV_VCL_NUT21 = 21, + EVC_RSV_VCL_NUT22 = 22, + EVC_RSV_VCL_NUT23 = 23, + EVC_SPS_NUT = 24, /* Sequence parameter set */ + EVC_PPS_NUT = 25, /* Picture paremeter set */ + EVC_APS_NUT = 26, /* Adaptation parameter set */ + EVC_FD_NUT = 27, /* Filler data */ + EVC_SEI_NUT = 28, /* Supplemental enhancement information */ + EVC_RSV_NONVCL29 = 29, + EVC_RSV_NONVCL30 = 30, + EVC_RSV_NONVCL31 = 31, + EVC_RSV_NONVCL32 = 32, + EVC_RSV_NONVCL33 = 33, + EVC_RSV_NONVCL34 = 34, + EVC_RSV_NONVCL35 = 35, + EVC_RSV_NONVCL36 = 36, + EVC_RSV_NONVCL37 = 37, + EVC_RSV_NONVCL38 = 38, + EVC_RSV_NONVCL39 = 39, + EVC_RSV_NONVCL40 = 40, + EVC_RSV_NONVCL41 = 41, + EVC_RSV_NONVCL42 = 42, + EVC_RSV_NONVCL43 = 43, + EVC_RSV_NONVCL44 = 44, + EVC_RSV_NONVCL45 = 45, + EVC_RSV_NONVCL46 = 46, + EVC_RSV_NONVCL47 = 47, + EVC_RSV_NONVCL48 = 48, + EVC_RSV_NONVCL49 = 49, + EVC_RSV_NONVCL50 = 50, + EVC_RSV_NONVCL51 = 51, + EVC_RSV_NONVCL52 = 52, + EVC_RSV_NONVCL53 = 53, + EVC_RSV_NONVCL54 = 54, + EVC_RSV_NONVCL55 = 55, + EVC_UNSPEC_NUT56 = 56, + EVC_UNSPEC_NUT57 = 57, + EVC_UNSPEC_NUT58 = 58, + EVC_UNSPEC_NUT59 = 59, + EVC_UNSPEC_NUT60 = 60, + EVC_UNSPEC_NUT61 = 61, + EVC_UNSPEC_NUT62 = 62 +}; + +// slice type +// @see ISO_IEC_23094-1_2020 7.4.5 Slice header semantics +// +enum EVCSliceType { + EVC_SLICE_TYPE_B = 0, + EVC_SLICE_TYPE_P = 1, + EVC_SLICE_TYPE_I = 2 +}; + +enum { + // 7.4.3.2: aps_video_parameter_set_id is u(4). + EVC_MAX_APS_COUNT = 32, + + // 7.4.3.1: sps_seq_parameter_set_id is in [0, 15]. + EVC_MAX_SPS_COUNT = 16, + + // 7.4.3.2: pps_pic_parameter_set_id is in [0, 63]. + EVC_MAX_PPS_COUNT = 64, + + // 7.4.5: slice header slice_pic_parameter_set_id in [0, 63] + EVC_MAX_SH_COUNT = 64, + + // E.3.2: cpb_cnt_minus1[i] is in [0, 31]. + EVC_MAX_CPB_CNT = 32, + + // A.4.1: in table A.1 the highest level allows a MaxLumaPs of 35 651 584. + EVC_MAX_LUMA_PS = 35651584, + + EVC_MAX_NUM_REF_PICS = 21, + + EVC_MAX_NUM_RPLS = 32, + + // A.4.1: pic_width_in_luma_samples and pic_height_in_luma_samples are + // constrained to be not greater than sqrt(MaxLumaPs * 8). Hence height/ + // width are bounded above by sqrt(8 * 35651584) = 16888.2 samples. + EVC_MAX_WIDTH = 16888, + EVC_MAX_HEIGHT = 16888, + + // A.4.1: table A.1 allows at most 22 tile rows for any level. + EVC_MAX_TILE_ROWS = 22, + // A.4.1: table A.1 allows at most 20 tile columns for any level. + EVC_MAX_TILE_COLUMNS = 20, + + // A.4.1: table A.1 allows at most 600 slice segments for any level. + EVC_MAX_SLICE_SEGMENTS = 600, + + // 7.4.7.1: in the worst case (tiles_enabled_flag and + // entropy_coding_sync_enabled_flag are both set), entry points can be + // placed at the beginning of every Ctb row in every tile, giving an + // upper bound of (num_tile_columns_minus1 + 1) * PicHeightInCtbsY - 1. + // Only a stream with very high resolution and perverse parameters could + // get near that, though, so set a lower limit here with the maximum + // possible value for 4K video (at most 135 16x16 Ctb rows). + HEVC_MAX_ENTRY_POINT_OFFSETS = EVC_MAX_TILE_COLUMNS * 135, +}; + +#endif // AVCODEC_EVC_H diff --git a/libavcodec/evc_parser.c b/libavcodec/evc_parser.c new file mode 100644 index 0000000000..c4de06f73e --- /dev/null +++ b/libavcodec/evc_parser.c @@ -0,0 +1,725 @@ +/* + * EVC format parser + * + * Copyright (C) 2021 Dawid Kozinski + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include "libavutil/common.h" +#include "parser.h" +#include "golomb.h" +#include "evc.h" + +// rpl structure +typedef struct RefPicListStruct { + int poc; + int tid; + int ref_pic_num; + int ref_pic_active_num; + int ref_pics[EVC_MAX_NUM_REF_PICS]; + char pic_type; + +} RefPicListStruct; + +// The sturcture reflects SPS RBSP(raw byte sequence payload) layout +// @see ISO_IEC_23094-1 section 7.3.2.1 +// +// The following descriptors specify the parsing process of each element +// u(n) - unsigned integer using n bits +// ue(v) - unsigned integer 0-th order Exp_Golomb-coded syntax element with the left bit first +typedef struct EVCParserSPS { + int sps_seq_parameter_set_id; // ue(v) + int profile_idc; // u(8) + int level_idc; // u(8) + int toolset_idc_h; // u(32) + int toolset_idc_l; // u(32) + int chroma_format_idc; // ue(v) + int pic_width_in_luma_samples; // ue(v) + int pic_height_in_luma_samples; // ue(v) + int bit_depth_luma_minus8; // ue(v) + int bit_depth_chroma_minus8; // ue(v) + + int sps_btt_flag; // u(1) + int log2_ctu_size_minus5; // ue(v) + int log2_min_cb_size_minus2; // ue(v) + int log2_diff_ctu_max_14_cb_size; // ue(v) + int log2_diff_ctu_max_tt_cb_size; // ue(v) + int log2_diff_min_cb_min_tt_cb_size_minus2; // ue(v) + + int sps_suco_flag; // u(1) + int log2_diff_ctu_size_max_suco_cb_size; // ue(v) + int log2_diff_max_suco_min_suco_cb_size; // ue(v) + + int sps_admvp_flag; // u(1) + int sps_affine_flag; // u(1) + int sps_amvr_flag; // u(1) + int sps_dmvr_flag; // u(1) + int sps_mmvd_flag; // u(1) + int sps_hmvp_flag; // u(1) + + int sps_eipd_flag; // u(1) + int sps_ibc_flag; // u(1) + int log2_max_ibc_cand_size_minus2; // ue(v) + + int sps_cm_init_flag; // u(1) + int sps_adcc_flag; // u(1) + + int sps_iqt_flag; // u(1) + int sps_ats_flag; // u(1) + + int sps_addb_flag; // u(1) + int sps_alf_flag; // u(1) + int sps_htdf_flag; // u(1) + int sps_rpl_flag; // u(1) + int sps_pocs_flag; // u(1) + int sps_dquant_flag; // u(1) + int sps_dra_flag; // u(1) + + int log2_max_pic_order_cnt_lsb_minus4; // ue(v) + int log2_sub_gop_length; // ue(v) + int log2_ref_pic_gap_length; // ue(v) + + int max_num_tid0_ref_pics; // ue(v) + + int sps_max_dec_pic_buffering_minus1; // ue(v) + int long_term_ref_pic_flag; // u(1) + int rpl1_same_as_rpl0_flag; // u(1) + int num_ref_pic_list_in_sps[2]; // ue(v) + RefPicListStruct rpls[2][EVC_MAX_NUM_RPLS]; + + int picture_cropping_flag; // u(1) + int picture_crop_left_offset; // ue(v) + int picture_crop_right_offset; // ue(v) + int picture_crop_top_offset; // ue(v) + int picture_crop_bottom_offset; // ue(v) + + // @note + // Currently the structure does not reflect the entire SPS RBSP layout. + // It contains only the fields that are necessary to read from the NAL unit all the values + // necessary for the correct initialization of the AVCodecContext structure. + + // @note + // If necessary, add the missing fields to the structure to reflect + // the contents of the entire NAL unit of the SPS type + +} EVCParserSPS; + +typedef struct EVCParserPPS { + int pps_pic_parameter_set_id; // ue(v) + int pps_seq_parameter_set_id; // ue(v) + int num_ref_idx_default_active_minus1[2]; // ue(v) + int additional_lt_poc_lsb_len; // ue(v) + int rpl1_idx_present_flag; // u(1) + int single_tile_in_pic_flag; // u(1) + int num_tile_columns_minus1; // ue(v) + int num_tile_rows_minus1; // ue(v) + int uniform_tile_spacing_flag; // u(1) + int tile_column_width_minus1[EVC_MAX_TILE_ROWS]; // ue(v) + int tile_row_height_minus1[EVC_MAX_TILE_COLUMNS]; // ue(v) + int loop_filter_across_tiles_enabled_flag; // u(1) + int tile_offset_len_minus1; // ue(v) + int tile_id_len_minus1; // ue(v) + int explicit_tile_id_flag; // u(1) + int tile_id_val[EVC_MAX_TILE_ROWS][EVC_MAX_TILE_COLUMNS]; // u(v) + int pic_dra_enabled_flag; // u(1) + int pic_dra_aps_id; // u(5) + int arbitrary_slice_present_flag; // u(1) + int constrained_intra_pred_flag; // u(1) + int cu_qp_delta_enabled_flag; // u(1) + int log2_cu_qp_delta_area_minus6; // ue(v) + +} EVCParserPPS; + +// The sturcture reflects Slice Header RBSP(raw byte sequence payload) layout +// @see ISO_IEC_23094-1 section 7.3.2.6 +// +// The following descriptors specify the parsing process of each element +// u(n) - unsigned integer using n bits +// ue(v) - unsigned integer 0-th order Exp_Golomb-coded syntax element with the left bit first +// u(n) - unsigned integer using n bits. +// When n is "v" in the syntax table, the number of bits varies in a manner dependent on the value of other syntax elements. +typedef struct EVCParserSliceHeader { + int slice_pic_parameter_set_id; // ue(v) + int single_tile_in_slice_flag; // u(1) + int first_tile_id; // u(v) + int arbitrary_slice_flag; // u(1) + int last_tile_id; // u(v) + int num_remaining_tiles_in_slice_minus1; // ue(v) + int delta_tile_id_minus1[EVC_MAX_TILE_ROWS * EVC_MAX_TILE_COLUMNS]; // ue(v) + + int slice_type; // ue(v) + + // @note + // Currently the structure does not reflect the entire Slice Header RBSP layout. + // It contains only the fields that are necessary to read from the NAL unit all the values + // necessary for the correct initialization of the AVCodecContext structure. + + // @note + // If necessary, add the missing fields to the structure to reflect + // the contents of the entire NAL unit of the SPS type + +} EVCParserSliceHeader; + +typedef struct EVCParserContext { + ParseContext pc; + EVCParserSPS sps[EVC_MAX_SPS_COUNT]; + EVCParserPPS pps[EVC_MAX_PPS_COUNT]; + EVCParserSliceHeader slice_header[EVC_MAX_PPS_COUNT]; + int is_avc; + int nal_length_size; + int to_read; + int incomplete_nalu_prefix_read; // The flag is set to 1 when an incomplete NAL unit prefix has been read + +} EVCParserContext; + +static int get_nalu_type(const uint8_t *bits, int bits_size, AVCodecContext *avctx) +{ + int unit_type_plus1 = 0; + + if (bits_size >= EVC_NAL_HEADER_SIZE) { + unsigned char *p = (unsigned char *)bits; + // forbidden_zero_bit + if ((p[0] & 0x80) != 0) + return -1; + + // nal_unit_type + unit_type_plus1 = (p[0] >> 1) & 0x3F; + } + + return unit_type_plus1 - 1; +} + +static uint32_t read_nal_unit_length(const uint8_t *bits, int bits_size, AVCodecContext *avctx) +{ + uint32_t nalu_len = 0; + + if (bits_size >= EVC_NAL_UNIT_LENGTH_BYTE) { + + int t = 0; + unsigned char *p = (unsigned char *)bits; + + for (int i = 0; i < EVC_NAL_UNIT_LENGTH_BYTE; i++) + t = (t << 8) | p[i]; + + nalu_len = t; + if (nalu_len == 0) + return 0; + } + + return nalu_len; +} + +// @see ISO_IEC_23094-1 (7.3.2.1 SPS RBSP syntax) +static EVCParserSPS *parse_sps(const uint8_t *bs, int bs_size, EVCParserContext *ev) +{ + GetBitContext gb; + EVCParserSPS *sps; + int sps_seq_parameter_set_id; + + if (init_get_bits8(&gb, bs, bs_size) < 0) + return NULL; + + sps_seq_parameter_set_id = get_ue_golomb(&gb); + + if (sps_seq_parameter_set_id >= EVC_MAX_SPS_COUNT) + return NULL; + + sps = &ev->sps[sps_seq_parameter_set_id]; + sps->sps_seq_parameter_set_id = sps_seq_parameter_set_id; + + // the Baseline profile is indicated by profile_idc eqal to 0 + // the Main profile is indicated by profile_idc eqal to 1 + sps->profile_idc = get_bits(&gb, 8); + + sps->level_idc = get_bits(&gb, 8); + + skip_bits_long(&gb, 32); /* skip toolset_idc_h */ + skip_bits_long(&gb, 32); /* skip toolset_idc_l */ + + // 0 - monochrome + // 1 - 4:2:0 + // 2 - 4:2:2 + // 3 - 4:4:4 + sps->chroma_format_idc = get_ue_golomb(&gb); + + sps->pic_width_in_luma_samples = get_ue_golomb(&gb); + sps->pic_height_in_luma_samples = get_ue_golomb(&gb); + + sps->bit_depth_luma_minus8 = get_ue_golomb(&gb); + sps->bit_depth_chroma_minus8 = get_ue_golomb(&gb); + + sps->sps_btt_flag = get_bits(&gb, 1); + if (sps->sps_btt_flag) { + sps->log2_ctu_size_minus5 = get_ue_golomb(&gb); + sps->log2_min_cb_size_minus2 = get_ue_golomb(&gb); + sps->log2_diff_ctu_max_14_cb_size = get_ue_golomb(&gb); + sps->log2_diff_ctu_max_tt_cb_size = get_ue_golomb(&gb); + sps->log2_diff_min_cb_min_tt_cb_size_minus2 = get_ue_golomb(&gb); + } + + sps->sps_suco_flag = get_bits(&gb, 1); + if (sps->sps_suco_flag) { + sps->log2_diff_ctu_size_max_suco_cb_size = get_ue_golomb(&gb); + sps->log2_diff_max_suco_min_suco_cb_size = get_ue_golomb(&gb); + } + + sps->sps_admvp_flag = get_bits(&gb, 1); + if (sps->sps_admvp_flag) { + sps->sps_affine_flag = get_bits(&gb, 1); + sps->sps_amvr_flag = get_bits(&gb, 1); + sps->sps_dmvr_flag = get_bits(&gb, 1); + sps->sps_mmvd_flag = get_bits(&gb, 1); + sps->sps_hmvp_flag = get_bits(&gb, 1); + } + + sps->sps_eipd_flag = get_bits(&gb, 1); + if (sps->sps_eipd_flag) { + sps->sps_ibc_flag = get_bits(&gb, 1); + if (sps->sps_ibc_flag) + sps->log2_max_ibc_cand_size_minus2 = get_ue_golomb(&gb); + } + + sps->sps_cm_init_flag = get_bits(&gb, 1); + if (sps->sps_cm_init_flag) + sps->sps_adcc_flag = get_bits(&gb, 1); + + sps->sps_iqt_flag = get_bits(&gb, 1); + if (sps->sps_iqt_flag) + sps->sps_ats_flag = get_bits(&gb, 1); + + sps->sps_addb_flag = get_bits(&gb, 1); + sps->sps_alf_flag = get_bits(&gb, 1); + sps->sps_htdf_flag = get_bits(&gb, 1); + sps->sps_rpl_flag = get_bits(&gb, 1); + sps->sps_pocs_flag = get_bits(&gb, 1); + sps->sps_dquant_flag = get_bits(&gb, 1); + sps->sps_dra_flag = get_bits(&gb, 1); + + if (sps->sps_pocs_flag) + sps->log2_max_pic_order_cnt_lsb_minus4 = get_ue_golomb(&gb); + + if (!sps->sps_pocs_flag || !sps->sps_rpl_flag) { + sps->log2_sub_gop_length = get_ue_golomb(&gb); + if (sps->log2_sub_gop_length == 0) + sps->log2_ref_pic_gap_length = get_ue_golomb(&gb); + } + + // @note + // If necessary, add the missing fields to the EVCParserSPS structure + // and then extend parser implementation + + return sps; +} + +// @see ISO_IEC_23094-1 (7.3.2.2 SPS RBSP syntax) +static EVCParserPPS *parse_pps(const uint8_t *bs, int bs_size, EVCParserContext *ev) +{ + GetBitContext gb; + EVCParserPPS *pps; + + int pps_pic_parameter_set_id; + + if (init_get_bits8(&gb, bs, bs_size) < 0) + return NULL; + + pps_pic_parameter_set_id = get_ue_golomb(&gb); + if (pps_pic_parameter_set_id > EVC_MAX_PPS_COUNT) + return NULL; + + pps = &ev->pps[pps_pic_parameter_set_id]; + + pps->pps_pic_parameter_set_id = pps_pic_parameter_set_id; + + pps->pps_seq_parameter_set_id = get_ue_golomb(&gb); + if (pps->pps_seq_parameter_set_id >= EVC_MAX_SPS_COUNT) + return NULL; + + pps->num_ref_idx_default_active_minus1[0] = get_ue_golomb(&gb); + pps->num_ref_idx_default_active_minus1[1] = get_ue_golomb(&gb); + pps->additional_lt_poc_lsb_len = get_ue_golomb(&gb); + pps->rpl1_idx_present_flag = get_bits(&gb, 1); + pps->single_tile_in_pic_flag = get_bits(&gb, 1); + + if (!pps->single_tile_in_pic_flag) { + pps->num_tile_columns_minus1 = get_ue_golomb(&gb); + pps->num_tile_rows_minus1 = get_ue_golomb(&gb); + pps->uniform_tile_spacing_flag = get_bits(&gb, 1); + + if (!pps->uniform_tile_spacing_flag) { + for (int i = 0; i < pps->num_tile_columns_minus1; i++) + pps->tile_column_width_minus1[i] = get_ue_golomb(&gb); + + for (int i = 0; i < pps->num_tile_rows_minus1; i++) + pps->tile_row_height_minus1[i] = get_ue_golomb(&gb); + } + pps->loop_filter_across_tiles_enabled_flag = get_bits(&gb, 1); + pps->tile_offset_len_minus1 = get_ue_golomb(&gb); + } + + pps->tile_id_len_minus1 = get_ue_golomb(&gb); + pps->explicit_tile_id_flag = get_bits(&gb, 1); + + if (pps->explicit_tile_id_flag) { + for (int i = 0; i <= pps->num_tile_rows_minus1; i++) { + for (int j = 0; j <= pps->num_tile_columns_minus1; j++) + pps->tile_id_val[i][j] = get_bits(&gb, pps->tile_id_len_minus1 + 1); + } + } + + pps->pic_dra_enabled_flag = 0; + pps->pic_dra_enabled_flag = get_bits(&gb, 1); + + if (pps->pic_dra_enabled_flag) + pps->pic_dra_aps_id = get_bits(&gb, 5); + + pps->arbitrary_slice_present_flag = get_bits(&gb, 1); + pps->constrained_intra_pred_flag = get_bits(&gb, 1); + pps->cu_qp_delta_enabled_flag = get_bits(&gb, 1); + + if (pps->cu_qp_delta_enabled_flag) + pps->log2_cu_qp_delta_area_minus6 = get_ue_golomb(&gb); + + return pps; +} + +// @see ISO_IEC_23094-1 (7.3.2.6 Slice layer RBSP syntax) +static EVCParserSliceHeader *parse_slice_header(const uint8_t *bs, int bs_size, EVCParserContext *ev) +{ + GetBitContext gb; + EVCParserSliceHeader *sh; + EVCParserPPS *pps; + int num_tiles_in_slice = 0; + int slice_pic_parameter_set_id; + + if (init_get_bits8(&gb, bs, bs_size) < 0) + return NULL; + + slice_pic_parameter_set_id = get_ue_golomb(&gb); + + if (slice_pic_parameter_set_id < 0 || slice_pic_parameter_set_id >= EVC_MAX_PPS_COUNT) + return NULL; + + sh = &ev->slice_header[slice_pic_parameter_set_id]; + pps = &ev->pps[slice_pic_parameter_set_id]; + + sh->slice_pic_parameter_set_id = slice_pic_parameter_set_id; + + if (!pps->single_tile_in_pic_flag) { + sh->single_tile_in_slice_flag = get_bits(&gb, 1); + sh->first_tile_id = get_bits(&gb, pps->tile_id_len_minus1 + 1); + } else + sh->single_tile_in_slice_flag = 1; + + if (!sh->single_tile_in_slice_flag) { + if (pps->arbitrary_slice_present_flag) + sh->arbitrary_slice_flag = get_bits(&gb, 1); + + if (!sh->arbitrary_slice_flag) + sh->last_tile_id = get_bits(&gb, pps->tile_id_len_minus1 + 1); + else { + sh->num_remaining_tiles_in_slice_minus1 = get_ue_golomb(&gb); + num_tiles_in_slice = sh->num_remaining_tiles_in_slice_minus1 + 2; + for (int i = 0; i < num_tiles_in_slice - 1; ++i) + sh->delta_tile_id_minus1[i] = get_ue_golomb(&gb); + } + } + + sh->slice_type = get_ue_golomb(&gb); + + // @note + // If necessary, add the missing fields to the EVCParserSliceHeader structure + // and then extend parser implementation + + return sh; +} + +static int parse_nal_units(AVCodecParserContext *s, const uint8_t *bs, + int bs_size, AVCodecContext *avctx) +{ + EVCParserContext *ev = s->priv_data; + int nalu_type, nalu_size; + unsigned char *bits = (unsigned char *)bs; + int bits_size = bs_size; + + avctx->codec_id = AV_CODEC_ID_EVC; + s->picture_structure = AV_PICTURE_STRUCTURE_FRAME; + s->key_frame = -1; + + nalu_size = read_nal_unit_length(bits, bits_size, avctx); + if (nalu_size == 0) { + av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit size: (%d)\n", nalu_size); + return -1; + } + + bits += EVC_NAL_UNIT_LENGTH_BYTE; + bits_size -= EVC_NAL_UNIT_LENGTH_BYTE; + + nalu_type = get_nalu_type(bits, bits_size, avctx); + + bits += EVC_NAL_HEADER_SIZE; + bits_size -= EVC_NAL_HEADER_SIZE; + + if (nalu_type == EVC_SPS_NUT) { // NAL Unit type: SPS (Sequence Parameter Set) + EVCParserSPS *sps; + + sps = parse_sps(bits, bits_size, ev); + if (!sps) { + av_log(avctx, AV_LOG_ERROR, "SPS parsing error\n"); + return -1; + } + + s->coded_width = sps->pic_width_in_luma_samples; + s->coded_height = sps->pic_height_in_luma_samples; + s->width = sps->pic_width_in_luma_samples; + s->height = sps->pic_height_in_luma_samples; + + if (sps->profile_idc == 1) avctx->profile = FF_PROFILE_EVC_MAIN; + else avctx->profile = FF_PROFILE_EVC_BASELINE; + + // Currently XEVD decoder supports ony YCBCR420_10LE chroma format for EVC stream + switch (sps->chroma_format_idc) { + case 0: /* YCBCR400_10LE */ + av_log(avctx, AV_LOG_ERROR, "YCBCR400_10LE: Not supported chroma format\n"); + s->format = AV_PIX_FMT_GRAY10LE; + return -1; + case 1: /* YCBCR420_10LE */ + s->format = AV_PIX_FMT_YUV420P10LE; + break; + case 2: /* YCBCR422_10LE */ + av_log(avctx, AV_LOG_ERROR, "YCBCR422_10LE: Not supported chroma format\n"); + s->format = AV_PIX_FMT_YUV422P10LE; + return -1; + case 3: /* YCBCR444_10LE */ + av_log(avctx, AV_LOG_ERROR, "YCBCR444_10LE: Not supported chroma format\n"); + s->format = AV_PIX_FMT_YUV444P10LE; + return -1; + default: + s->format = AV_PIX_FMT_NONE; + av_log(avctx, AV_LOG_ERROR, "Unknown supported chroma format\n"); + return -1; + } + + // @note + // The current implementation of parse_sps function doesn't handle VUI parameters parsing. + // If it will be needed, parse_sps function could be extended to handle VUI parameters parsing + // to initialize fields of the AVCodecContex i.e. color_primaries, color_trc,color_range + + } else if (nalu_type == EVC_PPS_NUT) { // NAL Unit type: PPS (Video Parameter Set) + EVCParserPPS *pps; + + pps = parse_pps(bits, bits_size, ev); + if (!pps) { + av_log(avctx, AV_LOG_ERROR, "PPS parsing error\n"); + return -1; + } + } else if (nalu_type == EVC_SEI_NUT) // NAL unit type: SEI (Supplemental Enhancement Information) + return 0; + else if (nalu_type == EVC_IDR_NUT || nalu_type == EVC_NOIDR_NUT) { // NAL Unit type: Coded slice of a IDR or non-IDR picture + EVCParserSliceHeader *sh; + + sh = parse_slice_header(bits, bits_size, ev); + if (!sh) { + av_log(avctx, AV_LOG_ERROR, "Slice header parsing error\n"); + return -1; + } + switch (sh->slice_type) { + case EVC_SLICE_TYPE_B: { + s->pict_type = AV_PICTURE_TYPE_B; + break; + } + case EVC_SLICE_TYPE_P: { + s->pict_type = AV_PICTURE_TYPE_P; + break; + } + case EVC_SLICE_TYPE_I: { + s->pict_type = AV_PICTURE_TYPE_I; + break; + } + default: { + s->pict_type = AV_PICTURE_TYPE_NONE; + } + } + s->key_frame = (nalu_type == EVC_IDR_NUT) ? 1 : 0; + } else { + av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit type: %d\n", nalu_type); + return -1; + } + + return 0; +} + +/** + * Find the end of the current frame in the bitstream. + * @return the position of the first byte of the next frame, or END_NOT_FOUND + */ +static int evc_find_frame_end(AVCodecParserContext *s, const uint8_t *buf, + int buf_size, AVCodecContext *avctx) +{ + EVCParserContext *ev = s->priv_data; + + if (!ev->to_read) { + int nal_unit_size = 0; + int next = END_NOT_FOUND; + + // This is the case when buffer size is not enough for buffer to store NAL unit length + if (buf_size < EVC_NAL_UNIT_LENGTH_BYTE) { + ev->to_read = EVC_NAL_UNIT_LENGTH_BYTE; + ev->nal_length_size = buf_size; + ev->incomplete_nalu_prefix_read = 1; + + return END_NOT_FOUND; + } + + nal_unit_size = read_nal_unit_length(buf, buf_size, avctx); + ev->nal_length_size = EVC_NAL_UNIT_LENGTH_BYTE; + + next = nal_unit_size + EVC_NAL_UNIT_LENGTH_BYTE; + ev->to_read = next; + if (next < buf_size) + return next; + else + return END_NOT_FOUND; + } else if (ev->to_read > buf_size) + return END_NOT_FOUND; + else { + if (ev->incomplete_nalu_prefix_read == 1) { + EVCParserContext *ev = s->priv_data; + ParseContext *pc = &ev->pc; + uint8_t nalu_len[EVC_NAL_UNIT_LENGTH_BYTE] = {0}; + int nal_unit_size = 0; + + // 1. pc->buffer contains previously read bytes of NALU prefix + // 2. buf contains the rest of NAL unit prefix bytes + // + // ~~~~~~~ + // EXAMPLE + // ~~~~~~~ + // + // In the following example we assumed that the number of already read NAL Unit prefix bytes is equal 1 + // + // ---------- + // pc->buffer -> conatins already read bytes + // ---------- + // __ pc->index == 1 + // | + // V + // ------------------------------------------------------- + // | 0 | 1 | 2 | 3 | 4 | ... | N | + // ------------------------------------------------------- + // | 0x00 | 0xXX | 0xXX | 0xXX | 0xXX | ... | 0xXX | + // ------------------------------------------------------- + // + // ---------- + // buf -> contains newly read bytes + // ---------- + // ------------------------------------------------------- + // | 0 | 1 | 2 | 3 | 4 | ... | N | + // ------------------------------------------------------- + // | 0x00 | 0x00 | 0x3C | 0xXX | 0xXX | ... | 0xXX | + // ------------------------------------------------------- + // + for (int i = 0; i < EVC_NAL_UNIT_LENGTH_BYTE; i++) { + if (i < pc->index) + nalu_len[i] = pc->buffer[i]; + else + nalu_len[i] = buf[i - pc->index]; + } + + // ---------- + // nalu_len + // ---------- + // --------------------------------- + // | 0 | 1 | 2 | 3 | + // --------------------------------- + // | 0x00 | 0x00 | 0x00 | 0x3C | + // --------------------------------- + // | NALU LENGTH | + // --------------------------------- + // NAL Unit lenght = 60 (0x0000003C) + + nal_unit_size = read_nal_unit_length(nalu_len, EVC_NAL_UNIT_LENGTH_BYTE, avctx); + + ev->to_read = nal_unit_size + EVC_NAL_UNIT_LENGTH_BYTE - pc->index; + + ev->incomplete_nalu_prefix_read = 0; + + if (ev->to_read > buf_size) + return END_NOT_FOUND; + else + return ev->to_read; + } + return ev->to_read; + } + + return END_NOT_FOUND; +} + +static int evc_parser_init(AVCodecParserContext *s) +{ + EVCParserContext *ev = s->priv_data; + + ev->nal_length_size = EVC_NAL_UNIT_LENGTH_BYTE; + ev->incomplete_nalu_prefix_read = 0; + + return 0; +} + +static int evc_parse(AVCodecParserContext *s, AVCodecContext *avctx, + const uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size) +{ + int next; + EVCParserContext *ev = s->priv_data; + ParseContext *pc = &ev->pc; + int is_dummy_buf = !buf_size; + const uint8_t *dummy_buf = buf; + + if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) + next = buf_size; + else { + next = evc_find_frame_end(s, buf, buf_size, avctx); + if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { + *poutbuf = NULL; + *poutbuf_size = 0; + ev->to_read -= buf_size; + return buf_size; + } + } + + is_dummy_buf &= (dummy_buf == buf); + + if (!is_dummy_buf) + parse_nal_units(s, buf, buf_size, avctx); + + // poutbuf contains just one NAL unit + *poutbuf = buf; + *poutbuf_size = buf_size; + ev->to_read -= next; + + return next; +} + +const AVCodecParser ff_evc_parser = { + .codec_ids = { AV_CODEC_ID_EVC }, + .priv_data_size = sizeof(EVCParserContext), + .parser_init = evc_parser_init, + .parser_parse = evc_parse, + .parser_close = ff_parse_close, +}; diff --git a/libavcodec/parsers.c b/libavcodec/parsers.c index d355808018..2c077ec3ae 100644 --- a/libavcodec/parsers.c +++ b/libavcodec/parsers.c @@ -41,6 +41,7 @@ extern const AVCodecParser ff_dvaudio_parser; extern const AVCodecParser ff_dvbsub_parser; extern const AVCodecParser ff_dvdsub_parser; extern const AVCodecParser ff_dvd_nav_parser; +extern const AVCodecParser ff_evc_parser; extern const AVCodecParser ff_flac_parser; extern const AVCodecParser ff_ftr_parser; extern const AVCodecParser ff_g723_1_parser; From patchwork Fri Oct 7 09:11:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawid Kozinski X-Patchwork-Id: 38597 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4d9:b0:9c:f4b:4e41 with SMTP id 25csp173506pzd; Fri, 7 Oct 2022 02:12:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Yhkeb/we4ERVVua7jXPpLsTMdnPhj3pdvOTCyCfMazUPOTzMcxKnrmcmHnSioQDb4fdh/ X-Received: by 2002:a05:6402:254b:b0:451:2b1d:d82c with SMTP id l11-20020a056402254b00b004512b1dd82cmr3634037edb.343.1665133923155; Fri, 07 Oct 2022 02:12:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665133923; cv=none; d=google.com; s=arc-20160816; b=Gkfx4KPO3dEnfO/T1xUBvmFWRqNhjHXFveoYuoze7eGXgywubItKs+Cxc8CYcbtKFZ iGzJ8mtiC2SfDaGKj4eqBoA8X/NvONco1DI8QnZGI0iXhsYvWtAwqoAI1qZGrZExgeBK bOF6Np0W+Be6ZF3EdKj0zC28eQmEaceTH2L3/MeWRi27dio0guc1FDWubFxMtsher7XG olJIGz2thbrCu42fpVDmaELaY/6nlACs0M7KdgYw/Nz+w1UrPPJy40CDLe+pyWS0mS6O 6FMJqLEiAFXOAD+xlTd8gSz21w8jVwh8FRmkd2lSrynEa5X9gTQkQ0FxpMEFvc4/kEZ0 /XdA== 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:references:cms-type:mime-version :message-id:date:to:from:dkim-signature:dkim-filter:delivered-to; bh=upEO98NCCsQ7JoO7q9bfBtw2Yu8ZXJUuxeXQn0HF01M=; b=FiokOPgDLEu9Urc6xAEJf7JnQ5BH2b4S4nX9qQ123e3B9IodK5i1izSzvnl7eKHV04 aFK3fv0ZqeF3/HVW6reQzWyvXv7nRDXOJFHFcedrEmPIJ36jnSnbrwv4N8CE1wJYmwOz 5qfREf93iqRXXm3qoPE34VdrDHDkHLk6Eog4iiXzGMiaVfArsy9fHewo/ALAoCUNSBf8 9QfErqKH1Xqik5qhcMTA4PwIMZ3PNls7D/y6Nqt3xZKl6Un0rcy/NO3gpyJ7bwbIF7/j KjLfViZnwgdZJ2y0lhlJ7ovW6SuXnQR2m4PHlbanfjtIB8G8epN1MigwtiFGup2LWm0B JEdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=O0mqOYPZ; 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=samsung.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id em8-20020a056402364800b0043dc00e0740si1625109edb.373.2022.10.07.02.12.02; Fri, 07 Oct 2022 02:12:03 -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=@samsung.com header.s=mail20170921 header.b=O0mqOYPZ; 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=samsung.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B484D68BBBC; Fri, 7 Oct 2022 12:12:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D72CE68BB66 for ; Fri, 7 Oct 2022 12:11:58 +0300 (EEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20221007091157euoutp02ce1293d7fb6fa0598ba57a585ff3586d~bvnnJvrsg2052420524euoutp02h for ; Fri, 7 Oct 2022 09:11:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20221007091157euoutp02ce1293d7fb6fa0598ba57a585ff3586d~bvnnJvrsg2052420524euoutp02h DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1665133917; bh=FGDnwBVi3i00hPQCRfUbBm9BeerQSBQls8aAOxHla1Y=; h=From:To:Cc:Subject:Date:References:From; b=O0mqOYPZRlJOgDhKncgDlxJM1JVKLSynOg0bX6gNIO1l3kUxZVUMtEcwBdpxYYaAk QeuNB5Yf8y87AdZSeYzmP0w/M5gpzLA5SSwd0JsP6WzWo9Ty9f99Z3P7J+K8FFvMnf iL40F/ZpOy/8JOSSQcD8ukELbWf+twM7xTP3aRaA= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20221007091157eucas1p21bdc2a3becde26f25b1043bd3bd35bcf~bvnm4dxgh2441424414eucas1p29; Fri, 7 Oct 2022 09:11:57 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 09.11.19378.D5DEF336; Fri, 7 Oct 2022 10:11:57 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20221007091156eucas1p29357f4a746df6d180e45c49cee995df3~bvnmadTk52246622466eucas1p23; Fri, 7 Oct 2022 09:11:56 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20221007091156eusmtrp2745aad53e96a5368513c889af92cb937~bvnmZ3LK80156801568eusmtrp2b; Fri, 7 Oct 2022 09:11:56 +0000 (GMT) X-AuditID: cbfec7f5-a4dff70000014bb2-8f-633fed5d0f53 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 2B.2F.07473.C5DEF336; Fri, 7 Oct 2022 10:11:56 +0100 (BST) Received: from AMDN5164.EU.corp.samsungelectronics.net (unknown [106.210.132.171]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20221007091156eusmtip2537b97885543be34ce6b79ad3a0eda90~bvnmIXWUn2455424554eusmtip2I; Fri, 7 Oct 2022 09:11:56 +0000 (GMT) From: Dawid Kozinski To: d.frankiewic@samsung.com, ffmpeg-devel@ffmpeg.org Date: Fri, 7 Oct 2022 11:11:46 +0200 Message-Id: <20221007091146.230-1-d.kozinski@samsung.com> X-Mailer: git-send-email 2.37.3.windows.1 MIME-Version: 1.0 X-Unsent: 1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNIsWRmVeSWpSXmKPExsWy7djP87qxb+2TDbaeY7f4cu0Ls8XKb79Z LL59OsPswOzxZ9FmFo++LasYA5iiuGxSUnMyy1KL9O0SuDLOvJ3AVPBKtOLfzPdsDYy/BboY OTkkBEwk9j45xd7FyMUhJLCCUWL2SxCHE8j5wiix9FkdROIzo8S5c1tYYTouNC9igUgsZ5RY s+AXVHs7k8TPec3MIFVsAroSLz88YgKxRQRMJU4272UDsZkFtCXW3f0OZgsL1Eh0vb8CZrMI qEqs6l4KVs8rYCnxZd41dohtmhITtsyBigtKnJz5hAUizi2xbtYlVoiZ8hLNW2czgxwhIfCT XeJX1zVGiCIXiSczDkCdLSzx6vgWqKEyEv93zgcaygFkF0sc6neAMGskDv1Ih6iwlnjbeJwR JMwMdML6XfoQYUeJR78WMUNU80nceCsIcQCfxKRt06HCvBIdbUIQpopEX6cYRKOUxNNlc5gh bA+JlcdvsE1gVJyF5KtZSD6ZhbB2ASPzKkbx1NLi3PTUYuO81HK94sTc4tK8dL3k/NxNjMD0 cPrf8a87GFe8+qh3iJGJg/EQowQHs5II786ddslCvCmJlVWpRfnxRaU5qcWHGKU5WJTEedlm aCULCaQnlqRmp6YWpBbBZJk4OKUamOIXzM7US3zN9mKaDMNx5p8uPMcn95TNfbT6OFdI3uX4 JNayFzcC1pdsf/9vRfIFlQ0ywvft510IC3mTxbQked/ifazmi81X3t23Lj1vQdHcN2uuFIk8 yN9w68fy+F+nHQ8UsO/6KzX77qbmp/W71Ltv63w0Osx4KOx206XU5cXZH3caa9r+1hIxXTqv rcP2LMeVXUFTMsInsTgI2NzJneRd8HZWQ80RlceRBz2OKq8vjs1w/mXBuf/QmtjABeGXy322 v5A+teZ3NPv+uQ8WS4qfOJX0f4lbopxVWKncMm+vL1azniQ99JzaesPfbd7Sr7NFPvwOjA9V kvx/LFshXtJqbs9D5vr5VicnN7fJimkrsRRnJBpqMRcVJwIAzs2lxn4DAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrELMWRmVeSWpSXmKPExsVy+t/xe7oxb+2TDR60a1l8ufaF2WLlt98s Ft8+nWF2YPb4s2gzi0ffllWMAUxRejZF+aUlqQoZ+cUltkrRhhZGeoaWFnpGJpZ6hsbmsVZG pkr6djYpqTmZZalF+nYJehln3k5gKnglWvFv5nu2BsbfAl2MnBwSAiYSF5oXsXQxcnEICSxl lPi56CUjREJKYunSRVC2sMSfa11sEEWtTBIn1j9iAUmwCehKvPzwiAnEFhEwl7i47hZYA7OA tsS6u9/ZQGxhgSqJPd2LmUFsFgFViVXdS8HqeQUsJb7Mu8YOsUBTYsKWOVBxQYmTM5+wQMS5 JdbNusQKMVNeonnrbOYJjPyzkJTNQpJawMi0ilEktbQ4Nz232FCvODG3uDQvXS85P3cTIzBw tx37uXkH47xXH/UOMTJxMB5ilOBgVhLh3bnTLlmINyWxsiq1KD++qDQntfgQoynQrROZpUST 84Gxk1cSb2hmYGpoYmZpYGppZqwkzutZ0JEoJJCeWJKanZpakFoE08fEwSnVwORsnOWucelq reGFz06bbwgmesQLu7DnvPVRT7+sHbc50E/SqNty75p911hZBRdOvVElpH/NmOXqnVrlzoRZ cnV+NtIfNWpZX0+dfuG7sS7Dr9hHdquO3U/+KStuf30Pt+5pv8s2H5fPvhmf5zPPaW34ppgd L+VX1rOW+EldecVj5rPy8Gvhg1ds7gbtis7okb75mudZulaPW4llTmuv9zvO/rmffERmrM6Z 7futJ2P96TOHDFji19zeI73m2uUTGVnzbxVP9nx48M2k7HPP2h/4RnwtFc349WD2rdjCgGtn 214H/3uyJMMjtYNxUnfK5B19/faJWztOvj+spyj50WzyFMu3fOYc5m1s716+P6bEUpyRaKjF XFScCAD8/YM75QIAAA== X-CMS-MailID: 20221007091156eucas1p29357f4a746df6d180e45c49cee995df3 X-Msg-Generator: CA X-RootMTR: 20221007091156eucas1p29357f4a746df6d180e45c49cee995df3 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20221007091156eucas1p29357f4a746df6d180e45c49cee995df3 References: Subject: [FFmpeg-devel] [PATCH v13 3/9] avformat/evc_muxer: Added muxer to handle writing EVC encoded data into file or output bytestream 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: Dawid Kozinski Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: DIJzATZJnM2+ - Provided AVOutputFormat structure describing EVC output format (ff_evc_muxer) - Added documentation for EVC muxer Signed-off-by: Dawid Kozinski --- doc/muxers.texi | 6 ++++++ libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/rawenc.c | 13 +++++++++++++ 4 files changed, 21 insertions(+) diff --git a/doc/muxers.texi b/doc/muxers.texi index b2f4326aae..08ab20c09e 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -2124,6 +2124,12 @@ DTS Coherent Acoustics (DCA) audio. Dolby Digital Plus, also known as Enhanced AC-3, audio. +@subsection evc + +MPEG-5 Essential Video Coding (EVC) / EVC / MPEG-5 Part 1 EVC video. + +Extensions: evc + @subsection g722 ITU-T G.722 audio. diff --git a/libavformat/Makefile b/libavformat/Makefile index d7f198bf39..a14a759c1f 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -251,6 +251,7 @@ OBJS-$(CONFIG_HCOM_DEMUXER) += hcom.o pcm.o OBJS-$(CONFIG_HDS_MUXER) += hdsenc.o OBJS-$(CONFIG_HEVC_DEMUXER) += hevcdec.o rawdec.o OBJS-$(CONFIG_HEVC_MUXER) += rawenc.o +OBJS-$(CONFIG_EVC_MUXER) += rawenc.o OBJS-$(CONFIG_HLS_DEMUXER) += hls.o hls_sample_encryption.o OBJS-$(CONFIG_HLS_MUXER) += hlsenc.o hlsplaylist.o avc.o OBJS-$(CONFIG_HNM_DEMUXER) += hnm.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 47c419a009..615d2bc3b1 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -150,6 +150,7 @@ extern const AVInputFormat ff_ea_cdata_demuxer; extern const AVInputFormat ff_eac3_demuxer; extern const AVOutputFormat ff_eac3_muxer; extern const AVInputFormat ff_epaf_demuxer; +extern const AVOutputFormat ff_evc_muxer; extern const AVOutputFormat ff_f4v_muxer; extern const AVInputFormat ff_ffmetadata_demuxer; extern const AVOutputFormat ff_ffmetadata_muxer; diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c index 267fce252d..b7b2aff453 100644 --- a/libavformat/rawenc.c +++ b/libavformat/rawenc.c @@ -401,6 +401,19 @@ const AVOutputFormat ff_hevc_muxer = { }; #endif +#if CONFIG_EVC_MUXER +AVOutputFormat ff_evc_muxer = { + .name = "evc", + .long_name = NULL_IF_CONFIG_SMALL("raw EVC video"), + .extensions = "evc", + .audio_codec = AV_CODEC_ID_NONE, + .video_codec = AV_CODEC_ID_EVC, + .write_header = force_one_stream, + .write_packet = ff_raw_write_packet, + .flags = AVFMT_NOTIMESTAMPS, +}; +#endif + #if CONFIG_M4V_MUXER const AVOutputFormat ff_m4v_muxer = { .name = "m4v", From patchwork Fri Oct 7 09:12:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawid Kozinski X-Patchwork-Id: 38598 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4d9:b0:9c:f4b:4e41 with SMTP id 25csp173618pzd; Fri, 7 Oct 2022 02:12:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6XHV7V5cTO3xkuc5YWe+dTBeZATnVV3s/luz2qbcgo5xCAQKrZVLHk6mGWShKvr6U1tH11 X-Received: by 2002:a17:906:7945:b0:73b:e605:f31 with SMTP id l5-20020a170906794500b0073be6050f31mr3319225ejo.129.1665133947522; Fri, 07 Oct 2022 02:12:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665133947; cv=none; d=google.com; s=arc-20160816; b=J21BS7Gsu4ImLjaAFAYKNqj/OHhl8JGbZIwUerhR29B86GB+LdHUHP7R00+3CSLTfp Z/LZqWzWARHCQAzqCZYeJIHMnBkm54DO8GXYTbKjfAP5ILnHdhxGBvP8UcZpwZQeZh9O vZyktlRpm1zauzIZeAdlBt799ivHIbtWwDuhXN1+mpv+qwF3YyldeIcEpJ/bi6wPSgnj /e2EeLFO97fGpzRPD8KRTn7nif39h9c844IsUJJDNb3KjOx0y2/2W3wKOiCBmMEY2AP2 ceb+1EKzT3fEzsxVzeqk/CGBEK5hiuIetWU7lNYGSG3mNawPgu+LvuxrzDqPQSCXBFMb TJeQ== 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:references:cms-type:mime-version :message-id:date:to:from:dkim-signature:dkim-filter:delivered-to; bh=I8qOndhlUb/X/aGreetL7TQlY/khVpkdwfGKbetJn2Y=; b=FBFVnshZ05u1q64wS9G7jul4xtQCcdsIyz8kykyFmENGg/2FBkem91DW1DWZbbkeRY T+iPkoiP1K0VUzyF1dVorHmfxM97JSpJvRr9ldqJrXYKbSEJ8b0v5tIFMOsb7jrYbRb1 b8RlSFHeqHETOq0/SA6UUYXZZgzE2FaiocXdb+s298L7aFMpEYaSELji2ShB0HePNBfz FIIoG9aRjRLHuZvMHAixRRGUSkEOzcMHn4HUsadSy/7Tp5QGWcmxQJs4lc9yny+1MImf lOMrtJC12724bNQc11bL2Bi+bGwsM70H7tCAMDkCIGP0M/P+A/rtgUxl5u9gbhonZMRK usuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=U3e2s4ON; 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=samsung.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id f13-20020a056402354d00b0045915120659si1930203edd.284.2022.10.07.02.12.26; Fri, 07 Oct 2022 02:12:27 -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=@samsung.com header.s=mail20170921 header.b=U3e2s4ON; 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=samsung.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E1D8768A72F; Fri, 7 Oct 2022 12:12:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7282A68A72F for ; Fri, 7 Oct 2022 12:12:23 +0300 (EEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20221007091222euoutp0101d7e8e5def78532fe0b12e34ae76fd4~bvn_xGody2797127971euoutp01w for ; Fri, 7 Oct 2022 09:12:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20221007091222euoutp0101d7e8e5def78532fe0b12e34ae76fd4~bvn_xGody2797127971euoutp01w DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1665133942; bh=NnlhAE8EQ9TqQjdG3v3TjYkbxpX0gkMebq4PXivsg1Y=; h=From:To:Cc:Subject:Date:References:From; b=U3e2s4ONy7esOqhI3/odG/aNhmyYw3hiw8dtUDJmYvfr0ywXpRG3aDQl3sTz+YJYp oJdoWYKUVTaYlNX2MaJbzve0aX5v9Hdika5jlcAWP65Wco3BfrtB1B0hiM0VvODhkd c1RruK4HFfmfqblC7NolXkcp7Q+FUFHgbReDNl2I= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20221007091222eucas1p26d9b8e95aa49ec5a77e31962b62aff3e~bvn_jvPeg3043330433eucas1p2F; Fri, 7 Oct 2022 09:12:22 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 0F.ED.29727.57DEF336; Fri, 7 Oct 2022 10:12:22 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20221007091221eucas1p194ad064eee911019b0af6f339a41660e~bvn9pe12r2634026340eucas1p1E; Fri, 7 Oct 2022 09:12:21 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20221007091221eusmtrp169a6ad1602c3eff8a6bc2c3bf38dd1a4~bvn9ozUnm1568315683eusmtrp1U; Fri, 7 Oct 2022 09:12:21 +0000 (GMT) X-AuditID: cbfec7f2-205ff7000001741f-cb-633fed7528b4 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 1C.A3.10862.57DEF336; Fri, 7 Oct 2022 10:12:21 +0100 (BST) Received: from AMDN5164.EU.corp.samsungelectronics.net (unknown [106.210.132.171]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20221007091221eusmtip1c767adb633055ff110056ea8fc458e3b~bvn9INO312948229482eusmtip1e; Fri, 7 Oct 2022 09:12:21 +0000 (GMT) From: Dawid Kozinski To: d.frankiewic@samsung.com, ffmpeg-devel@ffmpeg.org Date: Fri, 7 Oct 2022 11:12:10 +0200 Message-Id: <20221007091210.1489-1-d.kozinski@samsung.com> X-Mailer: git-send-email 2.37.3.windows.1 MIME-Version: 1.0 X-Unsent: 1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBIsWRmVeSWpSXmKPExsWy7djPc7plb+2TDZYeZbT4cu0Ls8XKb79Z LL59OsPswOzxZ9FmFo++LasYA5iiuGxSUnMyy1KL9O0SuDJ2d29lK5ijVbF/9We2BsaP8l2M nBwSAiYSW/+3sIPYQgIrGCVm/lbpYuQCsr8wSux8vZoZIvGZUeLTHiuYhgPXdrNCFC1nlGg4 8Jwdwmlnkpi+ZRYLSBWbgK7Eyw+PmEBsEQFTiZPNe9lAbGYBbYl1d7+D2cICCRLrFs4Gq2ER UJWY8PUf2DZeASuJGRvOsUFs05SYsGUOE0RcUOLkzCcsEHFuiXWzLrFCzJSXaN46mxki/pNd Yv9C5S5GDiDbRWJdA9TRwhKvjm9hh7BlJE5P7mGBKCmWONTvAGHWSBz6kQ5RYS3xtvE4I0iY GeiA9bv0IcKOEu/OvmKFqOaTuPFWEGI9n8SkbdOZIcK8Eh1tQhCmikRfpxhEo5TE02VzoA70 kNi7rIl1AqPiLCQ/zULyxyyEtQsYmVcxiqeWFuempxYb5qWW6xUn5haX5qXrJefnbmIEJobT /45/2sE499VHvUOMTByMhxglOJiVRHh37rRLFuJNSaysSi3Kjy8qzUktPsQozcGiJM7LNkMr WUggPbEkNTs1tSC1CCbLxMEp1cA0Y9Fui8bSuIu/b7dfUPnVHVC06tDf95Nk9nUceXVuY5Dk u62uKjMn8E8VSTquLruZf8c0T+G3UiWFDWFXQgsPRgQGe4tuKnLa2f6iaIXAlnAGo8MT3yQp ZnTu0D5pZPTOtzP2W7q1rcDbZoYFc2ytrLM5i94fOfEvVdPpWCLrzrc8RxSnvDp15/HEDyJW NpG9scGlp1gWRzPGaypq+2uplvlqH9ime27X4iYJq26jE1Xt6w7HfI58u7ZLvOyW3ksOeX7h Y5/EspdfNxPZtFxFiuutWGXUzjDFPctKZp64kXfkXa5cEHdo1PsZwuLLrmqdOMM35e9etc8B BiprLtceupZU5ikooaXs9IRz9mslluKMREMt5qLiRAA2TrMyewMAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrILMWRmVeSWpSXmKPExsVy+t/xu7qlb+2TDV4dE7f4cu0Ls8XKb79Z LL59OsPswOzxZ9FmFo++LasYA5ii9GyK8ktLUhUy8otLbJWiDS2M9AwtLfSMTCz1DI3NY62M TJX07WxSUnMyy1KL9O0S9DJ2d29lK5ijVbF/9We2BsaP8l2MnBwSAiYSB67tZu1i5OIQEljK KPFp6TFmiISUxNKlixghbGGJP9e62CCKWpkk5i37BlbEJqAr8fLDIyYQW0TAXOLiultgDcwC 2hLr7n4HauDgEBaIk5i9hh8kzCKgKjHh6z+wVl4BK4kZG86xQczXlJiwZQ4TRFxQ4uTMJywQ cW6JdbMusUKMlJdo3jqbeQIj/ywkZbOQpBYwMq1iFEktLc5Nzy020itOzC0uzUvXS87P3cQI DNttx35u2cG48tVHvUOMTByMhxglOJiVRHh37rRLFuJNSaysSi3Kjy8qzUktPsRoCnTrRGYp 0eR8YOTklcQbmhmYGpqYWRqYWpoZK4nzehZ0JAoJpCeWpGanphakFsH0MXFwSjUwGfBopd5a 2bV9buWnY2730q+slq413lsiOl/6lvGVDywFtXZWFrs2py5UagyKFD7Eet5Rt0mwjKlq6YH/ J5avz57/JfnpoczVu0tW/uTa2NfmHv9NS3Ti83cHdRy7OM+ounn9Ostwrlnyu9m1aX0SOYxL 1uosEvtfGhHWIRfg7HhL/0y96c5jjw3r027PnxexgtvQ7avL4a5PqQ6LhSYwhNuq1BxlVnDg rd3sKVv04Zj6yvP8TVc75hnsb6ooSWozDWoPP54x8fPWowJpeWXFDWxsDA56pT9fTCl9z96l Fsa+ofNK79HUuJm7pnxa9nGNsJ0nk9GUiMKTionHmnY092Y0rc2Y1S0/2ba0o12JpTgj0VCL uag4EQDD+jyc5AIAAA== X-CMS-MailID: 20221007091221eucas1p194ad064eee911019b0af6f339a41660e X-Msg-Generator: CA X-RootMTR: 20221007091221eucas1p194ad064eee911019b0af6f339a41660e X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20221007091221eucas1p194ad064eee911019b0af6f339a41660e References: Subject: [FFmpeg-devel] [PATCH v13 4/9] avformat/evc_demuxer: Added demuxer to handle reading EVC video files 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: Dawid Kozinski Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: YrkV/85dijwy - Provided AVInputFormat structure describing EVC input format (ff_evc_demuxer) Signed-off-by: Dawid Kozinski --- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/evcdec.c | 124 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 126 insertions(+) create mode 100644 libavformat/evcdec.c diff --git a/libavformat/Makefile b/libavformat/Makefile index a14a759c1f..af175d2097 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -251,6 +251,7 @@ OBJS-$(CONFIG_HCOM_DEMUXER) += hcom.o pcm.o OBJS-$(CONFIG_HDS_MUXER) += hdsenc.o OBJS-$(CONFIG_HEVC_DEMUXER) += hevcdec.o rawdec.o OBJS-$(CONFIG_HEVC_MUXER) += rawenc.o +OBJS-$(CONFIG_EVC_DEMUXER) += evcdec.o rawdec.o OBJS-$(CONFIG_EVC_MUXER) += rawenc.o OBJS-$(CONFIG_HLS_DEMUXER) += hls.o hls_sample_encryption.o OBJS-$(CONFIG_HLS_MUXER) += hlsenc.o hlsplaylist.o avc.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 615d2bc3b1..e4cc112b90 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -150,6 +150,7 @@ extern const AVInputFormat ff_ea_cdata_demuxer; extern const AVInputFormat ff_eac3_demuxer; extern const AVOutputFormat ff_eac3_muxer; extern const AVInputFormat ff_epaf_demuxer; +extern const AVInputFormat ff_evc_demuxer; extern const AVOutputFormat ff_evc_muxer; extern const AVOutputFormat ff_f4v_muxer; extern const AVInputFormat ff_ffmetadata_demuxer; diff --git a/libavformat/evcdec.c b/libavformat/evcdec.c new file mode 100644 index 0000000000..ffb7449c4d --- /dev/null +++ b/libavformat/evcdec.c @@ -0,0 +1,124 @@ +/* + * RAW EVC video demuxer + * + * Copyright (c) 2021 Dawid Kozinski + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavcodec/get_bits.h" +#include "libavcodec/golomb.h" +#include "libavcodec/internal.h" +#include "libavcodec/evc.h" + +#include "rawdec.h" +#include "avformat.h" + +typedef struct EVCParserContext { + int got_sps; + int got_pps; + int got_idr; + int got_nonidr; +} EVCParserContext; + +static int get_nalu_type(const uint8_t *bits, int bits_size) +{ + int unit_type_plus1 = 0; + + if(bits_size >= EVC_NAL_HEADER_SIZE) { + unsigned char *p = (unsigned char *)bits; + // forbidden_zero_bit + if ((p[0] & 0x80) != 0) { // Cannot get bitstream information. Malformed bitstream. + return -1; + } + + // nal_unit_type + unit_type_plus1 = (p[0] >> 1) & 0x3F; + } + + return unit_type_plus1 - 1; +} + +static uint32_t read_nal_unit_length(const uint8_t *bits, int bits_size) +{ + uint32_t nalu_len = 0; + + if(bits_size >= EVC_NAL_UNIT_LENGTH_BYTE) { + + int t = 0; + unsigned char *p = (unsigned char *)bits; + + for(int i=0; ibuf; + int bytes_to_read = p->buf_size; + + while(bytes_to_read > EVC_NAL_UNIT_LENGTH_BYTE) { + + nalu_size = read_nal_unit_length(bits, EVC_NAL_UNIT_LENGTH_BYTE); + if(nalu_size == 0) break; + + bits += EVC_NAL_UNIT_LENGTH_BYTE; + bytes_to_read -= EVC_NAL_UNIT_LENGTH_BYTE; + + if(bytes_to_read < nalu_size) break; + + nalu_type = get_nalu_type(bits, bytes_to_read); + + bits += nalu_size; + bytes_to_read -= nalu_size; + + if (nalu_type == EVC_SPS_NUT) + ev->got_sps++; + else if (nalu_type == EVC_PPS_NUT) + ev->got_pps++; + else if (nalu_type == EVC_IDR_NUT ) + ev->got_idr++; + else if (nalu_type == EVC_NOIDR_NUT) + ev->got_nonidr++; + } + + return 0; +} + +static int evc_probe(const AVProbeData *p) +{ + EVCParserContext ev = {0}; + int ret = parse_nal_units(p, &ev); + + if (ret == 0 && ev.got_sps && ev.got_pps && (ev.got_idr || ev.got_nonidr > 3)) + return AVPROBE_SCORE_EXTENSION + 1; // 1 more than .mpg + + return 0; +} + +FF_DEF_RAWVIDEO_DEMUXER(evc, "raw EVC video", evc_probe, "evc", AV_CODEC_ID_EVC) From patchwork Fri Oct 7 09:12:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawid Kozinski X-Patchwork-Id: 38599 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4d9:b0:9c:f4b:4e41 with SMTP id 25csp173716pzd; Fri, 7 Oct 2022 02:12:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6zM7gCQNqienXpIKtqcq7pHg7HCTwuQHqjA2Qn48TEQstQebIfRXRprmHeGOeiLZZtp8Ss X-Received: by 2002:a05:6402:528a:b0:454:8613:6560 with SMTP id en10-20020a056402528a00b0045486136560mr3796135edb.252.1665133970667; Fri, 07 Oct 2022 02:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665133970; cv=none; d=google.com; s=arc-20160816; b=WpIXO/ndeFDjcWlonXvoAPpUKiALH83xR/HCB2tCvE05P9z87PxG7XageCHeFCITaI wHlAt+ipNSXbWBgbd+zXeA6RMnFiI1rKm6cLy2FwteSbKa1yI8ZfYctIz2x3Vz2UP4IO G5boFP7rm415GoFo/HKid8KFLbEQZBoD7f5p+NwEewXFdLYmjP0m4hYdkLw7PImIMreN ae4n5SBvHo+Eyv+4KUrpg1tos+uLviVGVc1i+TEWkCX17f6FPKxoV1wNR3bwTzKG1Leb S/TdPzg01FxDsEy5CcVOrfuXm0sj4Wv5/eVch31AZSjBkpQ/9LwnecIm2+L7hT4ZBLJx IeQA== 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:references:cms-type:mime-version :message-id:date:to:from:dkim-signature:dkim-filter:delivered-to; bh=ZJ2D+SflouLeNClsf+tEWpgiHXm63VypjhMIQriSTZM=; b=XfmPMyOXKyGLZyqGvqRCn0ES5wgWFhDIvEY8VMQ+1LmtYt4Rujdtb3gtRSnWAu/B2W OQj1WdMlMNSK78fB66sKfyf294BvBaAsd6E55ZlvaR9rSNdCwYXQuZXf2BuoXIwwqKEo u2Nq5eKHc/T2fittkiAnomEdEK7h4QWOHVxt0dQfTozvvCaN8KLR08AmOVqFgYVc4Grr Iz2aPmEjC8xIQ6KJjfXAgahtywX9Bu55BkUn91VajAeGSHB5nYkiJzh/B82hufczaLo1 slv+tmjJKCMQiv3Yd1qEttECH/q+J+KBRZukPwoI7Bjk1vsu/txsPhDwnYmuuzHhWEsm SF7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=WeXD23UE; 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=samsung.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id o10-20020a170906974a00b0073ddab3aa79si2127559ejy.792.2022.10.07.02.12.50; Fri, 07 Oct 2022 02:12:50 -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=@samsung.com header.s=mail20170921 header.b=WeXD23UE; 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=samsung.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 06E7F68BBDF; Fri, 7 Oct 2022 12:12:48 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C8EC068BBA0 for ; Fri, 7 Oct 2022 12:12:46 +0300 (EEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20221007091246euoutp01e075b75ebb1f90a5d0a984a56a529f17~bvoUlacre2861628616euoutp01R for ; Fri, 7 Oct 2022 09:12:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20221007091246euoutp01e075b75ebb1f90a5d0a984a56a529f17~bvoUlacre2861628616euoutp01R DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1665133966; bh=662dcditAPR6IJhLbX3iGM20nNKGQuFBchnbKcnuCqA=; h=From:To:Cc:Subject:Date:References:From; b=WeXD23UER+i3hUrIMyekmVz2+WQbCQdSMAMr2Gr/V/n0ucBnzUeUFa3MMeZT5H76n FEixufD8UWBSAe95D9/luMkG4jEC9Fo5lV23JMs9TFywVqPnOMT0ixlO5sNtSdmcOB iRkHREfoBWeQexBTV80lG3Nas/A6JJcXoopenjqE= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20221007091245eucas1p17d95ce404d02884b7c8cda0b1bed8f5d~bvoUKNXsL1831318313eucas1p1_; Fri, 7 Oct 2022 09:12:45 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 5B.41.19378.D8DEF336; Fri, 7 Oct 2022 10:12:45 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20221007091245eucas1p1a8675ffcb82937b20649092a871cb811~bvoTwDjls3175731757eucas1p1G; Fri, 7 Oct 2022 09:12:45 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20221007091245eusmtrp12d3705567c143af002e2d458e67f4fe2~bvoTvc79Z1622516225eusmtrp1R; Fri, 7 Oct 2022 09:12:45 +0000 (GMT) X-AuditID: cbfec7f5-a35ff70000014bb2-51-633fed8de3ca Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 0A.B3.10862.D8DEF336; Fri, 7 Oct 2022 10:12:45 +0100 (BST) Received: from AMDN5164.EU.corp.samsungelectronics.net (unknown [106.210.132.171]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20221007091245eusmtip1d43e200713a3a14777866bb7b4c6f13d~bvoTaYKsZ0535005350eusmtip1k; Fri, 7 Oct 2022 09:12:45 +0000 (GMT) From: Dawid Kozinski To: d.frankiewic@samsung.com, ffmpeg-devel@ffmpeg.org Date: Fri, 7 Oct 2022 11:12:34 +0200 Message-Id: <20221007091234.1096-1-d.kozinski@samsung.com> X-Mailer: git-send-email 2.37.3.windows.1 MIME-Version: 1.0 X-Unsent: 1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHIsWRmVeSWpSXmKPExsWy7djPc7q9b+2TDSYt1Lf4cu0Ls8XKb79Z LL59OsPswOzxZ9FmFo++LasYA5iiuGxSUnMyy1KL9O0SuDKeTXrLVnDwN2PF28bTjA2MD/cy djFyckgImEhM3jWPqYuRi0NIYAWjxJ+LlxghnC+MEosfXWOBcD4zSsz43coK0/J45ht2iMRy RokjVz5B9bczScya8Rqsik1AV+Llh0dMILaIgKnEyea9bCA2s4C2xLq738FsYYEAidMzu9hB bBYBVYl9W/eB1fMKWEmsX3AOapumxIQtc6DighInZz5hgYhzS6ybdYkVYqa8RPPW2cwgR0gI /GSX+Dx5ARNEkYvEzRknmSFsYYlXx7ewQ9gyEqcn9wAN4gCyiyUO9TtAmDUSh36kQ1RYS7xt PM4IEmYGOmH9Ln2IsKPE64e/mSCq+SRuvBWEOIBPYtK26cwQYV6JjjYhCFNFoq9TDKJRSuLp sjlQl3hIvNu/lnkCo+IsJF/NQvLJLIS1CxiZVzGKp5YW56anFhvnpZbrFSfmFpfmpesl5+du YgQmidP/jn/dwbji1Ue9Q4xMHIyHGCU4mJVEeHfutEsW4k1JrKxKLcqPLyrNSS0+xCjNwaIk zss2QytZSCA9sSQ1OzW1ILUIJsvEwSnVwCTmFJ2iaBD8SOrkWlutOUp8R5ZbnQ7cW30hJGnV De41kx792PaLd9aUdy6uu44aVp42Zpm8ucPR/g7/mx/7w7OPtT7fndFy6wRrp+43Qx2LkoaC rSxrf/SlN0U/PFm13+tbYGXPsjNvFuvnRRQlLD4ZoXTNQnVHeG+4/0dnM5ZUnb+lyaZbe1c8 PuMhGtxycsfvzt+97KrpVhterttz0vyp7omla17+1uWyvbLuUebm0qdq0+TPsLK9uMbQceeL JP+Z29P+Hnz/WJ2zcMH3m0ukei+sfs+0cdUnhnt7LP98cbl8Yu+2ToVLvU3tdyamcV5cNqNw /h7zVv8Eq4Doe6sXnpAyFGP2Oqn6WutmRuZ3JZbijERDLeai4kQAzdMdSIEDAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrCLMWRmVeSWpSXmKPExsVy+t/xu7q9b+2TDU6dFbH4cu0Ls8XKb79Z LL59OsPswOzxZ9FmFo++LasYA5ii9GyK8ktLUhUy8otLbJWiDS2M9AwtLfSMTCz1DI3NY62M TJX07WxSUnMyy1KL9O0S9DKeTXrLVnDwN2PF28bTjA2MD/cydjFyckgImEg8nvmGvYuRi0NI YCmjxK/dG9khElISS5cugioSlvhzrYsNoqiVSeJ0wwGwBJuArsTLD4+YQGwRAXOJi+tugcWZ BbQl1t39zgZiCwv4SUzonAcWZxFQldi3dR9YPa+AlcT6BedYIRZoSkzYMgcqLihxcuYTFog4 t8S6WZdYIWbKSzRvnc08gZF/FpKyWUhSCxiZVjGKpJYW56bnFhvpFSfmFpfmpesl5+duYgQG 77ZjP7fsYFz56qPeIUYmDsZDjBIczEoivDt32iUL8aYkVlalFuXHF5XmpBYfYjQFunUis5Ro cj4wfvJK4g3NDEwNTcwsDUwtzYyVxHk9CzoShQTSE0tSs1NTC1KLYPqYODilGphYpX7+PmlX xH9CmU3P+fssafb6SYf1I850P/dlYj3y666U/4PUOW0frZhiv328t+hK/HL9Ff2nc08r6B/c nMS366S+Ic9Dq0T+lV4iN/JynarYVXl37DCrznST4xEXLUhdesCNm8O6/8D+pfN4nvu7MR76 9Kx3qQtTaSXzIpNK1lMGXJ/ThAv8eHxkq9leqUWJz3x5uXBTi0zefM2qKC6dvOVfs7WEpnlP e3Tj5E3mb0/b27+8fbjvltuK7bX3UlfV13Btj8lX/WBa5NT2cBn/TkOuLwtPfzk6wefPWoee LQu2hLkvWCDcdJGVW3xKT7v1h7J/lhdkzVdfnbpsYfVxmdMndzm1aFx+P/lAWJISS3FGoqEW c1FxIgCAl/PB5wIAAA== X-CMS-MailID: 20221007091245eucas1p1a8675ffcb82937b20649092a871cb811 X-Msg-Generator: CA X-RootMTR: 20221007091245eucas1p1a8675ffcb82937b20649092a871cb811 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20221007091245eucas1p1a8675ffcb82937b20649092a871cb811 References: Subject: [FFmpeg-devel] [PATCH v13 5/9] avcodec/evc_encoder: Provided support for EVC encoder 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: Dawid Kozinski Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: RAfmY+HV1dgX - Added EVC encoder wrapper - Changes in project configuration file and libavcodec Makefile - Added documentation for xeve wrapper Signed-off-by: Dawid Kozinski --- configure | 4 + doc/encoders.texi | 69 +++++ doc/general_contents.texi | 11 + libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/libxeve.c | 615 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 701 insertions(+) create mode 100644 libavcodec/libxeve.c diff --git a/configure b/configure index 957b7fe13e..7f430995a6 100755 --- a/configure +++ b/configure @@ -291,6 +291,7 @@ External library support: --enable-libwebp enable WebP encoding via libwebp [no] --enable-libx264 enable H.264 encoding via x264 [no] --enable-libx265 enable HEVC encoding via x265 [no] + --enable-libxeve enable EVC encoding via libxeve [no] --enable-libxavs enable AVS encoding via xavs [no] --enable-libxavs2 enable AVS2 encoding via xavs2 [no] --enable-libxcb enable X11 grabbing using XCB [autodetect] @@ -1876,6 +1877,7 @@ EXTERNAL_LIBRARY_LIST=" libvorbis libvpx libwebp + libxeve libxml2 libzimg libzmq @@ -3407,6 +3409,7 @@ libx264rgb_encoder_select="libx264_encoder" libx265_encoder_deps="libx265" libxavs_encoder_deps="libxavs" libxavs2_encoder_deps="libxavs2" +libxeve_encoder_deps="libxeve" libxvid_encoder_deps="libxvid" libzvbi_teletext_decoder_deps="libzvbi" vapoursynth_demuxer_deps="vapoursynth" @@ -6739,6 +6742,7 @@ enabled libx265 && require_pkg_config libx265 x265 x265.h x265_api_get require_cpp_condition libx265 x265.h "X265_BUILD >= 70" enabled libxavs && require libxavs "stdint.h xavs.h" xavs_encoder_encode "-lxavs $pthreads_extralibs $libm_extralibs" enabled libxavs2 && require_pkg_config libxavs2 "xavs2 >= 1.3.0" "stdint.h xavs2.h" xavs2_api_get +enabled libxeve && require_pkg_config libxeve "xeve >= 0.4.0" "xeve.h" xeve_encode enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore enabled libzimg && require_pkg_config libzimg "zimg >= 2.7.0" zimg.h zimg_get_api_version enabled libzmq && require_pkg_config libzmq "libzmq >= 4.2.1" zmq.h zmq_ctx_new diff --git a/doc/encoders.texi b/doc/encoders.texi index 1a5216f8eb..4c8c2871ec 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -2894,6 +2894,75 @@ ffmpeg -i input -c:v libxavs2 -xavs2-params RdoqLevel=0 output.avs2 @end example @end table +@section libxeve + +eXtra-fast Essential Video Encoder (XEVE) MPEG-5 EVC encoder wrapper. +The xeve-equivalent options or values are listed in parentheses for easy migration. + +This encoder requires the presence of the libxeve headers and library +during configuration. You need to explicitly configure the build with +@option{--enable-libxeve}. + +@float NOTE +Many libxeve encoder options are mapped to FFmpeg global codec options, +while unique encoder options are provided through private options. +Additionally the xeve-params private options allows one to pass a list +of key=value tuples as accepted by the libxeve @code{parse_xeve_params} function. +@end float + +The xeve project website is at @url{https://github.com/mpeg5/xeve}. + +@subsection Options + +The following options are supported by the libxeve wrapper. +The xeve-equivalent options or values are listed in parentheses for easy migration. + +@float NOTE +To reduce the duplication of documentation, only the private options +and some others requiring special attention are documented here. For +the documentation of the undocumented generic options, see +@ref{codec-options,,the Codec Options chapter}. +@end float + +@float NOTE +To get a more accurate and extensive documentation of the libxeve options, +invoke the command @code{xeve_app --help} or consult the libxeve documentation. +@end float + +@table @option +@item b (@emph{bitrate}) +Set target video bitrate in bits/s. +Note that FFmpeg's b option is expressed in bits/s, while xeve's bitrate is in kilobits/s. + +@item bf (@emph{bframes}) +Set the maximum number of B frames (1,3,7,15). + +@item g (@emph{keyint}) +Set the GOP size (I-picture period). + +@item preset (@emph{preset}) +Set the xeve preset. +Set the encoder preset value to determine encoding speed [fast, medium, slow, placebo] + +@item tune (@emph{tune}) +Set the encoder tune parameter [psnr, zerolatency] + +@item profile (@emph{profile}) +Set the encoder profile [0: baselie; 1: main] + +@item crf (@emph{crf}) +Set the quality for constant quality mode. +Constant rate factor <10..49> [default: 32] + +@item qp (@emph{qp}) +Set constant quantization rate control method parameter. +Quantization parameter qp <0..51> [default: 32] + +@item threads (@emph{threads}) +Force to use a specific number of threads + +@end table + @section libxvid Xvid MPEG-4 Part 2 encoder wrapper. diff --git a/doc/general_contents.texi b/doc/general_contents.texi index b005cb6c3e..417f0ab64f 100644 --- a/doc/general_contents.texi +++ b/doc/general_contents.texi @@ -343,6 +343,14 @@ libxavs2 is under the GNU Public License Version 2 or later details), you must upgrade FFmpeg's license to GPL in order to use it. @end float +@section eXtra-fast Essential Video Encoder (XEVE) + +FFmpeg can make use of the XEVE library for EVC video encoding. + +Go to @url{https://github.com/mpeg5/xeve} and follow the instructions for +installing the XEVE library. Then pass @code{--enable-libxeve} to configure to +enable it. + @section ZVBI ZVBI is a VBI decoding library which can be used by FFmpeg to decode DVB @@ -595,6 +603,7 @@ library: @item raw DTS @tab X @tab X @item raw DTS-HD @tab @tab X @item raw E-AC-3 @tab X @tab X +@item raw EVC @tab X @tab X @item raw FLAC @tab X @tab X @item raw GSM @tab @tab X @item raw H.261 @tab X @tab X @@ -934,6 +943,8 @@ following image formats are supported: @item Electronic Arts TQI video @tab @tab X @item Escape 124 @tab @tab X @item Escape 130 @tab @tab X +@item EVC / MPEG-5 Part 1 @tab X @tab X + @tab encoding supported through external library libxeve @item FFmpeg video codec #1 @tab X @tab X @tab lossless codec (fourcc: FFV1) @item Flash Screen Video v1 @tab X @tab X diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 0fdf141d54..8944e2a0d6 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1107,6 +1107,7 @@ OBJS-$(CONFIG_LIBX264_ENCODER) += libx264.o OBJS-$(CONFIG_LIBX265_ENCODER) += libx265.o OBJS-$(CONFIG_LIBXAVS_ENCODER) += libxavs.o OBJS-$(CONFIG_LIBXAVS2_ENCODER) += libxavs2.o +OBJS-$(CONFIG_LIBXEVE_ENCODER) += libxeve.o OBJS-$(CONFIG_LIBXVID_ENCODER) += libxvid.o OBJS-$(CONFIG_LIBZVBI_TELETEXT_DECODER) += libzvbi-teletextdec.o ass.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index cfeb01ac1c..5ce398f9ee 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -807,6 +807,7 @@ extern LIBX264_CONST FFCodec ff_libx264_encoder; #endif extern const FFCodec ff_libx264rgb_encoder; extern FFCodec ff_libx265_encoder; +extern const FFCodec ff_libxeve_encoder; extern const FFCodec ff_libxavs_encoder; extern const FFCodec ff_libxavs2_encoder; extern const FFCodec ff_libxvid_encoder; diff --git a/libavcodec/libxeve.c b/libavcodec/libxeve.c new file mode 100644 index 0000000000..38d70a1d2f --- /dev/null +++ b/libavcodec/libxeve.c @@ -0,0 +1,615 @@ +/* + * libxeve encoder + * EVC (MPEG-5 Essential Video Coding) encoding using XEVE MPEG-5 EVC encoder library + * + * Copyright (C) 2021 Dawid Kozinski + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include + +#include + +#include "libavutil/internal.h" +#include "libavutil/common.h" +#include "libavutil/opt.h" +#include "libavutil/pixdesc.h" +#include "libavutil/pixfmt.h" +#include "libavutil/time.h" +#include "libavutil/cpu.h" +#include "libavutil/avstring.h" + +#include "avcodec.h" +#include "internal.h" +#include "packet_internal.h" +#include "codec_internal.h" +#include "profiles.h" +#include "encode.h" + +#define MAX_BS_BUF (16*1024*1024) + +/** + * Error codes + */ +#define XEVE_PARAM_BAD_NAME -100 +#define XEVE_PARAM_BAD_VALUE -200 + +/** + * Encoder states + * + * STATE_ENCODING - the encoder receives and processes input frames + * STATE_BUMPING - there are no more input frames, however the encoder still processes previously received data + */ +typedef enum State { + STATE_ENCODING, + STATE_BUMPING, +} State; + +/** + * The structure stores all the states associated with the instance of Xeve MPEG-5 EVC encoder + */ +typedef struct XeveContext { + const AVClass *class; + + XEVE id; // XEVE instance identifier + XEVE_CDSC cdsc; // coding parameters i.e profile, width & height of input frame, num of therads, frame rate ... + XEVE_BITB bitb; // bitstream buffer (output) + XEVE_STAT stat; // encoding status (output) + XEVE_IMGB imgb; // image buffer (input) + + State state; // encoder state (skipping, encoding, bumping) + + int profile_id; // encoder profile (main, baseline) + int preset_id; // preset of xeve ( fast, medium, slow, placebo) + int tune_id; // tune of xeve (psnr, zerolatency) + + // variables for rate control modes + int rc_mode; // Rate control mode [ 0(CQP) / 1(ABR) / 2(CRF) ] + int qp; // quantization parameter (QP) [0,51] + int crf; // constant rate factor (CRF) [10,49] + + int hash; // embed picture signature (HASH) for conformance checking in decoding + int sei_info; // embed Supplemental enhancement information while encoding + + int color_format; // input data color format: currently only XEVE_CF_YCBCR420 is supported + + AVDictionary *xeve_params; +} XeveContext; + +/** + * Convert FFmpeg pixel format (AVPixelFormat) to XEVE pre-defined color format + * + * @param[in] av_pix_fmt pixel format (@see https://ffmpeg.org/doxygen/trunk/pixfmt_8h.html#a9a8e335cf3be472042bc9f0cf80cd4c5) + * @param[out] xeve_col_fmt XEVE pre-defined color format (@see xeve.h) + * + * @return 0 on success, negative value on failure + */ +static int libxeve_color_fmt(enum AVPixelFormat av_pix_fmt, int *xeve_col_fmt) +{ + switch (av_pix_fmt) { + case AV_PIX_FMT_YUV420P: + *xeve_col_fmt = XEVE_CF_YCBCR420; + break; + case AV_PIX_FMT_YUV420P10: + *xeve_col_fmt = XEVE_CF_YCBCR420; + break; + default: + *xeve_col_fmt = XEVE_CF_UNKNOWN; + return AVERROR_INVALIDDATA; + } + + return 0; +} + +/** + * Convert FFmpeg pixel format (AVPixelFormat) into XEVE pre-defined color space + * + * @param[in] px_fmt pixel format (@see https://ffmpeg.org/doxygen/trunk/pixfmt_8h.html#a9a8e335cf3be472042bc9f0cf80cd4c5) + * + * @return XEVE pre-defined color space (@see xeve.h) on success, XEVE_CF_UNKNOWN on failure + */ +static int libxeve_color_space(enum AVPixelFormat av_pix_fmt) +{ + /* color space of input image */ + int cs = XEVE_CF_UNKNOWN; + + switch (av_pix_fmt) { + case AV_PIX_FMT_YUV420P: + cs = XEVE_CS_YCBCR420; + break; + case AV_PIX_FMT_YUV420P10: +#if AV_HAVE_BIGENDIAN + cs = XEVE_CS_SET(XEVE_CF_YCBCR420, 10, 1); +#else + cs = XEVE_CS_YCBCR420_10LE; +#endif + + break; + default: + cs = XEVE_CF_UNKNOWN; + break; + } + + return cs; +} + +/** + * The function returns a pointer to the object of the XEVE_CDSC type. + * XEVE_CDSC contains all encoder parameters that should be initialized before the encoder is used. + * + * The field values of the XEVE_CDSC structure are populated based on: + * - the corresponding field values of the AvCodecConetxt structure, + * - the xeve encoder specific option values, + * (the full list of options available for xeve encoder is displayed after executing the command ./ffmpeg --help encoder = libxeve) + * + * The order of processing input data and populating the XEVE_CDSC structure + * 1) first, the fields of the AVCodecContext structure corresponding to the provided input options are processed, + * (i.e -pix_fmt yuv420p -s:v 1920x1080 -r 30 -profile:v 0) + * 2) then xeve-specific options added as AVOption to the xeve AVCodec implementation + * (i.e -preset 0) + * + * Keep in mind that, there are options that can be set in different ways. + * In this case, please follow the above-mentioned order of processing. + * The most recent assignments overwrite the previous values. + * + * @param[in] avctx codec context (AVCodecContext) + * @param[out] cdsc contains all Xeve MPEG-5 EVC encoder encoder parameters that should be initialized before the encoder is use + * + * @return 0 on success, negative error code on failure + */ +static int get_conf(AVCodecContext *avctx, XEVE_CDSC *cdsc) +{ + XeveContext *xectx = NULL; + int ret; + + xectx = avctx->priv_data; + + /* initialize xeve_param struct with default values */ + ret = xeve_param_default(&cdsc->param); + if (XEVE_FAILED(ret)) { + av_log(avctx, AV_LOG_ERROR, "Cannot set_default parameter\n"); + return AVERROR_EXTERNAL; + } + + /* read options from AVCodecContext */ + if (avctx->width > 0) + cdsc->param.w = avctx->width; + + if (avctx->height > 0) + cdsc->param.h = avctx->height; + + if (avctx->framerate.num > 0) { + // fps can be float number, but xeve API doesn't support it + cdsc->param.fps = (int)(((float)avctx->framerate.num / avctx->framerate.den) + 0.5); + } + + if (avctx->gop_size >= 0) // GOP size (key-frame interval, I-picture period) + cdsc->param.keyint = avctx->gop_size; // 0: only one I-frame at the first time; 1: every frame is coded in I-frame + + if (avctx->max_b_frames == 0 || avctx->max_b_frames == 1 || avctx->max_b_frames == 3 || + avctx->max_b_frames == 7 || avctx->max_b_frames == 15) // number of b-frames + cdsc->param.bframes = avctx->max_b_frames; + else { + av_log(avctx, AV_LOG_ERROR, "Incorrect value for maximum number of B frames: (%d) \n" + "Acceptable values for bf option (maximum number of B frames) are 0,1,3,7 or 15\n", avctx->max_b_frames); + return AVERROR_INVALIDDATA; + } + + if (avctx->level >= 0) + cdsc->param.level_idc = avctx->level; + + if (avctx->rc_buffer_size) // VBV buf size + cdsc->param.vbv_bufsize = (int)(avctx->rc_buffer_size / 1000); + + cdsc->param.rc_type = xectx->rc_mode; + + if (xectx->rc_mode == XEVE_RC_CQP) { + cdsc->param.qp = xectx->qp; + } else if (xectx->rc_mode == XEVE_RC_ABR) { + if (avctx->bit_rate / 1000 > INT_MAX || avctx->rc_max_rate / 1000 > INT_MAX) { + av_log(avctx, AV_LOG_ERROR, "Not supported bitrate bit_rate and rc_max_rate > %d000\n", INT_MAX); + return AVERROR_INVALIDDATA; + } + cdsc->param.bitrate = (int)(avctx->bit_rate / 1000); + } else if (xectx->rc_mode == XEVE_RC_CRF) { + cdsc->param.crf = xectx->crf; + } else { + av_log(avctx, AV_LOG_ERROR, "Not supported rate control type: %d\n", xectx->rc_mode); + return AVERROR_INVALIDDATA; + } + + if (avctx->thread_count <= 0) { + int cpu_count = av_cpu_count(); + cdsc->param.threads = (cpu_count < XEVE_MAX_THREADS) ? cpu_count : XEVE_MAX_THREADS; + } else if (avctx->thread_count > XEVE_MAX_THREADS) + cdsc->param.threads = XEVE_MAX_THREADS; + else + cdsc->param.threads = avctx->thread_count; + + + libxeve_color_fmt(avctx->pix_fmt, &xectx->color_format); + + cdsc->param.cs = XEVE_CS_SET(xectx->color_format, cdsc->param.codec_bit_depth, AV_HAVE_BIGENDIAN); + + cdsc->max_bs_buf_size = MAX_BS_BUF; + + ret = xeve_param_ppt(&cdsc->param, xectx->profile_id, xectx->preset_id, xectx->tune_id); + if (XEVE_FAILED(ret)) { + av_log(avctx, AV_LOG_ERROR, "Cannot set profile(%d), preset(%d), tune(%d)\n", xectx->profile_id, xectx->preset_id, xectx->tune_id); + return AVERROR_EXTERNAL; + } + + return 0; +} + +/** + * Set XEVE_CFG_SET_USE_PIC_SIGNATURE for encoder + * + * @param[in] logger context + * @param[in] id XEVE encodec instance identifier + * @param[in] ctx the structure stores all the states associated with the instance of Xeve MPEG-5 EVC encoder + * + * @return 0 on success, negative error code on failure + */ +static int set_extra_config(AVCodecContext *avctx, XEVE id, XeveContext *ctx) +{ + int ret, size; + size = 4; + + // embed SEI messages identifying encoder parameters and command line arguments + // - 0: off\n" + // - 1: emit sei info" + // + // SEI - Supplemental enhancement information contains information + // that is not necessary to decode the samples of coded pictures from VCL NAL units. + // Some SEI message information is required to check bitstream conformance + // and for output timing decoder conformance. + // @see ISO_IEC_23094-1_2020 7.4.3.5 + // @see ISO_IEC_23094-1_2020 Annex D + ret = xeve_config(id, XEVE_CFG_SET_SEI_CMD, &ctx->sei_info, &size); // sei_cmd_info + if (XEVE_FAILED(ret)) { + av_log(avctx, AV_LOG_ERROR, "Failed to set config for sei command info messages\n"); + return AVERROR_EXTERNAL; + } + + ret = xeve_config(id, XEVE_CFG_SET_USE_PIC_SIGNATURE, &ctx->hash, &size); + if (XEVE_FAILED(ret)) { + av_log(avctx, AV_LOG_ERROR, "Failed to set config for picture signature\n"); + return AVERROR_EXTERNAL; + } + + return 0; +} + +/** + * @brief Switch encoder to bumping mode + * + * @param id XEVE encodec instance identifier + * @return 0 on success, negative error code on failure + */ +static int setup_bumping(XEVE id) +{ + int val = 1; + int size = sizeof(int); + if (XEVE_FAILED(xeve_config(id, XEVE_CFG_SET_FORCE_OUT, (void *)(&val), &size))) + return AVERROR_EXTERNAL; + + return 0; +} + +/** + * @brief Initialize eXtra-fast Essential Video Encoder codec + * Create an encoder instance and allocate all the needed resources + * + * @param avctx codec context + * @return 0 on success, negative error code on failure + */ +static av_cold int libxeve_init(AVCodecContext *avctx) +{ + XeveContext *xectx = avctx->priv_data; + unsigned char *bs_buf = NULL; + int i; + int shift_h = 0; + int shift_v = 0; + int width_chroma = 0; + int height_chroma = 0; + XEVE_IMGB *imgb = NULL; + int ret = 0; + + XEVE_CDSC *cdsc = &(xectx->cdsc); + + /* allocate bitstream buffer */ + bs_buf = av_malloc(MAX_BS_BUF); + if (bs_buf == NULL) { + av_log(avctx, AV_LOG_ERROR, "Cannot allocate bitstream buffer\n"); + return AVERROR(ENOMEM); + } + xectx->bitb.addr = bs_buf; + xectx->bitb.bsize = MAX_BS_BUF; + + /* read configurations and set values for created descriptor (XEVE_CDSC) */ + if ((ret = get_conf(avctx, cdsc)) != 0) { + av_log(avctx, AV_LOG_ERROR, "Cannot get configuration\n"); + return AVERROR(EINVAL); + } + + if ((ret = xeve_param_check(&cdsc->param)) != 0) { + av_log(avctx, AV_LOG_ERROR, "Invalid configuration\n"); + return AVERROR(EINVAL); + } + + { + AVDictionaryEntry *en = NULL; + while (en = av_dict_get(xectx->xeve_params, "", en, AV_DICT_IGNORE_SUFFIX)) { + if ((ret = xeve_param_parse(&cdsc->param, en->key, en->value)) < 0) { + av_log(avctx, AV_LOG_WARNING, + "Error parsing option '%s = %s'.\n", + en->key, en->value); + } + } + } + + /* create encoder */ + xectx->id = xeve_create(cdsc, NULL); + if (xectx->id == NULL) { + av_log(avctx, AV_LOG_ERROR, "Cannot create XEVE encoder\n"); + return AVERROR_EXTERNAL; + } + + if ((ret = set_extra_config(avctx, xectx->id, xectx)) != 0) { + av_log(avctx, AV_LOG_ERROR, "Cannot set extra configuration\n"); + return AVERROR(EINVAL); + } + + if ((ret = av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &shift_h, &shift_v)) != 0) { + av_log(avctx, AV_LOG_ERROR, "Failed to get chroma shift\n"); + return AVERROR(EINVAL); + } + + // Chroma subsampling + // + // YUV format explanation + // shift_h == 1 && shift_v == 1 : YUV420 + // shift_h == 1 && shift_v == 0 : YUV422 + // shift_h == 0 && shift_v == 0 : YUV444 + // + width_chroma = AV_CEIL_RSHIFT(avctx->width, shift_h); + height_chroma = AV_CEIL_RSHIFT(avctx->height, shift_v); + + /* set default values for input image buffer */ + imgb = &xectx->imgb; + imgb->cs = libxeve_color_space(avctx->pix_fmt); + imgb->np = 3; /* only for yuv420p, yuv420ple */ + + for (i = 0; i < imgb->np; i++) + imgb->x[i] = imgb->y[i] = 0; + + imgb->w[0] = imgb->aw[0] = avctx->width; // width luma + imgb->w[1] = imgb->w[2] = imgb->aw[1] = imgb->aw[2] = width_chroma; + imgb->h[0] = imgb->ah[0] = avctx->height; // height luma + imgb->h[1] = imgb->h[2] = imgb->ah[1] = imgb->ah[2] = height_chroma; + + xectx->state = STATE_ENCODING; + + return 0; +} + +/** + * Encode raw data frame into EVC packet + * + * @param[in] avctx codec context + * @param[out] pkt output AVPacket containing encoded data + * @param[in] frame AVFrame containing the raw data to be encoded + * @param[out] got_packet encoder sets to 0 or 1 to indicate that a + * non-empty packet was returned in pkt + * + * @return 0 on success, negative error code on failure + */ +static int libxeve_encode(AVCodecContext *avctx, AVPacket *avpkt, + const AVFrame *frame, int *got_packet) +{ + XeveContext *xectx = avctx->priv_data; + int ret = -1; + + // No more input frames are available but encoder still can have some data in its internal buffer to process + // and some frames to dump. + if (xectx->state == STATE_ENCODING && frame == NULL) { + if (setup_bumping(xectx->id) == 0) + xectx->state = STATE_BUMPING; // Entering bumping process + else { + av_log(avctx, AV_LOG_ERROR, "Failed to setup bumping\n"); + return 0; + } + } + + if (xectx->state == STATE_ENCODING) { + int i; + XEVE_IMGB *imgb = NULL; + + imgb = &xectx->imgb; + + for (i = 0; i < imgb->np; i++) { + imgb->a[i] = frame->data[i]; + imgb->s[i] = frame->linesize[i]; + } + + imgb->ts[0] = frame->pts; + imgb->ts[1] = 0; + + /* push image to encoder */ + ret = xeve_push(xectx->id, imgb); + if (XEVE_FAILED(ret)) { + av_log(avctx, AV_LOG_ERROR, "xeve_push() failed\n"); + return AVERROR_EXTERNAL; + } + } + if (xectx->state == STATE_ENCODING || xectx->state == STATE_BUMPING) { + /* encoding */ + ret = xeve_encode(xectx->id, &(xectx->bitb), &(xectx->stat)); + if (XEVE_FAILED(ret)) { + av_log(avctx, AV_LOG_ERROR, "xeve_encode() failed\n"); + return AVERROR_EXTERNAL; + } + + /* store bitstream */ + if (ret == XEVE_OK_OUT_NOT_AVAILABLE) { // Return OK but picture is not available yet + *got_packet = 0; + return 0; + } else if (ret == XEVE_OK) { + int av_pic_type; + + if (xectx->stat.write > 0) { + + ret = ff_get_encode_buffer(avctx, avpkt, xectx->stat.write, 0); + if (ret < 0) + return ret; + + memcpy(avpkt->data, xectx->bitb.addr, xectx->stat.write); + + avpkt->pts = xectx->bitb.ts[0]; + avpkt->dts = xectx->bitb.ts[1]; + + switch(xectx->stat.stype) { + case XEVE_ST_I: + av_pic_type = AV_PICTURE_TYPE_I; + avpkt->flags |= AV_PKT_FLAG_KEY; + break; + case XEVE_ST_P: + av_pic_type = AV_PICTURE_TYPE_P; + break; + case XEVE_ST_B: + av_pic_type = AV_PICTURE_TYPE_B; + break; + case XEVE_ST_UNKNOWN: + av_log(avctx, AV_LOG_ERROR, "Unknown slice type\n"); + return AVERROR_INVALIDDATA; + } + + ff_side_data_set_encoder_stats(avpkt, xectx->stat.qp * FF_QP2LAMBDA, NULL, 0, av_pic_type); + + *got_packet = 1; + } + } else if (ret == XEVE_OK_NO_MORE_FRM) { + // Return OK but no more frames + return 0; + } else { + av_log(avctx, AV_LOG_ERROR, "Invalid return value: %d\n", ret); + return AVERROR_EXTERNAL; + } + } else { + av_log(avctx, AV_LOG_ERROR, "Udefined encoder state\n"); + return AVERROR_INVALIDDATA; + } + + return 0; +} + +/** + * Destroy the encoder and release all the allocated resources + * + * @param avctx codec context + * @return 0 on success, negative error code on failure + */ +static av_cold int libxeve_close(AVCodecContext *avctx) +{ + XeveContext *xectx = avctx->priv_data; + + if (xectx->id) { + xeve_delete(xectx->id); + xectx->id = NULL; + } + + av_free(xectx->bitb.addr); /* release bitstream buffer */ + + return 0; +} + +#define OFFSET(x) offsetof(XeveContext, x) +#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM + +static const enum AVPixelFormat supported_pixel_formats[] = { + AV_PIX_FMT_YUV420P, + AV_PIX_FMT_YUV420P10, + AV_PIX_FMT_NONE +}; + +// Consider using following options (./ffmpeg --help encoder=libxeve) +// +static const AVOption libxeve_options[] = { + { "preset", "Encoding preset for setting encoding speed", OFFSET(preset_id), AV_OPT_TYPE_INT, { .i64 = XEVE_PRESET_MEDIUM }, XEVE_PRESET_DEFAULT, XEVE_PRESET_PLACEBO, VE, "preset" }, + { "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XEVE_PRESET_DEFAULT }, INT_MIN, INT_MAX, VE, "preset" }, + { "fast", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XEVE_PRESET_FAST }, INT_MIN, INT_MAX, VE, "preset" }, + { "medium", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XEVE_PRESET_MEDIUM }, INT_MIN, INT_MAX, VE, "preset" }, + { "slow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XEVE_PRESET_SLOW }, INT_MIN, INT_MAX, VE, "preset" }, + { "placebo", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XEVE_PRESET_PLACEBO }, INT_MIN, INT_MAX, VE, "preset" }, + { "tune", "Tuning parameter for special purpose operation", OFFSET(tune_id), AV_OPT_TYPE_INT, { .i64 = XEVE_TUNE_NONE }, XEVE_TUNE_NONE, XEVE_TUNE_PSNR, VE, "tune"}, + { "none", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XEVE_TUNE_NONE }, INT_MIN, INT_MAX, VE, "tune" }, + { "zerolatency", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XEVE_TUNE_ZEROLATENCY }, INT_MIN, INT_MAX, VE, "tune" }, + { "psnr", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XEVE_TUNE_PSNR }, INT_MIN, INT_MAX, VE, "tune" }, + { "profile", "Encoding profile", OFFSET(profile_id), AV_OPT_TYPE_INT, { .i64 = XEVE_PROFILE_BASELINE }, XEVE_PROFILE_BASELINE, XEVE_PROFILE_MAIN, VE, "profile" }, + { "baseline", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XEVE_PROFILE_BASELINE }, INT_MIN, INT_MAX, VE, "profile" }, + { "main", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XEVE_PROFILE_MAIN }, INT_MIN, INT_MAX, VE, "profile" }, + { "rc_mode", "Rate control mode", OFFSET(rc_mode), AV_OPT_TYPE_INT, { .i64 = XEVE_RC_CQP }, XEVE_RC_CQP, XEVE_RC_CRF, VE, "rc_mode" }, + { "CQP", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XEVE_RC_CQP }, INT_MIN, INT_MAX, VE, "rc_mode" }, + { "ABR", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XEVE_RC_ABR }, INT_MIN, INT_MAX, VE, "rc_mode" }, + { "CRF", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XEVE_RC_CRF }, INT_MIN, INT_MAX, VE, "rc_mode" }, + { "qp", "Quantization parameter value for CQP rate control mode", OFFSET(qp), AV_OPT_TYPE_INT, { .i64 = 32 }, 0, 51, VE }, + { "crf", "Constant rate factor value for CRF rate control mode", OFFSET(crf), AV_OPT_TYPE_INT, { .i64 = 32 }, 10, 49, VE }, + { "hash", "Embed picture signature (HASH) for conformance checking in decoding", OFFSET(hash), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE }, + { "sei_info", "Embed SEI messages identifying encoder parameters and command line arguments", OFFSET(sei_info), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE }, + { "xeve-params", "Override the xeve configuration using a :-separated list of key=value parameters", OFFSET(xeve_params), AV_OPT_TYPE_DICT, { 0 }, 0, 0, VE }, + { NULL } +}; + +static const AVClass libxeve_class = { + .class_name = "libxeve", + .item_name = av_default_item_name, + .option = libxeve_options, + .version = LIBAVUTIL_VERSION_INT, +}; + +/** + * libavcodec generic global options, which can be set on all the encoders and decoders + * @see https://www.ffmpeg.org/ffmpeg-codecs.html#Codec-Options + */ +static const FFCodecDefault libxeve_defaults[] = { + { "b", "0" }, // bitrate in terms of kilo-bits per second + { "g", "0" }, // gop_size (key-frame interval 0: only one I-frame at the first time; 1: every frame is coded in I-frame) + { "bf", "15"}, // maximum number of B frames (0: no B-frames, 1,3,7,15) + { "threads", "0"}, // number of threads to be used (0: automatically select the number of threads to set) + { NULL }, +}; + +const FFCodec ff_libxeve_encoder = { + .p.name = "libxeve", + .p.long_name = NULL_IF_CONFIG_SMALL("libxeve MPEG-5 EVC"), + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_EVC, + .init = libxeve_init, + FF_CODEC_ENCODE_CB(libxeve_encode), + .close = libxeve_close, + .priv_data_size = sizeof(XeveContext), + .p.priv_class = &libxeve_class, + .defaults = libxeve_defaults, + .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS | AV_CODEC_CAP_DR1, + .p.profiles = NULL_IF_CONFIG_SMALL(ff_evc_profiles), + .p.wrapper_name = "libxeve", + .p.pix_fmts = supported_pixel_formats, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_NOT_INIT_THREADSAFE, +}; From patchwork Fri Oct 7 09:12:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawid Kozinski X-Patchwork-Id: 38600 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4d9:b0:9c:f4b:4e41 with SMTP id 25csp173832pzd; Fri, 7 Oct 2022 02:13:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7m2fU1/hyxLKhhy/51bYm2eG7APfZJ8Jpapjyry8qweisICQQkrKjY/FUujwgE8M1t/5kv X-Received: by 2002:a17:907:2be6:b0:78d:45d5:4867 with SMTP id gv38-20020a1709072be600b0078d45d54867mr3261974ejc.105.1665133997802; Fri, 07 Oct 2022 02:13:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665133997; cv=none; d=google.com; s=arc-20160816; b=HZ1ioqQTjG+wIHEdk1nqXd62AuXb2EnEPj2y6Q54oXiy2jcajlVRRzc0mJWbx0ITrg OjF+zOskNfKfG2eKXQN5uDiALj0I8t+Z9wBtCFNU99F5E3YidhTu+fi+KMOiQOmuvYhe R0KbVJ1stkow3eBNXCAIXslO8Za5YmBFzWkejpP//+j4hbvC5EhDcMhjG3lIoGA/FlK6 agzQZOLWN2QN+nAvbfOKl86hES6rOMLXv++D+e7YjNkhZDubsa8xNLVkQtyax28Olpbi ThwtRxowR6CaEqHj2z1Y8xp9TyacLQeGOZZnSVdio1SdS+2qKPmfjLqETq8e0WQUaBkN TVqA== 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:references:cms-type:mime-version :message-id:date:to:from:dkim-signature:dkim-filter:delivered-to; bh=H4b/CFokSo9pGarVKPQRQGj8MUVA3FrfqgdWl8r9cts=; b=mR2izEBr/mAdZ0sjG/JdllzPILq+GvV3WWD8j8yxxJq/bmGYzHa2ZPqVAQfLyyOKgW 5zU8N0u3KRJXLL1K+Vb6jfjV/jr2LY73kpDw+Wuqqq/6bIf5RzebLXN46LysO/LL0gFr 9kM09nbOPl1kKcSgir2nRdMZM0wBjesWGG7s7cAdt98DXlXAOwh4Xy7qylAx3vPvhe72 rhA8RIWFx2s1TwjS8MCdbcvaWie/ByiwoIXGAOzkuOhaMrXdTOv0AElDLARRhyTjdPsO hlwEvP/uCudkxncKI+Bn5apV/y6O7pmaMWAQxEdPU+ih1K8lzTsLnvOwRthYZuNH27YX bi+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=vL14z+2K; 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=samsung.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id t9-20020a50d709000000b004542c9947c1si1699086edi.217.2022.10.07.02.13.16; Fri, 07 Oct 2022 02:13:17 -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=@samsung.com header.s=mail20170921 header.b=vL14z+2K; 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=samsung.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 34AE568BBFD; Fri, 7 Oct 2022 12:13:14 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C798F68A72F for ; Fri, 7 Oct 2022 12:13:07 +0300 (EEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20221007091307euoutp02b7c30526f11e5e8c8b1420543d393889~bvooMknHz2052520525euoutp02M for ; Fri, 7 Oct 2022 09:13:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20221007091307euoutp02b7c30526f11e5e8c8b1420543d393889~bvooMknHz2052520525euoutp02M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1665133987; bh=Y/IvSa00RO80AevP/J43aWwjHBnWG3L9DDH/dymtR4c=; h=From:To:Cc:Subject:Date:References:From; b=vL14z+2KvJwSoLcKpdnZL16zy8dJp1UDn413WcEw1SYSmWaO3hBCtvANzsnBwQv7I nJkJ7MLhAANm3icxdqrIEEBU4noaqMt4ky35kEkb9Aa+HC05jd6f82AielUn/24VBO GAmlt9tlBRHRU61s39DF97kSzxM6Z+bx3/12r9fE= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20221007091307eucas1p1a4224ff0b02b3a05c676442ef00850d0~bvon55IKJ2633626336eucas1p1g; Fri, 7 Oct 2022 09:13:07 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 97.D5.07817.2ADEF336; Fri, 7 Oct 2022 10:13:06 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20221007091306eucas1p1dada13179d77572d38c4aacd625a1801~bvonbdzr62633626336eucas1p1f; Fri, 7 Oct 2022 09:13:06 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20221007091306eusmtrp1633c9a4568eec702cc7b44df77c3f422~bvonatEAe1622516225eusmtrp1A; Fri, 7 Oct 2022 09:13:06 +0000 (GMT) X-AuditID: cbfec7f4-8abff70000011e89-29-633feda21ebd Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id D4.C3.10862.2ADEF336; Fri, 7 Oct 2022 10:13:06 +0100 (BST) Received: from AMDN5164.EU.corp.samsungelectronics.net (unknown [106.210.132.171]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20221007091306eusmtip2450c4719021230e92b27f83cf8b8e8e9~bvonHjK7D2452924529eusmtip2e; Fri, 7 Oct 2022 09:13:06 +0000 (GMT) From: Dawid Kozinski To: d.frankiewic@samsung.com, ffmpeg-devel@ffmpeg.org Date: Fri, 7 Oct 2022 11:12:57 +0200 Message-Id: <20221007091257.425-1-d.kozinski@samsung.com> X-Mailer: git-send-email 2.37.3.windows.1 MIME-Version: 1.0 X-Unsent: 1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNIsWRmVeSWpSXmKPExsWy7djPc7qL3tonG7z6aW7x5doXZouV336z WHz7dIbZgdnjz6LNLB59W1YxBjBFcdmkpOZklqUW6dslcGX8+3SVveDIIsaK89cOsDYw7i7r YuTkkBAwkXjdf46ti5GLQ0hgBaPE9WOnmCGcL4wSi3fPg3I+M0o0z5jJDNOypKWPFSKxnFFi 99xXLBBOO5PEjl8L2EGq2AR0JV5+eMQEYosImEqcbN7LBmIzC2hLrLv7HcwWFgiQWPFhHpjN IqAqsf3+VKB6Dg5eAUuJuTt4IZZpSkzYMgdsDK+AoMTJmU9YIOLcEutmXWKFGCkv0bx1Ntil EgJ/2SWufDzPClHkItHyayYThC0s8er4FnYIW0bi9OQeFpBdEgLFEof6HSDMGolDP9IhKqwl 3jYeZwQJMwOdsH6XPkTYUWLJnF42iGo+iRtvBSEO4JOYtG06M0SYV6KjTQjCVJHo6xSDaJSS eLpsDlSFh8S+1WETGBVnIXlqFpJHZiFsXcDIvIpRPLW0ODc9tdgoL7Vcrzgxt7g0L10vOT93 EyMwPZz+d/zLDsblrz7qHWJk4mA8xCjBwawkwrtzp12yEG9KYmVValF+fFFpTmrxIUZpDhYl cV62GVrJQgLpiSWp2ampBalFMFkmDk6pBqYZ3SqzZbIbVU6qXe/slbJlO7U3pZ/v9q8a5zvB Toc1Df4Wv2U+r/t8UnCp9IxP2ws6ztTOPMg/N/LgqWPvIo6rKKZPkgh4rLD9wL6vf1/IbTWS urGOxSllcg7LwZMea4VZn1bc9VxtfPTJB79v7pK7a9tLdJvm6seyOazN37d17+f7ncuWnQ4/ 2TV9mbf+4Vvrf+pdeFfO63Hx3iXrQpM/dh3XHyupt8mXlwoJ8N2b3vL069YLrnpGXQ4/EyIO +iUsL8yqdp6iJJXw5Kn4ksN8dfZCl5b8331ZeapdX1Pgz1q/uzNb97x+ZasipG94UmW3j0bu Wc+udbd4pyosO3D/UZpTYlzhhcK8U5vLTCuUWIozEg21mIuKEwEpa+ypfgMAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrELMWRmVeSWpSXmKPExsVy+t/xe7qL3tonGxy/JGvx5doXZouV336z WHz7dIbZgdnjz6LNLB59W1YxBjBF6dkU5ZeWpCpk5BeX2CpFG1oY6RlaWugZmVjqGRqbx1oZ mSrp29mkpOZklqUW6dsl6GX8+3SVveDIIsaK89cOsDYw7i7rYuTkkBAwkVjS0sfaxcjFISSw lFFi86r3zBAJKYmlSxcxQtjCEn+udbFBFLUySfzaMJcdJMEmoCvx8sMjJhBbRMBc4uK6W2AN zALaEuvufmcDsYUF/CSeNr8Hs1kEVCW2358KVM/BwStgKTF3By/EfE2JCVvmgI3hFRCUODnz CQtEnFti3axLrBAj5SWat85mnsDIPwtJ2SwkqQWMTKsYRVJLi3PTc4uN9IoTc4tL89L1kvNz NzECA3fbsZ9bdjCufPVR7xAjEwfjIUYJDmYlEd6dO+2ShXhTEiurUovy44tKc1KLDzGaAp06 kVlKNDkfGDt5JfGGZgamhiZmlgamlmbGSuK8ngUdiUIC6YklqdmpqQWpRTB9TBycUg1MzQ6/ 989dUPp65UvtsJu/H7Ze3XyfzyTAZ3mU3enmhS6TjAIlnOM2nzQtXmkmn/vGV9YtxNrEdfc9 led6GdfYnd5/EuVyVmY1P7PIrXXnOa+tR2OTpB5989r3rntNsY1a2wfXUwJMBz+3nunPYlP0 aGfbNKOx8B3r9asi+vG3Q3w/f9+Z5BR6ILPOdlPttISr/MuZlFavWhGctsgq8brp1OIXVqwb Joif6r6QPjfIbUu61/nC83Oa0tYLnj5Yb150aO5/k/l18U9lemwUlYOmbfW3YggNf293+N9E P956ibdZHol/Uq40Lvffxdvxs2y5K0ccK8OO9NkrGOceKU+9FXruqyGX4NwNOV3uWzYpsRRn JBpqMRcVJwIAm6En8+UCAAA= X-CMS-MailID: 20221007091306eucas1p1dada13179d77572d38c4aacd625a1801 X-Msg-Generator: CA X-RootMTR: 20221007091306eucas1p1dada13179d77572d38c4aacd625a1801 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20221007091306eucas1p1dada13179d77572d38c4aacd625a1801 References: Subject: [FFmpeg-devel] [PATCH v13 6/9] avcodec/evc_decoder: Provided support for EVC decoder 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: Dawid Kozinski Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: la4Y2e2jqhza - Added EVC decoder wrapper - Changes in project configuration file and libavcodec Makefile - Added documentation for xevd wrapper Signed-off-by: Dawid Kozinski --- configure | 4 + doc/decoders.texi | 24 +++ doc/general_contents.texi | 10 +- libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/libxevd.c | 423 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 462 insertions(+), 1 deletion(-) create mode 100644 libavcodec/libxevd.c diff --git a/configure b/configure index 7f430995a6..0adbd4291e 100755 --- a/configure +++ b/configure @@ -292,6 +292,7 @@ External library support: --enable-libx264 enable H.264 encoding via x264 [no] --enable-libx265 enable HEVC encoding via x265 [no] --enable-libxeve enable EVC encoding via libxeve [no] + --enable-libxevd enable EVC decoding via libxevd [no] --enable-libxavs enable AVS encoding via xavs [no] --enable-libxavs2 enable AVS2 encoding via xavs2 [no] --enable-libxcb enable X11 grabbing using XCB [autodetect] @@ -1877,6 +1878,7 @@ EXTERNAL_LIBRARY_LIST=" libvorbis libvpx libwebp + libxevd libxeve libxml2 libzimg @@ -3409,6 +3411,7 @@ libx264rgb_encoder_select="libx264_encoder" libx265_encoder_deps="libx265" libxavs_encoder_deps="libxavs" libxavs2_encoder_deps="libxavs2" +libxevd_decoder_deps="libxevd" libxeve_encoder_deps="libxeve" libxvid_encoder_deps="libxvid" libzvbi_teletext_decoder_deps="libzvbi" @@ -6742,6 +6745,7 @@ enabled libx265 && require_pkg_config libx265 x265 x265.h x265_api_get require_cpp_condition libx265 x265.h "X265_BUILD >= 70" enabled libxavs && require libxavs "stdint.h xavs.h" xavs_encoder_encode "-lxavs $pthreads_extralibs $libm_extralibs" enabled libxavs2 && require_pkg_config libxavs2 "xavs2 >= 1.3.0" "stdint.h xavs2.h" xavs2_api_get +enabled libxevd && require_pkg_config libxevd "xevd >= 0.4.0" "xevd.h" xevd_decode enabled libxeve && require_pkg_config libxeve "xeve >= 0.4.0" "xeve.h" xeve_encode enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore enabled libzimg && require_pkg_config libzimg "zimg >= 2.7.0" zimg.h zimg_get_api_version diff --git a/doc/decoders.texi b/doc/decoders.texi index e2fcbf5dc9..0bd9096114 100644 --- a/doc/decoders.texi +++ b/doc/decoders.texi @@ -126,6 +126,30 @@ Set amount of frame threads to use during decoding. The default value is 0 (auto @end table +@section libxevd + +eXtra-fast Essential Video Decoder (XEVD) MPEG-5 EVC decoder wrapper. + +This decoder requires the presence of the libxevd headers and library +during configuration. You need to explicitly configure the build with +@option{--enable-libxevd}. + +The xevd project website is at @url{https://github.com/mpeg5/xevd}. + +@subsection Options + +The following options are supported by the libxevd wrapper. +The xevd-equivalent options or values are listed in parentheses for easy migration. + +To get a more accurate and extensive documentation of the libxevd options, +invoke the command @code{xevd_app --help} or consult the libxevd documentation. + +@table @option +@item threads (@emph{threads}) +Force to use a specific number of threads + +@end table + @section QSV Decoders The family of Intel QuickSync Video decoders (VC1, MPEG-2, H.264, HEVC, diff --git a/doc/general_contents.texi b/doc/general_contents.texi index 417f0ab64f..0d9daf43a7 100644 --- a/doc/general_contents.texi +++ b/doc/general_contents.texi @@ -351,6 +351,14 @@ Go to @url{https://github.com/mpeg5/xeve} and follow the instructions for installing the XEVE library. Then pass @code{--enable-libxeve} to configure to enable it. +@section eXtra-fast Essential Video Decoder (XEVD) + +FFmpeg can make use of the XEVD library for EVC video decoding. + +Go to @url{https://github.com/mpeg5/xevd} and follow the instructions for +installing the XEVD library. Then pass @code{--enable-libxevd} to configure to +enable it. + @section ZVBI ZVBI is a VBI decoding library which can be used by FFmpeg to decode DVB @@ -944,7 +952,7 @@ following image formats are supported: @item Escape 124 @tab @tab X @item Escape 130 @tab @tab X @item EVC / MPEG-5 Part 1 @tab X @tab X - @tab encoding supported through external library libxeve + @tab encoding and decoding supported through external libraries libxeve and libxevd @item FFmpeg video codec #1 @tab X @tab X @tab lossless codec (fourcc: FFV1) @item Flash Screen Video v1 @tab X @tab X diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 8944e2a0d6..f2799ae19b 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1107,6 +1107,7 @@ OBJS-$(CONFIG_LIBX264_ENCODER) += libx264.o OBJS-$(CONFIG_LIBX265_ENCODER) += libx265.o OBJS-$(CONFIG_LIBXAVS_ENCODER) += libxavs.o OBJS-$(CONFIG_LIBXAVS2_ENCODER) += libxavs2.o +OBJS-$(CONFIG_LIBXEVD_DECODER) += libxevd.o OBJS-$(CONFIG_LIBXEVE_ENCODER) += libxeve.o OBJS-$(CONFIG_LIBXVID_ENCODER) += libxvid.o OBJS-$(CONFIG_LIBZVBI_TELETEXT_DECODER) += libzvbi-teletextdec.o ass.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 5ce398f9ee..571ca31056 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -808,6 +808,7 @@ extern LIBX264_CONST FFCodec ff_libx264_encoder; extern const FFCodec ff_libx264rgb_encoder; extern FFCodec ff_libx265_encoder; extern const FFCodec ff_libxeve_encoder; +extern const FFCodec ff_libxevd_decoder; extern const FFCodec ff_libxavs_encoder; extern const FFCodec ff_libxavs2_encoder; extern const FFCodec ff_libxvid_encoder; diff --git a/libavcodec/libxevd.c b/libavcodec/libxevd.c new file mode 100644 index 0000000000..133d004f4b --- /dev/null +++ b/libavcodec/libxevd.c @@ -0,0 +1,423 @@ +/* + * libxevd decoder + * EVC (MPEG-5 Essential Video Coding) decoding using XEVD MPEG-5 EVC decoder library + * + * Copyright (C) 2021 Dawid Kozinski + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include + +#include + +#include "libavutil/internal.h" +#include "libavutil/common.h" +#include "libavutil/opt.h" +#include "libavutil/pixdesc.h" +#include "libavutil/pixfmt.h" +#include "libavutil/imgutils.h" +#include "libavutil/cpu.h" + +#include "avcodec.h" +#include "internal.h" +#include "packet_internal.h" +#include "codec_internal.h" +#include "profiles.h" +#include "decode.h" + +#define XEVD_PARAM_BAD_NAME -1 +#define XEVD_PARAM_BAD_VALUE -2 + +#define EVC_NAL_HEADER_SIZE 2 /* byte */ + +/** + * The structure stores all the states associated with the instance of Xeve MPEG-5 EVC decoder + */ +typedef struct XevdContext { + const AVClass *class; + + XEVD id; // XEVD instance identifier @see xevd.h + XEVD_CDSC cdsc; // decoding parameters @see xevd.h +} XevdContext; + +/** + * The function populates the XEVD_CDSC structure. + * XEVD_CDSC contains all decoder parameters that should be initialized before its use. + * + * @param[in] avctx codec context + * @param[out] cdsc contains all decoder parameters that should be initialized before its use + * + */ +static void get_conf(AVCodecContext *avctx, XEVD_CDSC *cdsc) +{ + int cpu_count = av_cpu_count(); + + /* clear XEVS_CDSC structure */ + memset(cdsc, 0, sizeof(XEVD_CDSC)); + + /* init XEVD_CDSC */ + if (avctx->thread_count <= 0) + cdsc->threads = (cpu_count < XEVD_MAX_TASK_CNT) ? cpu_count : XEVD_MAX_TASK_CNT; + else if (avctx->thread_count > XEVD_MAX_TASK_CNT) + cdsc->threads = XEVD_MAX_TASK_CNT; + else + cdsc->threads = avctx->thread_count; +} + +/** + * Read NAL unit length + * @param bs input data (bitstream) + * @return the length of NAL unit on success, 0 value on failure + */ +static uint32_t read_nal_unit_length(const uint8_t *bs, int bs_size, AVCodecContext *avctx) +{ + uint32_t len = 0; + XEVD_INFO info; + int ret; + + if (bs_size == XEVD_NAL_UNIT_LENGTH_BYTE) { + ret = xevd_info((void *)bs, XEVD_NAL_UNIT_LENGTH_BYTE, 1, &info); + if (XEVD_FAILED(ret)) { + av_log(avctx, AV_LOG_ERROR, "Cannot get bitstream information\n"); + return 0; + } + len = info.nalu_len; + if (len == 0) { + av_log(avctx, AV_LOG_ERROR, "Invalid bitstream size! [%d]\n", bs_size); + return 0; + } + } + + return len; +} + +/** + * @param[in] xectx the structure that stores all the state associated with the instance of Xeve MPEG-5 EVC decoder + * @param[out] avctx codec context + * @return 0 on success, negative value on failure + */ +static int export_stream_params(const XevdContext *xectx, AVCodecContext *avctx) +{ + int ret; + int size; + int color_space; + + avctx->pix_fmt = AV_PIX_FMT_YUV420P10; + + size = 4; + ret = xevd_config(xectx->id, XEVD_CFG_GET_CODED_WIDTH, &avctx->coded_width, &size); + if (XEVD_FAILED(ret)) { + av_log(avctx, AV_LOG_ERROR, "Failed to get coded_width\n"); + return AVERROR_EXTERNAL; + } + + ret = xevd_config(xectx->id, XEVD_CFG_GET_CODED_HEIGHT, &avctx->coded_height, &size); + if (XEVD_FAILED(ret)) { + av_log(avctx, AV_LOG_ERROR, "Failed to get coded_height\n"); + return AVERROR_EXTERNAL; + } + + ret = xevd_config(xectx->id, XEVD_CFG_GET_WIDTH, &avctx->width, &size); + if (XEVD_FAILED(ret)) { + av_log(avctx, AV_LOG_ERROR, "Failed to get width\n"); + return AVERROR_EXTERNAL; + } + + ret = xevd_config(xectx->id, XEVD_CFG_GET_HEIGHT, &avctx->height, &size); + if (XEVD_FAILED(ret)) { + av_log(avctx, AV_LOG_ERROR, "Failed to get height\n"); + return AVERROR_EXTERNAL; + } + + ret = xevd_config(xectx->id, XEVD_CFG_GET_COLOR_SPACE, &color_space, &size); + if (XEVD_FAILED(ret)) { + av_log(avctx, AV_LOG_ERROR, "Failed to get color_space\n"); + return AVERROR_EXTERNAL; + } + switch(color_space) { + case XEVD_CS_YCBCR400_10LE: + avctx->pix_fmt = AV_PIX_FMT_GRAY10LE; + break; + case XEVD_CS_YCBCR420_10LE: + avctx->pix_fmt = AV_PIX_FMT_YUV420P10LE; + break; + case XEVD_CS_YCBCR422_10LE: + avctx->pix_fmt = AV_PIX_FMT_YUV422P10LE; + break; + case XEVD_CS_YCBCR444_10LE: + avctx->pix_fmt = AV_PIX_FMT_YUV444P10LE; + break; + default: + av_log(avctx, AV_LOG_ERROR, "Unknown color space\n"); + avctx->pix_fmt = AV_PIX_FMT_NONE; + return AVERROR_INVALIDDATA; + } + + // the function returns sps->num_reorder_pics + ret = xevd_config(xectx->id, XEVD_CFG_GET_MAX_CODING_DELAY, &avctx->max_b_frames, &size); + if (XEVD_FAILED(ret)) { + av_log(avctx, AV_LOG_ERROR, "Failed to get max_coding_delay\n"); + return AVERROR_EXTERNAL; + } + + avctx->has_b_frames = (avctx->max_b_frames) ? 1 : 0; + + avctx->color_primaries = AVCOL_PRI_UNSPECIFIED; + avctx->color_trc = AVCOL_TRC_UNSPECIFIED; + avctx->colorspace = AVCOL_SPC_UNSPECIFIED; + + return 0; +} + +/** + * @brief Copy image in imgb to frame. + * + * @param avctx codec context + * @param[in] imgb + * @param[out] frame + * @return 0 on success, negative value on failure + */ +static int libxevd_image_copy(struct AVCodecContext *avctx, XEVD_IMGB *imgb, struct AVFrame *frame) +{ + int ret; + if (imgb->cs != XEVD_CS_YCBCR420_10LE) { + av_log(avctx, AV_LOG_ERROR, "Not supported pixel format: %s\n", av_get_pix_fmt_name(avctx->pix_fmt)); + return AVERROR_INVALIDDATA; + } + + if (imgb->w[0] != avctx->width || imgb->h[0] != avctx->height) { // stream resolution changed + if (ff_set_dimensions(avctx, imgb->w[0], imgb->h[0]) < 0) { + av_log(avctx, AV_LOG_ERROR, "Cannot set new dimension\n"); + return AVERROR_INVALIDDATA; + } + } + + if (ret = ff_get_buffer(avctx, frame, 0) < 0) { + return ret; + } + + av_image_copy(frame->data, frame->linesize, (const uint8_t **)imgb->a, + imgb->s, avctx->pix_fmt, + imgb->w[0], imgb->h[0]); + + return 0; +} + +/** + * Initialize decoder + * Create a decoder instance and allocate all the needed resources + * + * @param avctx codec context + * @return 0 on success, negative error code on failure + */ +static av_cold int libxevd_init(AVCodecContext *avctx) +{ + XevdContext *xectx = avctx->priv_data; + XEVD_CDSC *cdsc = &(xectx->cdsc); + + /* read configurations and set values for created descriptor (XEVD_CDSC) */ + get_conf(avctx, cdsc); + + /* create decoder */ + xectx->id = xevd_create(&(xectx->cdsc), NULL); + if (xectx->id == NULL) { + av_log(avctx, AV_LOG_ERROR, "Cannot create XEVD encoder\n"); + return AVERROR_EXTERNAL; + } + + return 0; +} + +/** + * Decode picture + * + * @param avctx codec context + * @param[out] frame decoded frame + * @param[out] got_frame_ptr decoder sets to 0 or 1 to indicate that a + * non-empty frame or subtitle was returned in + * outdata. + * @param[in] avpkt AVPacket containing encoded data to be decoded + * + * @return amount of bytes read from the packet on success, negative error + * code on failure + */ +static int libxevd_decode(struct AVCodecContext *avctx, struct AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt) +{ + XevdContext *xectx = NULL; + XEVD_IMGB *imgb = NULL; + XEVD_STAT stat; + XEVD_BITB bitb; + int xevd_ret, nalu_size, bs_read_pos; + int ret = 0; + + xectx = avctx->priv_data; + + if (avpkt->size > 0) { + bs_read_pos = 0; + imgb = NULL; + while(avpkt->size > (bs_read_pos + XEVD_NAL_UNIT_LENGTH_BYTE)) { + memset(&stat, 0, sizeof(XEVD_STAT)); + memset(&bitb, 0, sizeof(XEVD_BITB)); + + nalu_size = read_nal_unit_length(avpkt->data + bs_read_pos, XEVD_NAL_UNIT_LENGTH_BYTE, avctx); + if (nalu_size == 0) { + av_log(avctx, AV_LOG_ERROR, "Invalid bitstream\n"); + ret = AVERROR_INVALIDDATA; + goto ERR; + } + bs_read_pos += XEVD_NAL_UNIT_LENGTH_BYTE; + + bitb.addr = avpkt->data + bs_read_pos; + bitb.ssize = nalu_size; + + /* main decoding block */ + xevd_ret = xevd_decode(xectx->id, &bitb, &stat); + if (XEVD_FAILED(xevd_ret)) { + av_log(avctx, AV_LOG_ERROR, "Failed to decode bitstream\n"); + ret = AVERROR_EXTERNAL; + goto ERR; + } + + bs_read_pos += nalu_size; + + if (stat.nalu_type == XEVD_NUT_SPS) { // EVC stream parameters changed + if ((ret = export_stream_params(xectx, avctx)) != 0) + goto ERR; + } + + if (stat.read != nalu_size) + av_log(avctx, AV_LOG_INFO, "Different reading of bitstream (in:%d, read:%d)\n,", nalu_size, stat.read); + if (stat.fnum >= 0) { + // already has a decoded image + if (imgb) { + // xevd_pull uses pool of objects of type XEVD_IMGB. + // The pool size is equal MAX_PB_SIZE (26), so release object when it is no more needed + imgb->release(imgb); + imgb = NULL; + } + xevd_ret = xevd_pull(xectx->id, &imgb); + if (XEVD_FAILED(xevd_ret)) { + av_log(avctx, AV_LOG_ERROR, "Failed to pull the decoded image (xevd error code: %d, frame#=%d)\n", xevd_ret, stat.fnum); + ret = AVERROR_EXTERNAL; + goto ERR; + } else if (xevd_ret == XEVD_OK_FRM_DELAYED) { + if (imgb) { + // xevd_pull uses pool of objects of type XEVD_IMGB. + // The pool size is equal MAX_PB_SIZE (26), so release object when it is no more needed + imgb->release(imgb); + imgb = NULL; + } + } + if (imgb) { + int ret = libxevd_image_copy(avctx, imgb, frame); + if(ret < 0) { + goto ERR; + } + + frame->pts = avpkt->pts; + *got_frame_ptr = 1; + + // xevd_pull uses pool of objects of type XEVD_IMGB. + // The pool size is equal MAX_PB_SIZE (26), so release object when it is no more needed + imgb->release(imgb); + imgb = NULL; + } else + *got_frame_ptr = 0; + } + } + } else { // bumping + xevd_ret = xevd_pull(xectx->id, &(imgb)); + if (xevd_ret == XEVD_ERR_UNEXPECTED) { // bumping process completed + *got_frame_ptr = 0; + return 0; + } else if (XEVD_FAILED(xevd_ret)) { + av_log(avctx, AV_LOG_ERROR, "Failed to pull the decoded image (xevd error code: %d)\n", xevd_ret); + ret = AVERROR_EXTERNAL; + goto ERR; + } + if (imgb) { + int ret = libxevd_image_copy(avctx, imgb, frame); + if(ret < 0) { + goto ERR; + } + + frame->pts = avpkt->pts; + *got_frame_ptr = 1; + + // xevd_pull uses pool of objects of type XEVD_IMGB. + // The pool size is equal MAX_PB_SIZE (26), so release object when it is no more needed + imgb->release(imgb); + imgb = NULL; + } else + *got_frame_ptr = 0; + } + + return avpkt->size; + +ERR: + if (imgb) { + imgb->release(imgb); + imgb = NULL; + } + *got_frame_ptr = 0; + + return ret; +} + +/** + * Destroy decoder + * + * @param avctx codec context + * @return 0 on success + */ +static av_cold int libxevd_close(AVCodecContext *avctx) +{ + XevdContext *xectx = avctx->priv_data; + if (xectx->id) { + xevd_delete(xectx->id); + xectx->id = NULL; + } + + return 0; +} + +#define OFFSET(x) offsetof(XevdContext, x) +#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM + +static const AVClass libxevd_class = { + .class_name = "libxevd", + .item_name = av_default_item_name, + .version = LIBAVUTIL_VERSION_INT, +}; + +const FFCodec ff_libxevd_decoder = { + .p.name = "evc", + .p.long_name = NULL_IF_CONFIG_SMALL("EVC / MPEG-5 Essential Video Coding (EVC)"), + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_EVC, + .init = libxevd_init, + FF_CODEC_DECODE_CB(libxevd_decode), + .close = libxevd_close, + .priv_data_size = sizeof(XevdContext), + .p.priv_class = &libxevd_class, + .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_DR1, + .p.profiles = NULL_IF_CONFIG_SMALL(ff_evc_profiles), + .p.wrapper_name = "libxevd", + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_NOT_INIT_THREADSAFE, +}; From patchwork Fri Oct 7 09:13:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawid Kozinski X-Patchwork-Id: 38601 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4d9:b0:9c:f4b:4e41 with SMTP id 25csp173910pzd; Fri, 7 Oct 2022 02:13:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7tntxFe4iDc8u1z79bwiJcz7aIBWWiEkDYA76B2erd4u3iMoVs70Xi3r7rx0Z4PsSH2NKA X-Received: by 2002:a17:907:96a2:b0:782:4072:19da with SMTP id hd34-20020a17090796a200b00782407219damr3303117ejc.398.1665134013946; Fri, 07 Oct 2022 02:13:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665134013; cv=none; d=google.com; s=arc-20160816; b=JYv1wYDYUk/dX8RBsReAYZxXp7l2jg3O0trx4M2mkZJCjZQlsKecXkyRo1qhj0M+6B DQeHA47/R5lv4dYGVXITM5srCdZ57OUXQ+KwE/p87eI+K14Fqx7gKrgoKLB7wOd93ESv f3vKei7VSmk7Xh9unzEJHKP1UZ6zCU+rDp0IR1V33xDncRosX8fbMXx3lKbVz+joD84Z sI8SNYOws4UarpHj5KJ3Q5/+is3EZK2dMPU8p7I6e3MHZI2M/MXTacB3GIr0j4BvXs+1 jUwYzPQM7uyLvl8eX7M177o9jeY3ltRTWFuPi2LZMMYffF2vKDVNAbNHfx0xBk8WTMcz 2OpQ== 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:references:cms-type:mime-version :message-id:date:to:from:dkim-signature:dkim-filter:delivered-to; bh=/JMGEB+TLjsYpZWSi1ucySgpGam2FaMm2djMOmgFfg0=; b=RXYnI5nxdhIF66JXsMW4MM8M9v0vjE7+/uYfq6J/TN4uB1RHvyxB3dpsg0EiyUC01C MyIRYaQ+anjsF5W1zIgNwLuRJeppYjtxz5oK9k/erdfa+d+4amI4V+tutK7lpg2EZwRq yn9GRMrojeQ93RWaFHey4xKZLYl6J9OIJ2n6cIHvTRhR3SBTs1HTbIxLAuqiDR7BqGR2 whvUJQ1wqm2sEgusxwBBLohqronjtTjIs9KDBpKIWQO1ikrnu2Tike2DJi2b9WLDHZMN reKxvc3nd97b9HCiHmhG2pgc+4W7LM5P+V7qJGOQMeFmOjTQiSJ5qiCzJmoJ7BmTOqEt hWOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=tLA4Ezpw; 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=samsung.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id go41-20020a1709070da900b007832270e889si2133054ejc.90.2022.10.07.02.13.33; Fri, 07 Oct 2022 02:13:33 -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=@samsung.com header.s=mail20170921 header.b=tLA4Ezpw; 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=samsung.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 465C668BBDF; Fri, 7 Oct 2022 12:13:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3C34168BBAC for ; Fri, 7 Oct 2022 12:13:29 +0300 (EEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20221007091328euoutp0241627bed80ec387785a47f18cf4bf4fe~bvo8EP1oi2153921539euoutp02p for ; Fri, 7 Oct 2022 09:13:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20221007091328euoutp0241627bed80ec387785a47f18cf4bf4fe~bvo8EP1oi2153921539euoutp02p DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1665134008; bh=DvG8Hpeb1nYilTETutbL4Q9YsLXyaZy8EwDWZLgEn7w=; h=From:To:Cc:Subject:Date:References:From; b=tLA4EzpwKoXttVGIsHoCciPaMTx/mwHD3w7N6LS8a5QorYX/CaUmVgcS0iZNTxLOQ 9gX0PH6FBP64GdyPToMntjiYU9lHPumdreZEdpS8Ba0kqT1H9h4N6PlMTRARKf0yiM pPW5w3WBZ4ICYdK8lJWNns+XsPSqfy6vUuMKj0cU= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20221007091328eucas1p2b6ed9edbd55e53b87e31131a2af27b61~bvo7pTmA33038030380eucas1p2R; Fri, 7 Oct 2022 09:13:28 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 98.61.19378.8BDEF336; Fri, 7 Oct 2022 10:13:28 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20221007091327eucas1p2d574363f0f43a3b8aec36172db404f12~bvo6yEm8x3042430424eucas1p2A; Fri, 7 Oct 2022 09:13:27 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20221007091327eusmtrp187edcc9bbb8be2223b8cd69a4287fca3~bvo6xIJar1626216262eusmtrp1W; Fri, 7 Oct 2022 09:13:27 +0000 (GMT) X-AuditID: cbfec7f5-a35ff70000014bb2-d8-633fedb8094d Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 22.D3.10862.7BDEF336; Fri, 7 Oct 2022 10:13:27 +0100 (BST) Received: from AMDN5164.EU.corp.samsungelectronics.net (unknown [106.210.132.171]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20221007091326eusmtip23b2d24bb67f59f5f0b0ae0afeb41df9c~bvo6XjIAv2037320373eusmtip2C; Fri, 7 Oct 2022 09:13:26 +0000 (GMT) From: Dawid Kozinski To: d.frankiewic@samsung.com, ffmpeg-devel@ffmpeg.org Date: Fri, 7 Oct 2022 11:13:16 +0200 Message-Id: <20221007091316.1300-1-d.kozinski@samsung.com> X-Mailer: git-send-email 2.37.3.windows.1 MIME-Version: 1.0 X-Unsent: 1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDIsWRmVeSWpSXmKPExsWy7djPc7o73tonGyxYzGbx5doXZouV336z WHz7dIbZgdnjz6LNLB59W1YxBjBFcdmkpOZklqUW6dslcGUc7tvLUnBxN2PF7oc3mBsY/3Qw djFycEgImEjM2x7XxcjFISSwglFiwpf3LBDOF0aJjxO/M0I4nxklei5tYO1i5ATrWNb0nhUi sZxRYsG9FjYIp51JYtGpbcwgVWwCuhIvPzxiArFFBEwlTjbvZQOxmQW0Jdbd/Q5mCwvESpzu msMIYrMIqEpcv3YfrJdXwEpiw/r5jBDbNCUmbJnDBBEXlDg58wkLRJxbYt2sS6wQM+UlmrfO ZgY5QkLgJ7tE26V9zBBFLhIrN/xggrCFJV4d38IOYctInJ7cwwIJgGKJQ/0OEGaNxKEf6RAV 1hJvG4+Dg4gZ6IT1u/QhKhwllk6zgTD5JG68FYTYzycxadt0Zogwr0RHmxCEqSLR1ykGMU5K 4umyOVBHeUjM+LGEbQKj4iwkT81C8sgshK0LGJlXMYqnlhbnpqcWG+ellusVJ+YWl+al6yXn 525iBCaI0/+Of93BuOLVR71DjEwcjIcYJTiYlUR4d+60SxbiTUmsrEotyo8vKs1JLT7EKM3B oiTOyzZDK1lIID2xJDU7NbUgtQgmy8TBKdXAtN4zZNeba1O2CqbP3vnz522fiLehl2ublgVW +4ZUnFLtDthVt4Dr7H7r4w3Rk4/yvnYsSVy+MHxxwZvml5d+crpaLNxX+G1i1rknjppH4q0e bmYqiGlS/a/885VA/97Hnn5M7yY0Nh+uZxRYbTArgcHEVfaZvKKs7rN/crcmZF50njnFLotX ffWUAo8aMw5zYa2i/X1TNrvn7khwElkw7SzzxeyDBhfmmTR4HLztUKkk12k2RS1l+/aD5hZC Qfs2n9yxvu0Zv8fFgChbKc9tis5dN+a3PuhYKbv07pIds+2m+mdUHOe/zOu7j5t5w/ulfe++ ZT8Ll3rmuP3+6p2RN2cc79L14OhoEnyz+a7XRyWW4oxEQy3mouJEAPz523F/AwAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrMLMWRmVeSWpSXmKPExsVy+t/xe7rb39onGzycy23x5doXZouV336z WHz7dIbZgdnjz6LNLB59W1YxBjBF6dkU5ZeWpCpk5BeX2CpFG1oY6RlaWugZmVjqGRqbx1oZ mSrp29mkpOZklqUW6dsl6GUc7tvLUnBxN2PF7oc3mBsY/3QwdjFyckgImEgsa3rP2sXIxSEk sJRR4mjLRDaIhJTE0qWLoIqEJf5c6wKLCwm0MkkcXp8IYrMJ6Eq8/PCICcQWETCXuLjuFlg9 s4C2xLq738HqhQWiJa69ug9WwyKgKnH92n1mEJtXwEpiw/r5UPM1JSZsmcMEEReUODnzCQtE nFti3axLrBAz5SWat85mnsDIPwtJ2SwkqQWMTKsYRVJLi3PTc4uN9IoTc4tL89L1kvNzNzEC Q3fbsZ9bdjCufPVR7xAjEwfjIUYJDmYlEd6dO+2ShXhTEiurUovy44tKc1KLDzGaAt06kVlK NDkfGD15JfGGZgamhiZmlgamlmbGSuK8ngUdiUIC6YklqdmpqQWpRTB9TBycUg1MLLnSkRNU z/2rTtmWr5ZdsEX/qLG7jNQPrtTkvy+XyYTz8n2KmWcQc/mgdYPpg7pbNha8CcaG+q+u3uHp PrU+SMAszp5P/HXTl/TSmpNcdz7Mn17edeieKHNl6/dvGcaK52XT42X/LVW+NHPXv3mL7+p5 s59Od6r1e7H10s5/Bk+tFm4LXXvX1YertOfYyvS/wgve1E4u6lOerOVU1Fq2XJ+/+7Xj98VM nJM0H/JXXbPqkb1/0Iy/UvfkO47sS7fjO0qWfDX5v9i3YvI0Xnmp+BkbTcvZjkicvOSnWljo 1xJ0q5LJ+Jb43U2FfX7Gs1q3bt7GELzE/L1bQ8a9zJvGTPoqNr18HaveFTDYlSixFGckGmox FxUnAgBbPCW45gIAAA== X-CMS-MailID: 20221007091327eucas1p2d574363f0f43a3b8aec36172db404f12 X-Msg-Generator: CA X-RootMTR: 20221007091327eucas1p2d574363f0f43a3b8aec36172db404f12 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20221007091327eucas1p2d574363f0f43a3b8aec36172db404f12 References: Subject: [FFmpeg-devel] [PATCH v13 7/9] avformat/mov_muxer: Extended MOV muxer to handle EVC video content 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: Dawid Kozinski Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: UMLFchYj/1+z - Changes in mov_write_video_tag function to handle EVC elementary stream - Provided structure EVCDecoderConfigurationRecord that specifies the decoder configuration information for ISO/IEC 23094-1 video content Signed-off-by: Dawid Kozinski --- libavformat/Makefile | 2 +- libavformat/evc.c | 455 ++++++++++++++++++++++++++++++++++++++++ libavformat/evc.h | 44 ++++ libavformat/isom_tags.c | 2 + libavformat/movenc.c | 35 +++- 5 files changed, 536 insertions(+), 2 deletions(-) create mode 100644 libavformat/evc.c create mode 100644 libavformat/evc.h diff --git a/libavformat/Makefile b/libavformat/Makefile index af175d2097..6ae5056c61 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -363,7 +363,7 @@ OBJS-$(CONFIG_MOV_DEMUXER) += mov.o mov_chan.o mov_esds.o \ OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o vpcc.o \ movenchint.o mov_chan.o rtp.o \ movenccenc.o movenc_ttml.o rawutils.o \ - dovi_isom.o + dovi_isom.o evc.o OBJS-$(CONFIG_MP2_MUXER) += rawenc.o OBJS-$(CONFIG_MP3_DEMUXER) += mp3dec.o replaygain.o OBJS-$(CONFIG_MP3_MUXER) += mp3enc.o rawenc.o id3v2enc.o diff --git a/libavformat/evc.c b/libavformat/evc.c new file mode 100644 index 0000000000..72c2759924 --- /dev/null +++ b/libavformat/evc.c @@ -0,0 +1,455 @@ +/* + * EVC helper functions for muxers + * Copyright (c) 2022 Dawid Kozinski + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/intreadwrite.h" +#include "libavcodec/get_bits.h" +#include "libavcodec/golomb.h" +#include "libavcodec/evc.h" +#include "avformat.h" +#include "avio.h" +#include "evc.h" +#include "avio_internal.h" + +// The length field that indicates the length in bytes of the following NAL unit is configured to be of 4 bytes +#define EVC_NAL_UNIT_LENGTH_BYTE (4) /* byte */ +#define EVC_NAL_HEADER_SIZE (2) /* byte */ + +// @see ISO/IEC 14496-15:2021 Coding of audio-visual objects - Part 15: section 12.3.3.1 +enum { + SPS_INDEX, + PPS_INDEX, + APS_INDEX, + SEI_INDEX, + NB_ARRAYS +}; + +// rpl structure +typedef struct RefPicListStruct { + int poc; + int tid; + int ref_pic_num; + int ref_pic_active_num; + int ref_pics[EVC_MAX_NUM_REF_PICS]; + char pic_type; + +} RefPicListStruct; + +// The sturcture reflects SPS RBSP(raw byte sequence payload) layout +// @see ISO_IEC_23094-1 section 7.3.2.1 +// +// The following descriptors specify the parsing process of each element +// u(n) - unsigned integer using n bits +// ue(v) - unsigned integer 0-th order Exp_Golomb-coded syntax element with the left bit first +typedef struct EVCSPS { + int sps_seq_parameter_set_id; // ue(v) + int profile_idc; // u(8) + int level_idc; // u(8) + int toolset_idc_h; // u(32) + int toolset_idc_l; // u(32) + int chroma_format_idc; // ue(v) + int pic_width_in_luma_samples; // ue(v) + int pic_height_in_luma_samples; // ue(v) + int bit_depth_luma_minus8; // ue(v) + int bit_depth_chroma_minus8; // ue(v) + + // @note + // Currently the structure does not reflect the entire SPS RBSP layout. + // It contains only the fields that are necessary to read from the NAL unit all the values + // necessary for the correct initialization of EVCDecoderConfigurationRecord + + // @note + // If necessary, add the missing fields to the structure to reflect + // the contents of the entire NAL unit of the SPS type + +} EVCSPS; + +// @see ISO/IEC 14496-15:2021 Coding of audio-visual objects - Part 15: section 12.3.3.3 +typedef struct EVCNALUnitArray { + uint8_t array_completeness; // when equal to 1 indicates that all NAL units of the given type are in the following array + uint8_t NAL_unit_type; // indicates the type of the NAL units in the following array + uint16_t numNalus; // indicates the number of NAL units of the indicated type + uint16_t *nalUnitLength; // indicates the length in bytes of the NAL unit + uint8_t **nalUnit; // contains an SPS, PPS, APS or a SEI NAL unit, as specified in ISO/IEC 23094-1 +} EVCNALUnitArray; + +/** + * @brief Specifies the decoder configuration information for ISO/IEC 23094-1 video content. + * @see ISO/IEC 14496-15:2021 Coding of audio-visual objects - Part 15: section 12.3.3.2 + * Carriage of network abstraction layer (NAL) unit structured video in the ISO base media file format + */ +typedef struct EVCDecoderConfigurationRecord { + uint8_t configurationVersion; // 8 bits + uint8_t profile_idc; // 8 bits + uint8_t level_idc; // 8 bits + uint32_t toolset_idc_h; // 32 bits + uint32_t toolset_idc_l; // 32 bits + uint8_t chroma_format_idc; // 2 bits + uint8_t bit_depth_luma_minus8; // 3 bits + uint8_t bit_depth_chroma_minus8; // 3 bits + uint16_t pic_width_in_luma_samples; // 16 bits + uint16_t pic_height_in_luma_samples; // 16 bits + uint8_t reserved; // 6 bits '000000'b + uint8_t lengthSizeMinusOne; // 2 bits + uint8_t num_of_arrays; // 8 bits + EVCNALUnitArray arrays[NB_ARRAYS]; +} EVCDecoderConfigurationRecord; + +typedef struct NALU { + int offset; + uint32_t size; +} NALU; + +typedef struct NALUList { + NALU *nalus; + unsigned nalus_array_size; + unsigned nb_nalus; ///< valid entries in nalus +} NALUList; + +static int get_nalu_type(const uint8_t *bits, int bits_size) +{ + int unit_type_plus1 = 0; + + if (bits_size >= EVC_NAL_HEADER_SIZE) { + unsigned char *p = (unsigned char *)bits; + // forbidden_zero_bit + if ((p[0] & 0x80) != 0) + return -1; + + // nal_unit_type + unit_type_plus1 = (p[0] >> 1) & 0x3F; + } + + return unit_type_plus1 - 1; +} + +static uint32_t read_nal_unit_length(const uint8_t *bits, int bits_size) +{ + uint32_t nalu_len = 0; + + if (bits_size >= EVC_NAL_UNIT_LENGTH_BYTE) { + + int t = 0; + for (int i = 0; i < EVC_NAL_UNIT_LENGTH_BYTE; i++) + t = (t << 8) | bits[i]; + + nalu_len = t; + if (nalu_len == 0) + return 0; + } + + return nalu_len; +} + +// @see ISO_IEC_23094-1 (7.3.2.1 SPS RBSP syntax) +static int evcc_parse_sps(const uint8_t *bs, int bs_size, EVCDecoderConfigurationRecord *evcc) +{ + GetBitContext gb; + int sps_seq_parameter_set_id; + EVCSPS sps; + + if (init_get_bits8(&gb, bs, bs_size) < 0) + return 0; + + sps.sps_seq_parameter_set_id = get_ue_golomb(&gb); + + if (sps_seq_parameter_set_id >= EVC_MAX_SPS_COUNT) + return 0; + + // the Baseline profile is indicated by profile_idc eqal to 0 + // the Main profile is indicated by profile_idc eqal to 1 + sps.profile_idc = get_bits(&gb, 8); + + sps.level_idc = get_bits(&gb, 8); + + sps.toolset_idc_h = get_bits(&gb, 32); + sps.toolset_idc_l = get_bits(&gb, 32); + + // 0 - monochrome + // 1 - 4:2:0 + // 2 - 4:2:2 + // 3 - 4:4:4 + sps.chroma_format_idc = get_ue_golomb(&gb); + + sps.pic_width_in_luma_samples = get_ue_golomb(&gb); + sps.pic_height_in_luma_samples = get_ue_golomb(&gb); + + sps.bit_depth_luma_minus8 = get_ue_golomb(&gb); + sps.bit_depth_chroma_minus8 = get_ue_golomb(&gb); + + evcc->profile_idc = sps.profile_idc; + evcc->level_idc = sps.level_idc; + evcc->toolset_idc_h = sps.toolset_idc_h; + evcc->toolset_idc_l = sps.toolset_idc_l; + evcc->chroma_format_idc = sps.chroma_format_idc; + evcc->bit_depth_luma_minus8 = sps.bit_depth_luma_minus8; + evcc->bit_depth_chroma_minus8 = sps.bit_depth_chroma_minus8; + evcc->pic_width_in_luma_samples = sps.pic_width_in_luma_samples; + evcc->pic_height_in_luma_samples = sps.pic_height_in_luma_samples; + + return 0; +} + +// @see ISO/IEC 14496-15:2021 Coding of audio-visual objects - Part 15: section 12.3.3.3 +static int evcc_array_add_nal_unit(const uint8_t *nal_buf, uint32_t nal_size, + uint8_t nal_type, int ps_array_completeness, + EVCNALUnitArray *array) +{ + int ret; + uint16_t numNalus = array->numNalus; + + ret = av_reallocp_array(&array->nalUnit, numNalus + 1, sizeof(uint8_t *)); + if (ret < 0) + return ret; + + ret = av_reallocp_array(&array->nalUnitLength, numNalus + 1, sizeof(uint16_t)); + if (ret < 0) + return ret; + + array->nalUnit [numNalus] = (uint8_t*)nal_buf; + array->nalUnitLength[numNalus] = nal_size; + array->NAL_unit_type = nal_type; + array->numNalus++; + + /* + * When the sample entry name is 'evc1', the default and mandatory value of + * array_completeness is 1 for arrays of all types of parameter sets, and 0 + * for all other arrays. + */ + if (nal_type == EVC_SPS_NUT || nal_type == EVC_PPS_NUT || nal_type == EVC_APS_NUT) + array->array_completeness = ps_array_completeness; + + return 0; +} + +static void evcc_init(EVCDecoderConfigurationRecord *evcc) +{ + memset(evcc, 0, sizeof(EVCDecoderConfigurationRecord)); + evcc->configurationVersion = 1; + evcc->lengthSizeMinusOne = 3; // 4 bytes +} + +static void evcc_close(EVCDecoderConfigurationRecord *evcc) +{ + for (unsigned i = 0; i < FF_ARRAY_ELEMS(evcc->arrays); i++) { + EVCNALUnitArray *const array = &evcc->arrays[i]; + array->numNalus = 0; + av_freep(&array->nalUnit); + av_freep(&array->nalUnitLength); + } +} + +static int evcc_write(AVIOContext *pb, EVCDecoderConfigurationRecord *evcc) +{ + uint16_t sps_count; + + av_log(NULL, AV_LOG_TRACE, "configurationVersion: %"PRIu8"\n", + evcc->configurationVersion); + av_log(NULL, AV_LOG_TRACE, "profile_idc: %"PRIu8"\n", + evcc->profile_idc); + av_log(NULL, AV_LOG_TRACE, "level_idc: %"PRIu8"\n", + evcc->level_idc); + av_log(NULL, AV_LOG_TRACE, "toolset_idc_h: %"PRIu32"\n", + evcc->toolset_idc_h); + av_log(NULL, AV_LOG_TRACE, "toolset_idc_l: %"PRIu32"\n", + evcc->toolset_idc_l); + av_log(NULL, AV_LOG_TRACE, "chroma_format_idc: %"PRIu8"\n", + evcc->chroma_format_idc); + av_log(NULL, AV_LOG_TRACE, "bit_depth_luma_minus8: %"PRIu8"\n", + evcc->bit_depth_luma_minus8); + av_log(NULL, AV_LOG_TRACE, "bit_depth_chroma_minus8: %"PRIu8"\n", + evcc->bit_depth_chroma_minus8); + av_log(NULL, AV_LOG_TRACE, "pic_width_in_luma_samples: %"PRIu16"\n", + evcc->pic_width_in_luma_samples); + av_log(NULL, AV_LOG_TRACE, "pic_height_in_luma_samples: %"PRIu16"\n", + evcc->pic_height_in_luma_samples); + av_log(NULL, AV_LOG_TRACE, "lengthSizeMinusOne: %"PRIu8"\n", + evcc->lengthSizeMinusOne); + av_log(NULL, AV_LOG_TRACE, "num_of_arrays: %"PRIu8"\n", + evcc->num_of_arrays); + for (unsigned i = 0; i < FF_ARRAY_ELEMS(evcc->arrays); i++) { + const EVCNALUnitArray *const array = &evcc->arrays[i]; + + if(array->numNalus == 0) + continue; + + av_log(NULL, AV_LOG_TRACE, "array_completeness[%"PRIu8"]: %"PRIu8"\n", + i, array->array_completeness); + av_log(NULL, AV_LOG_TRACE, "NAL_unit_type[%"PRIu8"]: %"PRIu8"\n", + i, array->NAL_unit_type); + av_log(NULL, AV_LOG_TRACE, "numNalus[%"PRIu8"]: %"PRIu16"\n", + i, array->numNalus); + for ( unsigned j = 0; j < array->numNalus; j++) + av_log(NULL, AV_LOG_TRACE, + "nalUnitLength[%"PRIu8"][%"PRIu16"]: %"PRIu16"\n", + i, j, array->nalUnitLength[j]); + } + + /* + * We need at least one SPS. + */ + sps_count = evcc->arrays[SPS_INDEX].numNalus; + if (!sps_count || sps_count > EVC_MAX_SPS_COUNT) + return AVERROR_INVALIDDATA; + + if (!sps_count || sps_count > EVC_MAX_SPS_COUNT) + return AVERROR_INVALIDDATA; + + /* unsigned int(8) configurationVersion = 1; */ + avio_w8(pb, evcc->configurationVersion); + + /* unsigned int(8) profile_idc */ + avio_w8(pb, evcc->profile_idc); + + /* unsigned int(8) profile_idc */ + avio_w8(pb, evcc->level_idc); + + /* unsigned int(32) toolset_idc_h */ + avio_wb32(pb, evcc->toolset_idc_h); + + /* unsigned int(32) toolset_idc_l */ + avio_wb32(pb, evcc->toolset_idc_l); + + /* + * unsigned int(2) chroma_format_idc; + * unsigned int(3) bit_depth_luma_minus8; + * unsigned int(3) bit_depth_chroma_minus8; + */ + avio_w8(pb, evcc->chroma_format_idc << 6 | + evcc->bit_depth_luma_minus8 << 3 | + evcc->bit_depth_chroma_minus8); + + /* unsigned int(16) pic_width_in_luma_samples; */ + avio_wb16(pb, evcc->pic_width_in_luma_samples); + + /* unsigned int(16) pic_width_in_luma_samples; */ + avio_wb16(pb, evcc->pic_height_in_luma_samples); + + /* + * bit(6) reserved = '111111'b; + * unsigned int(2) chromaFormat; + */ + avio_w8(pb, evcc->lengthSizeMinusOne | 0xfc); + + /* unsigned int(8) numOfArrays; */ + avio_w8(pb, evcc->num_of_arrays); + + for (unsigned i = 0; i < FF_ARRAY_ELEMS(evcc->arrays); i++) { + const EVCNALUnitArray *const array = &evcc->arrays[i]; + + if (!array->numNalus) + continue; + + /* + * bit(1) array_completeness; + * unsigned int(1) reserved = 0; + * unsigned int(6) NAL_unit_type; + */ + avio_w8(pb, array->array_completeness << 7 | + array->NAL_unit_type & 0x3f); + + /* unsigned int(16) numNalus; */ + avio_wb16(pb, array->numNalus); + + for (unsigned j = 0; j < array->numNalus; j++) { + /* unsigned int(16) nalUnitLength; */ + avio_wb16(pb, array->nalUnitLength[j]); + + /* bit(8*nalUnitLength) nalUnit; */ + avio_write(pb, array->nalUnit[j], + array->nalUnitLength[j]); + } + } + + return 0; +} + +int ff_isom_write_evcc(AVIOContext *pb, const uint8_t *data, + int size, int ps_array_completeness) +{ + EVCDecoderConfigurationRecord evcc; + int nalu_type; + size_t nalu_size; + int bytes_to_read = size; + unsigned array_index; + + int ret = 0; + + if (size < 8) { + /* We can't write a valid evcC from the provided data */ + return AVERROR_INVALIDDATA; + } else if (*data == 1) { + /* Data is already evcC-formatted */ + avio_write(pb, data, size); + return 0; + } + + evcc_init(&evcc); + + while (bytes_to_read > EVC_NAL_UNIT_LENGTH_BYTE) { + nalu_size = read_nal_unit_length(data, EVC_NAL_UNIT_LENGTH_BYTE); + if (nalu_size == 0) break; + + data += EVC_NAL_UNIT_LENGTH_BYTE; + bytes_to_read -= EVC_NAL_UNIT_LENGTH_BYTE; + + if (bytes_to_read < nalu_size) break; + + nalu_type = get_nalu_type(data, bytes_to_read); + + switch (nalu_type) { + case EVC_SPS_NUT: + array_index = SPS_INDEX; + break; + case EVC_PPS_NUT: + array_index = PPS_INDEX; + break; + case EVC_APS_NUT: + array_index = APS_INDEX; + break; + case EVC_SEI_NUT: + array_index = SEI_INDEX; + break; + default: + break; + } + + ret = evcc_array_add_nal_unit(data, nalu_size, nalu_type, ps_array_completeness, &(evcc.arrays[array_index])); + if (ret < 0) + goto end; + if (evcc.arrays[array_index].numNalus == 1) + evcc.num_of_arrays++; + + if(nalu_type == EVC_SPS_NUT) { + ret = evcc_parse_sps(data, nalu_size, &evcc); + if (ret < 0) + goto end; + } + + data += nalu_size; + bytes_to_read -= nalu_size; + } + + ret = evcc_write(pb, &evcc); + +end: + evcc_close(&evcc); + return ret; +} diff --git a/libavformat/evc.h b/libavformat/evc.h new file mode 100644 index 0000000000..db56275fd8 --- /dev/null +++ b/libavformat/evc.h @@ -0,0 +1,44 @@ +/* + * EVC helper functions for muxers + * Copyright (c) 2022 Dawid Kozinski + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFORMAT_EVC_H +#define AVFORMAT_EVC_H + +#include +#include "libavutil/rational.h" +#include "avio.h" + + + +/** + * Writes EVC sample metadata to the provided AVIOContext. + * + * @param pb pointer to the AVIOContext where the evc sample metadata shall be written + * @param buf input data buffer + * @param size size in bytes of the input data buffer + * @param ps_array_completeness @see ISO/IEC 14496-15:2021 Coding of audio-visual objects - Part 15: section 12.3.3.3 + * + * @return 0 in case of success, a negative error code in case of failure + */ +int ff_isom_write_evcc(AVIOContext *pb, const uint8_t *data, + int size, int ps_array_completeness); + +#endif // AVFORMAT_EVC_H diff --git a/libavformat/isom_tags.c b/libavformat/isom_tags.c index e2b80405cc..8ca740cab1 100644 --- a/libavformat/isom_tags.c +++ b/libavformat/isom_tags.c @@ -147,6 +147,8 @@ const AVCodecTag ff_codec_movvideo_tags[] = { { AV_CODEC_ID_H264, MKTAG('d', 'v', 'a', '1') }, /* AVC-based Dolby Vision derived from avc1 */ { AV_CODEC_ID_H264, MKTAG('d', 'v', 'a', 'v') }, /* AVC-based Dolby Vision derived from avc3 */ + { AV_CODEC_ID_EVC, MKTAG('e', 'v', 'c', '1') }, /* EVC/MPEG-5 */ + { AV_CODEC_ID_VP8, MKTAG('v', 'p', '0', '8') }, /* VP8 */ { AV_CODEC_ID_VP9, MKTAG('v', 'p', '0', '9') }, /* VP9 */ { AV_CODEC_ID_AV1, MKTAG('a', 'v', '0', '1') }, /* AV1 */ diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 754f95912a..6f782bd536 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -35,6 +35,7 @@ #include "isom.h" #include "av1.h" #include "avc.h" +#include "evc.h" #include "libavcodec/ac3_parser_internal.h" #include "libavcodec/dnxhddata.h" #include "libavcodec/flac.h" @@ -1392,6 +1393,21 @@ static int mov_write_hvcc_tag(AVIOContext *pb, MOVTrack *track) return update_size(pb, pos); } +static int mov_write_evcc_tag(AVIOContext *pb, MOVTrack *track) +{ + int64_t pos = avio_tell(pb); + + avio_wb32(pb, 0); + ffio_wfourcc(pb, "evcC"); + + if (track->tag == MKTAG('e','v','c','1')) + ff_isom_write_evcc(pb, track->vos_data, track->vos_len, 1); + else + ff_isom_write_evcc(pb, track->vos_data, track->vos_len, 0); + + return update_size(pb, pos); +} + /* also used by all avid codecs (dv, imx, meridien) and their variants */ static int mov_write_avid_tag(AVIOContext *pb, MOVTrack *track) { @@ -1641,6 +1657,16 @@ static int mov_get_h264_codec_tag(AVFormatContext *s, MOVTrack *track) return tag; } +static int mov_get_evc_codec_tag(AVFormatContext *s, MOVTrack *track) +{ + int tag = track->par->codec_tag; + + if (!tag) + tag = MKTAG('e', 'v', 'c', 'i'); + + return tag; +} + static const struct { enum AVPixelFormat pix_fmt; uint32_t tag; @@ -1722,6 +1748,8 @@ static unsigned int mov_get_codec_tag(AVFormatContext *s, MOVTrack *track) tag = mov_get_mpeg2_xdcam_codec_tag(s, track); else if (track->par->codec_id == AV_CODEC_ID_H264) tag = mov_get_h264_codec_tag(s, track); + else if (track->par->codec_id == AV_CODEC_ID_EVC) + tag = mov_get_evc_codec_tag(s, track); else if (track->par->codec_id == AV_CODEC_ID_DNXHD) tag = mov_get_dnxhd_codec_tag(s, track); else if (track->par->codec_type == AVMEDIA_TYPE_VIDEO) { @@ -2290,6 +2318,9 @@ static int mov_write_video_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex mov_write_avcc_tag(pb, track); if (track->mode == MODE_IPOD) mov_write_uuid_tag_ipod(pb); + } + else if (track->par->codec_id ==AV_CODEC_ID_EVC) { + mov_write_evcc_tag(pb, track); } else if (track->par->codec_id == AV_CODEC_ID_VP9) { mov_write_vpcc_tag(mov->fc, pb, track); } else if (track->par->codec_id == AV_CODEC_ID_AV1) { @@ -6033,7 +6064,8 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) if ((par->codec_id == AV_CODEC_ID_DNXHD || par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_HEVC || - par->codec_id == AV_CODEC_ID_TRUEHD) && !trk->vos_len && + par->codec_id == AV_CODEC_ID_TRUEHD || + par->codec_id == AV_CODEC_ID_EVC) && !trk->vos_len && !TAG_IS_AVCI(trk->tag)) { /* copy frame to create needed atoms */ trk->vos_len = size; @@ -7692,6 +7724,7 @@ static const AVCodecTag codec_mp4_tags[] = { { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '3') }, { AV_CODEC_ID_HEVC, MKTAG('h', 'e', 'v', '1') }, { AV_CODEC_ID_HEVC, MKTAG('h', 'v', 'c', '1') }, + { AV_CODEC_ID_EVC, MKTAG('e', 'v', 'c', '1') }, { AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', 'p', '4', 'v') }, { AV_CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', '4', 'v') }, { AV_CODEC_ID_MJPEG, MKTAG('m', 'p', '4', 'v') }, From patchwork Fri Oct 7 09:13:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawid Kozinski X-Patchwork-Id: 38596 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4d9:b0:9c:f4b:4e41 with SMTP id 25csp173989pzd; Fri, 7 Oct 2022 02:13:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM74DypwsEZR7fWB25r54LNoIqI0hH5toiwdTdxWgRvj7bL4X6SPHb5YMNaDtTq07RHTaZzl X-Received: by 2002:a17:907:2ced:b0:773:6f77:f10f with SMTP id hz13-20020a1709072ced00b007736f77f10fmr3263981ejc.34.1665134034546; Fri, 07 Oct 2022 02:13:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665134034; cv=none; d=google.com; s=arc-20160816; b=cqkehCrhtmRCjTXFuFEsGBES2suCG2efQ6K9fTrToUqK8z6qh0/fJJ8v5bwTuOPpn9 54UvgHd4OaOflsdSIkJx9BpGrjCQexF6xUv3hD2usT7H56ulZHga7bkYtnmB4VKZTEqB p+zhacHdLpOPR7FBQ2026EyblIOSNBPCX71Tdkr+d2Uu9fmmwzymutIEmGxHuckkNSAe Zs3TjS5RC+pfhAB3mXnfu2p9F6IeDYOFkP7UlpZQbAHk3IesZtaYwKr+Jci0Dgy7cXs8 /CVwjdvQLr46l5E+TfeZjEA5JimLfO90sU1pwHXnv6UX0GSh/GANJ8rtkdvtK0SQs6HN 3qXQ== 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:references:cms-type:mime-version :message-id:date:to:from:dkim-signature:dkim-filter:delivered-to; bh=kmMvGyuenR+nBfHnPWkJPlV2A3VePVP+2WKfAAn5GOI=; b=UWoplnCI91N8tUo2w5/b3D0fkQZiypUpX65SRn8PNk9ulrVD9dyAKctZpYcD3DU23p BT6j5LcKWSr9OK5sl/p1KQNW30MZBUawhpmu+W0VBxbnHQ1yclhaXTITB2wdKSqtjxp6 9PpSUgGxceZYs53wkcRr/eYsmlF0Q4CMS2/cdrf0ZEkFi8XbfkuZ6WgOQ7mH+eMHUyYP QwlvGIapOo9HR3iLhGMj6QgYcu3i/9mT+POgtlEHaIM6wLPHOLWBlUZ0BXaa6hswnLYZ Emioj1jUNgnmn9qAJbD8yFYnYIcnGqETh0bM+9eyRv6gZuvfSniZMaVdPmZYSm83nOx3 2M3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=gMiomhGJ; 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=samsung.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i33-20020a0564020f2100b004551a7e54acsi1618726eda.74.2022.10.07.02.13.54; Fri, 07 Oct 2022 02:13: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=@samsung.com header.s=mail20170921 header.b=gMiomhGJ; 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=samsung.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 580C568BC13; Fri, 7 Oct 2022 12:13:52 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C006E68BB66 for ; Fri, 7 Oct 2022 12:13:50 +0300 (EEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20221007091350euoutp0209f4568a0b3110b3d16e017def07e5e2~bvpQLEhdT2052420524euoutp02Y for ; Fri, 7 Oct 2022 09:13:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20221007091350euoutp0209f4568a0b3110b3d16e017def07e5e2~bvpQLEhdT2052420524euoutp02Y DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1665134030; bh=f2mdicmifmazMTixqAy1DHb5CP7N/A0FmCwGogj0lpM=; h=From:To:Cc:Subject:Date:References:From; b=gMiomhGJTy6xUX3g27/L8qzgRkY8Uwx3X2O/9sedKLg7ZfxqyQqsyLXItSnwMqvnl iIlUyrqTkH++kBz7nYqqQK0qDNUQRx3uHIfQm1LvxceapUEMWwemHt9GITo1bhMlID eBxKo3HyoWlJv66pccppdyFIvdsASuRTCKoaX14M= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20221007091349eucas1p2d5b2fc68e39acd7488a3a4641e5e02c2~bvpP0yw9a3040430404eucas1p2e; Fri, 7 Oct 2022 09:13:49 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 09.71.19378.DCDEF336; Fri, 7 Oct 2022 10:13:49 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20221007091349eucas1p21f7c21fb2a3fea3ef5696b337e38263f~bvpPZSHLu3038030380eucas1p2m; Fri, 7 Oct 2022 09:13:49 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20221007091349eusmtrp2e00fc5fad3e4fe99ca67c5d2b33b300a~bvpPYqvnH0179201792eusmtrp2U; Fri, 7 Oct 2022 09:13:49 +0000 (GMT) X-AuditID: cbfec7f5-a35ff70000014bb2-1d-633fedcd8a18 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 06.7F.07473.DCDEF336; Fri, 7 Oct 2022 10:13:49 +0100 (BST) Received: from AMDN5164.EU.corp.samsungelectronics.net (unknown [106.210.132.171]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20221007091349eusmtip2816b2bb42c6d7f179a38e8a27b2f3f76~bvpPDlQkj2373723737eusmtip2y; Fri, 7 Oct 2022 09:13:49 +0000 (GMT) From: Dawid Kozinski To: d.frankiewic@samsung.com, ffmpeg-devel@ffmpeg.org Date: Fri, 7 Oct 2022 11:13:39 +0200 Message-Id: <20221007091339.897-1-d.kozinski@samsung.com> X-Mailer: git-send-email 2.37.3.windows.1 MIME-Version: 1.0 X-Unsent: 1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrFIsWRmVeSWpSXmKPExsWy7djP87pn39onG/ybbWTx5doXZouV336z WHz7dIbZgdnjz6LNLB59W1YxBjBFcdmkpOZklqUW6dslcGV0btvBVjCNr+LFh1lMDYyvuLoY OTkkBEwkmro+sXYxcnEICaxglPiwfR4LhPOFUWLxr0uMEM5nRokp0x6zdzFygLUsOhIMEV/O KPF063WoonYmiaOPHrOAzGUT0JV4+eERE4gtImAqcbJ5LxuIzSygLbHu7ncwW1ggUeLK+tlg 9SwCqhLTTt9nBFnAK2Ap0d/rCXGepsSELXPAxvAKCEqcnPmEBSLOLbFu1iVWiJHyEs1bZzOD 3CAh8Jdd4umye6wQRS4SV548ZIewhSVeHd8CZctI/N85nwnimWKJQ/0OEGaNxKEf6RAV1hJv G4+DXcMMdML6XfoQYUeJVTuWsEBU80nceCsIcQCfxKRt05khwrwSHW1CEKaKRF+nGESjFNBV c5ghbA+Jvc1r2CYwKs5C8tUsJJ/MQli7gJF5FaN4amlxbnpqsXFearlecWJucWleul5yfu4m RmByOP3v+NcdjCtefdQ7xMjEwXiIUYKDWUmEd+dOu2Qh3pTEyqrUovz4otKc1OJDjNIcLEri vGwztJKFBNITS1KzU1MLUotgskwcnFINTE19kmtk/Er1BQSO7OP2+jk9aBpvefo69xkPtu1/ fc54v0+P9JzmGXOmG9tn+v87uIG3b2lUvOGZS64Pz2dXXJEr2b2rPWWrU0q+TgG73p8q26J3 f6yXbJNZwaiV3NtV7h32Jld4Vr/Cb9/+L+Lr/q2pFlJI/tXw+P6vqPVn1Ph1QtWSSjSOMP5e rty8dJp2xmwzCx/pW6dlvz/oKzmkv4xbXyq6N15mx9Vvbgkas7s+89zdGjaP5dFiQRaLtUZ2 dqysmw+/LfV6z3Vxq5pfyJW4n563cvwXTu6bLLhUf89/naYKxYYZMcpGL6Mk5oefCvaqYnSP +lD1YLn/mTAFbx/eJS7bRMUZq+ac31GhxFKckWioxVxUnAgAm9YEq30DAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrPLMWRmVeSWpSXmKPExsVy+t/xe7pn39onG1y7I2rx5doXZouV336z WHz7dIbZgdnjz6LNLB59W1YxBjBF6dkU5ZeWpCpk5BeX2CpFG1oY6RlaWugZmVjqGRqbx1oZ mSrp29mkpOZklqUW6dsl6GV0btvBVjCNr+LFh1lMDYyvuLoYOTgkBEwkFh0J7mLk4hASWMoo 8bV3B2sXIydQXEpi6dJFjBC2sMSfa11sILaQQCuTRPsjCxCbTUBX4uWHR0wgtoiAucTFdbfA 6pkFtCXW3f0OVi8sEC/x7l8DC4jNIqAqMe30fUaQvbwClhL9vZ4Q4zUlJmyZAzaGV0BQ4uTM JywQcW6JdbMusUKMlJdo3jqbeQIj/ywkZbOQpBYwMq1iFEktLc5Nzy021CtOzC0uzUvXS87P 3cQIDNltx35u3sE479VHvUOMTByMhxglOJiVRHh37rRLFuJNSaysSi3Kjy8qzUktPsRoCnTq RGYp0eR8YNTklcQbmhmYGpqYWRqYWpoZK4nzehZ0JAoJpCeWpGanphakFsH0MXFwSjUwucV4 bUzvSUiaLSXlf6r02v3SaP6XTdZBAooX9P8pqR9RkEqMbqp21rv4obK97ktPBc/lDUwnJZ83 bD+qcfK8kbaz1hTOGWYzl+mphayZcUxKLlLzvpyh/W8/o+9RaW4Cf0Pn/9pueLdYckfEvSM6 +tu7tz/TVGQLELIO0jZ5L2gn4ZZ64KWNnXnI/XOMS4417kgSf+06zy9H55ns3JTk0LrO0/Nl soRiF/lv2vSbaUn/wR2n2T9rPtQMXfhogrlW3T2dup/Vt6YqvtvA/53Hh2G6zlX3sKvW/xkP Hcx4abum8Ozhya5Jvz5Hpf56V/hv+p3e1/dfsl8z1P27NzX8YWHY9a2HXa90HlG4FTVdiaU4 I9FQi7moOBEANIS74+ICAAA= X-CMS-MailID: 20221007091349eucas1p21f7c21fb2a3fea3ef5696b337e38263f X-Msg-Generator: CA X-RootMTR: 20221007091349eucas1p21f7c21fb2a3fea3ef5696b337e38263f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20221007091349eucas1p21f7c21fb2a3fea3ef5696b337e38263f References: Subject: [FFmpeg-devel] [PATCH v13 8/9] avformat/mov_demuxer: Extended MOV demuxer to handle EVC video content 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: Dawid Kozinski Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: bnfZogrAy1Ei - Added evc extension to the list of extensions for ff_mov_demuxer Signed-off-by: Dawid Kozinski --- libavformat/demux.c | 1 + libavformat/mov.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/demux.c b/libavformat/demux.c index 2dfd82a63c..f3ebe4d09b 100644 --- a/libavformat/demux.c +++ b/libavformat/demux.c @@ -120,6 +120,7 @@ static int set_codec_from_probe_data(AVFormatContext *s, AVStream *st, { "mp3", AV_CODEC_ID_MP3, AVMEDIA_TYPE_AUDIO }, { "mpegvideo", AV_CODEC_ID_MPEG2VIDEO, AVMEDIA_TYPE_VIDEO }, { "truehd", AV_CODEC_ID_TRUEHD, AVMEDIA_TYPE_AUDIO }, + { "evc", AV_CODEC_ID_EVC, AVMEDIA_TYPE_VIDEO }, { 0 } }; int score; diff --git a/libavformat/mov.c b/libavformat/mov.c index 1f436e21d6..435c9d905e 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2502,6 +2502,7 @@ static int mov_finalize_stsd_codec(MOVContext *c, AVIOContext *pb, case AV_CODEC_ID_VP9: sti->need_parsing = AVSTREAM_PARSE_FULL; break; + case AV_CODEC_ID_EVC: case AV_CODEC_ID_AV1: /* field_order detection of H264 requires parsing */ case AV_CODEC_ID_H264: @@ -9130,7 +9131,7 @@ const AVInputFormat ff_mov_demuxer = { .long_name = NULL_IF_CONFIG_SMALL("QuickTime / MOV"), .priv_class = &mov_class, .priv_data_size = sizeof(MOVContext), - .extensions = "mov,mp4,m4a,3gp,3g2,mj2,psp,m4b,ism,ismv,isma,f4v,avif", + .extensions = "mov,mp4,m4a,3gp,3g2,mj2,psp,m4b,ism,ismv,isma,f4v,avif,evc", .flags_internal = FF_FMT_INIT_CLEANUP, .read_probe = mov_probe, .read_header = mov_read_header, From patchwork Fri Oct 7 09:14:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawid Kozinski X-Patchwork-Id: 38602 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4d9:b0:9c:f4b:4e41 with SMTP id 25csp174117pzd; Fri, 7 Oct 2022 02:14:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5xaLIs/W5UgBGspwAPFZIG4VutKXrQ5FfUJIJI3A191r4lIcm0elxGtWbXE6gAH4CtvONn X-Received: by 2002:a17:907:62a1:b0:781:b320:90c0 with SMTP id nd33-20020a17090762a100b00781b32090c0mr3176386ejc.255.1665134060514; Fri, 07 Oct 2022 02:14:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665134060; cv=none; d=google.com; s=arc-20160816; b=oPnZztRaxCm4l2+80szeOIuD1DCKd39h2GpfcrxHc36edKdtuabGvmFF4FYkQVzrgW Zt0F9BRxyn61zKdrsGDQeTxJVtox3+60rRVIpvo/yNI2/RR/8Yz8u2TLlbN7g+0z2Mrt lX0zB8svrs4/MK4jdDpClpr+0nDrrYqK6b58xTHWal5CHVD3cQxbIXGF/jQJMxYkOIDp 7AJTJIFI4/CUFoYa5r/62GVgYuQz+1YZH3G+qTPTKwNGIPC2C0R+LZuL9aveljeDbZH1 muXh4hnAgsz/KJwJ9uxQfmg1lHxV0vDrCHKvE5gbfWjB/OrRMkopJJdA/4a7z+xeqo2+ j6Kg== 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:references:cms-type:mime-version :message-id:date:to:from:dkim-signature:dkim-filter:delivered-to; bh=SO4eohSbssRxSHls9xopBYSIl2hHeAUE4EiHFwE+zYo=; b=CYlW8r0TY89ERogVE6NYBF6gUnmC/wrnZ9Gr6ZIe9IrCOBCNRHsAylrxoUSjcg11mv 6s0rzXNcDQzg9ueFxXlUaD9a/8hLuaGUkgUOgjmy1h1sISbJlAl5IkagTChjS3ZQ5Sf/ JoZ9GjFGvhJ+l0AffSdy3Y7kfsrPj8J8m7atYyzllRc2fq4PYHJm4dRaab/6SHIu6m8Y PYv8GR6sWsp7ypsrwiA8IWl+tYOPETJQULBkjCdgdxOo1AnIA4BgtIxOxrXnfdl9qZ1t IZTcmZ0OUfHovPaFQLycgZySDteSHZjTqPt/D6LxxqXjSQrUx5Sc9sh1T5pmBews/qqQ neJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=gSYipd4P; 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=samsung.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id m18-20020a056402431200b00453688643fasi2041692edc.260.2022.10.07.02.14.20; Fri, 07 Oct 2022 02:14:20 -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=@samsung.com header.s=mail20170921 header.b=gSYipd4P; 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=samsung.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5720468BC19; Fri, 7 Oct 2022 12:14:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4612168BBA0 for ; Fri, 7 Oct 2022 12:14:12 +0300 (EEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20221007091411euoutp024c52eb13f90ed400710bc93511d64ba5~bvpkNnua22052420524euoutp02e for ; Fri, 7 Oct 2022 09:14:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20221007091411euoutp024c52eb13f90ed400710bc93511d64ba5~bvpkNnua22052420524euoutp02e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1665134051; bh=tW3mbb/cPAEklI5TFZQL8w/muJBNnUrAhZCQFqg4ciI=; h=From:To:Cc:Subject:Date:References:From; b=gSYipd4PTqC6EeRwsKV4ziHtPbNcyDg522mFnYNfrCf0Bo7zGwjTEHrRUYAa3o/zm ZHIgy16cwN/CF3qvbx0mhvt6HkSnWMtrdG4EJNakZ9qAKeJfbdxodRqV99rRDV/oqY pvJTmdHBgmU1OkDUEE8IhbkPgJNVL1aWysmdqTnU= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20221007091411eucas1p26abcab8b3b3a97c5c960c02170ad4c7a~bvpj2ZvL93038030380eucas1p2I; Fri, 7 Oct 2022 09:14:11 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id B9.3E.29727.3EDEF336; Fri, 7 Oct 2022 10:14:11 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20221007091411eucas1p264bdfaefe894387b5d1509ea2917a800~bvpje19r_3043330433eucas1p22; Fri, 7 Oct 2022 09:14:11 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20221007091411eusmtrp2bf218f5f97cddf485a0f4df4e3892625~bvpjeRG_10292302923eusmtrp2f; Fri, 7 Oct 2022 09:14:11 +0000 (GMT) X-AuditID: cbfec7f2-205ff7000001741f-39-633fede3faea Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 12.8F.07473.2EDEF336; Fri, 7 Oct 2022 10:14:10 +0100 (BST) Received: from AMDN5164.EU.corp.samsungelectronics.net (unknown [106.210.132.171]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20221007091410eusmtip12e47c70e62d935bda2c725159d928fce~bvpjLnqjs0438404384eusmtip1g; Fri, 7 Oct 2022 09:14:10 +0000 (GMT) From: Dawid Kozinski To: d.frankiewic@samsung.com, ffmpeg-devel@ffmpeg.org Date: Fri, 7 Oct 2022 11:14:01 +0200 Message-Id: <20221007091401.1157-1-d.kozinski@samsung.com> X-Mailer: git-send-email 2.37.3.windows.1 MIME-Version: 1.0 X-Unsent: 1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNIsWRmVeSWpSXmKPExsWy7djPc7qP39onGxxcK2Lx5doXZouV336z WHz7dIbZgdnjz6LNLB59W1YxBjBFcdmkpOZklqUW6dslcGWs+72JreACX8XF+7PZGhivc3Qx cnJICJhILH3UzdzFyMUhJLCCUeLcwnvsEM4XRonFl7ayQTifGSXWT73MCNPSO+cSVNVyRol/ XR9YIZx2JonTGzaxglSxCehKvPzwiAnEFhEwlTjZvJcNxGYW0JZYd/c7kM3BISwQJLHttjZI mEVAVWJay012EJtXwEriWM8MqGWaEhO2zGGCiAtKnJz5hAUizi2xbtYlVoiR8hLNW2eD/SAh 8JNd4vr6KawQRS4Sq5vb2CFsYYlXx7dA2TIS/3fOZwK5QUKgWOJQvwOEWSNx6Ec6RIW1xNvG 44wgYWagE9bv0ocIO0qcefGQEaKaT+LGW0GIA/gkJm2bzgwR5pXoaBOCMFUk+jrFIBqlJJ4u m8MMYXtIzFgxk3ECo+IsJF/NQvLJLIS1CxiZVzGKp5YW56anFhvmpZbrFSfmFpfmpesl5+du YgSmh9P/jn/awTj31Ue9Q4xMHIyHGCU4mJVEeHfutEsW4k1JrKxKLcqPLyrNSS0+xCjNwaIk zss2QytZSCA9sSQ1OzW1ILUIJsvEwSnVwLRId8Wyb+mLU7/tzjVN7fnRrJm8rT33e6mL3rVI +aztKQvec4WmmL2OMr3i/211AaPsjz1i0wtqubV3bt8rtqN/t2LZ2ynX3vE21P7gl9n4d5Md 99tlhaGq3o7PdXxWh/yrfBxw+erOW4y3vv77aqqxVe0JO/9h9u17HlXb1u2t/HDsxpnGl5m/ fjeI1O88MT+DP4RzXe3HdSnrIpTuTZN02Fx0aH1B8vSZOwp1S94skVzNodr6f9rJ/6dYtH3y C1I0d6jLclz5/YJzpjdb2uI1cYnzZmqlFfWJ2famyTHyPf0a87JPvmCX3ObPq0Kqz1/atHfN /kTuVA2XZtM70knFczbelfMOb3NbMevMJm4lluKMREMt5qLiRADT1g46fgMAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrELMWRmVeSWpSXmKPExsVy+t/xu7qP3tonG0x+YGXx5doXZouV336z WHz7dIbZgdnjz6LNLB59W1YxBjBF6dkU5ZeWpCpk5BeX2CpFG1oY6RlaWugZmVjqGRqbx1oZ mSrp29mkpOZklqUW6dsl6GWs+72JreACX8XF+7PZGhivc3QxcnJICJhI9M65xN7FyMUhJLCU UeL23YusEAkpiaVLFzFC2MISf651sUEUtTJJvP37lg0kwSagK/HywyMmEFtEwFzi4rpbYA3M AtoS6+5+B6sRFgiQeDphEVgNi4CqxLSWm+wgNq+AlcSxnhlQCzQlJmyZwwQRF5Q4OfMJC0Sc W2LdrEusEDPlJZq3zmaewMg/C0nZLCSpBYxMqxhFUkuLc9Nziw31ihNzi0vz0vWS83M3MQID d9uxn5t3MM579VHvECMTB+MhRgkOZiUR3p077ZKFeFMSK6tSi/Lji0pzUosPMZoC3TqRWUo0 OR8YO3kl8YZmBqaGJmaWBqaWZsZK4ryeBR2JQgLpiSWp2ampBalFMH1MHJxSDUwztnun3WTY V6DOmjvvQZU207f2Q08dlQyiIhzSvkYYTU6NXVw8PXflkxVyZ+1u3Xm1t2eCnv1Wl4933641 6Fvd9r9vW969cpm1qhtYzC6dO73I52T+lYineyeGzmRbPoPB0mVeeKFNYevmhBNlLHy3TM32 RybfSbx+Qlc5TSozes///kVLz5y/nnTr+b9rYS+iRfQzUzi3lJX4La95tsbJUafihqv/ldrJ 9qxqcdsmerxnuW9cLXTP76AFy+Lq1m9ca9M/7JNSZRZ5G2v6Vbm9V0b8TMvRx89Vfe//et7N cLMgI83sR3v31T/rzL5NaNMxPOJ3fWVbjC1/wQG7iuusuTN36y9MEdnE/vYX5yYlluKMREMt 5qLiRADZER+c5QIAAA== X-CMS-MailID: 20221007091411eucas1p264bdfaefe894387b5d1509ea2917a800 X-Msg-Generator: CA X-RootMTR: 20221007091411eucas1p264bdfaefe894387b5d1509ea2917a800 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20221007091411eucas1p264bdfaefe894387b5d1509ea2917a800 References: Subject: [FFmpeg-devel] [PATCH v13 9/9] avcodec/evc: Changes in Changelog and MAINTAINERS files 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: Dawid Kozinski Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Kf5J9c0Byi0z - Changelog update - MAINTAINERS update Signed-off-by: Dawid Kozinski --- Changelog | 3 ++- MAINTAINERS | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 14ba8ac874..ff3b9aebf1 100644 --- a/Changelog +++ b/Changelog @@ -44,6 +44,8 @@ version 5.1: - remap_opencl filter - added chromakey_cuda filter - added bilateral_cuda filter +- eXtra-fast Essential Video Encoder (XEVE) +- eXtra-fast Essential Video Decoder (XEVD) version 5.0: @@ -91,7 +93,6 @@ version 5.0: - anlmf audio filter - IMF demuxer (experimental) - version 4.4: - AudioToolbox output device - MacCaption demuxer diff --git a/MAINTAINERS b/MAINTAINERS index eebfa5cfb7..df8d8eca73 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -200,6 +200,8 @@ Codecs: libvpx* James Zern libxavs.c Stefan Gehrer libxavs2.c Huiwen Ren + libxevd.c Dawid Kozinski + libxeve.c, Dawid Kozinski libzvbi-teletextdec.c Marton Balint lzo.h, lzo.c Reimar Doeffinger mdec.c Michael Niedermayer @@ -420,6 +422,9 @@ Muxers/Demuxers: dv.c Roman Shaposhnik electronicarts.c Peter Ross epafdec.c Paul B Mahol + evc.c, evc.h Dawid Kozinski + evcdec.c Dawid Kozinski + evc_parser.c Dawid Kozinski ffm* Baptiste Coudurier flic.c Mike Melanson flvdec.c Michael Niedermayer