From patchwork Thu Aug 25 13:34:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawid Kozinski X-Patchwork-Id: 37474 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp344132pzh; Thu, 25 Aug 2022 06:35:23 -0700 (PDT) X-Google-Smtp-Source: AA6agR5BUCn7+NlzzBrTYGVwNEzmzT1FujzOCP7xU0QW09BtNY+Mnfs0jBLAnkpVR7t7RB6klwfV X-Received: by 2002:a05:6402:438a:b0:446:c214:1b2c with SMTP id o10-20020a056402438a00b00446c2141b2cmr3166147edc.310.1661434523197; Thu, 25 Aug 2022 06:35:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661434523; cv=none; d=google.com; s=arc-20160816; b=G/WiEFgNANr06BgTos+RUTpdZ6HNJVu1jh9eValHGWmT2SevyZMO0V+kpW6O6ljV2S ZbtNHQ3GqQl7YOUgBTUTgJfzsRfgLwjDuxFmYKXfs+cliAdqUQOzxVqHJufSi7E8tmoz /XF+z+bYysmgEQc/XDx7ahHDvos1kMiY21sV0lYEAmk4McEYhhEkFHRBXlSbC8d7DKSV rkprlptMA7gaylrbQ6MFV5KKw42jvRcshf/CxR6wGtpmFUNAUqBRArDuBQMFkQGDZ7Xb jsP3vCNM3b0ZWUQu86A8EahSsxSjxYQGjOjRORPnVSbJEG71aHC1fWT334HD4kpiJ59a PzoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:references:cms-type:content-language :thread-index:mime-version:message-id:date:to:from:dkim-signature :dkim-filter:delivered-to; bh=9RWfxEeq6IHCNb5iwGeJvSGr4iH28uh5ZjscA94zlIY=; b=WBnAimPq6P9qhsYExomaEPXDnHfyVNoKXwfVtdr5l56Iq7Y3ZLLSz6Ac08NLQTV8AB mh3upLQ+jSsOKtUueZq/+Bp7JARSYXGrcfkyEiYt97ZTuftu6CSSYgaRq387esBZ3Wjg +lc72PhPniwsGjeTWUeXBMMqCM66ghNBQ6sxpyp8QtODLBnGNEqxgPNpjqpfI78uT+L+ 8kIrBRZbo7r4nkj5CIMOVZQIxWUydIn1zAhy4F1jl3Oz4EIKZe6ePG305q7+63b4slyd x54eqx5IydpAFfuZ/9W9Sf5JpEZAfRS9IYKowVt6Ebc92MMwyqMxi2Sf3HA+QSbzQaf0 sl4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=k7bWyHtm; 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 jr9-20020a170906a98900b0073d795a38d2si3535947ejb.79.2022.08.25.06.35.15; Thu, 25 Aug 2022 06:35:23 -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=k7bWyHtm; 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 259BA68B9F6; Thu, 25 Aug 2022 16:35:11 +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 9A27268B58E for ; Thu, 25 Aug 2022 16:35:04 +0300 (EEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220825133501euoutp0240c3dc707b4c38aca5fa5a55fdf03971~OmeBC_cTG2945229452euoutp02u for ; Thu, 25 Aug 2022 13:35:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220825133501euoutp0240c3dc707b4c38aca5fa5a55fdf03971~OmeBC_cTG2945229452euoutp02u DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1661434501; bh=OD/peepzvhmPP9gWThe8CpRIW6wN8IpFL5BlTs20XaY=; h=From:To:Subject:Date:References:From; b=k7bWyHtmmRvMD29C+Wmh7svJJUH5cMjzcxl5kuxIsttwYGAn0VWjE2CqDIc+//+iT NI70nEf/fGTSMY0l2C+32ggyfWNSA2y0tyTCpiG3t3TMQhRMRRP7ixm3ZvA0jxJAOf wC08ngDQDxaP7FCYpTNKTqJZezwr1JxIStiabyik= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220825133500eucas1p209119461394612bd9faeaeb7a2fe8811~OmeAqr5PQ3110831108eucas1p2G for ; Thu, 25 Aug 2022 13:35:00 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 1A.67.29727.48A77036; Thu, 25 Aug 2022 14:35:00 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220825133500eucas1p2dfa18eddfc17fb93bec160f7a91c6a11~OmeAU2k8i2291122911eucas1p2x for ; Thu, 25 Aug 2022 13:35:00 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220825133500eusmtrp185ec335eb358714c1d36b3a1370be114~OmeAUNZzd1581615816eusmtrp1h for ; Thu, 25 Aug 2022 13:35:00 +0000 (GMT) X-AuditID: cbfec7f2-21dff7000001741f-c9-63077a84474a Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id EC.83.07473.48A77036; Thu, 25 Aug 2022 14:35:00 +0100 (BST) Received: from AMDN3260 (unknown [106.210.132.171]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220825133500eusmtip1f6d56e1b6fdce03feaa50f94fc9ea74b~OmeAHj4Is1301713017eusmtip1G for ; Thu, 25 Aug 2022 13:34:59 +0000 (GMT) From: "Dawid Kozinski" To: Date: Thu, 25 Aug 2022 15:34:59 +0200 Message-ID: <014801d8b887$79365810$6ba30830$@samsung.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: Adi4cGBdcbGrXp0HRjCABH9TSJ0pEQ== Content-Language: pl X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOIsWRmVeSWpSXmKPExsWy7djP87otVezJBqs/K1h8+3SG2YHR48+i zSwBjFFcNimpOZllqUX6dglcGUduJBfMkanY+bqXrYFxllgXIyeHhICJxL7WFWxdjFwcQgIr GCUm3tnPCuFMYpJY270FKjORSeLLurnMXYwcYC2rp3tDxJczSnx5cogJwmljkri3dSETyFw2 AX2JmYs+sYHYIgKyEqv/TQGzhQVsJb42z2QGsVkEVCVaZx8As3kFLCWutG2EsgUlTs58wgJi MwvIS2x/O4cZ4lYFiZ9Pl7FCzNSTWPz2PVSNiMSNRy2MIEdICLxll5i29C0jRIOLxJf7x1gg bGGJV8e3sEPYMhKnJ/ewQHxTLHGo3wHCrJE49CMdosJa4m3jcUaQMLOApsT6XfoQYUeJiWtX MEJU80nceCsIcQCfxKRt06GhwyvR0SYEYapI9HVCg1lK4ukymDc8JKZv/MU8gVFxFpJvZyH5 dhaSr2YhnLCAkWUVo3hqaXFuemqxYV5quV5xYm5xaV66XnJ+7iZGYFo4/e/4px2Mc1991DvE yMTBeIhRgoNZSYTX6hhLshBvSmJlVWpRfnxRaU5q8SFGaQ4WJXHe5MwNiUIC6YklqdmpqQWp RTBZJg5OqQam2S27PealC3LNKNw+OUbdca3MTsEnHtkKzDML1Wamt79b0dA9Nblr2tSLBk6i Z1KvHIyoFDXTm2qsvPzt0V9yvxb9LPS8VhblUfWo9vQiqWfN/CZ3LgbP3HmiuPfR2YsNf/+a dWiUCW3VOhF9K3KWZk1JtsVuv6prKioC3CEqfb1KjvefPqncmq3CW71/ciKP+ObZTwOe3y/U OaLRuFSI9cyt+hVz39zsK98i2ivq8bcqKTVFJufn386pvBP/NEqc2rr6/raSNwpRNbF8i8UE 6zNMXooUiq92fJ7exfXumPiqK667Cj/Xz3j8/1JgQqCow+r/Cetfc4euCehZFq5guM8wtkY5 f+bqpzclLucqsRRnJBpqMRcVJwIAaGIE13oDAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrKLMWRmVeSWpSXmKPExsVy+t/xu7otVezJBjMec1t8+3SG2YHR48+i zSwBjFF6NkX5pSWpChn5xSW2StGGFkZ6hpYWekYmlnqGxuaxVkamSvp2NimpOZllqUX6dgl6 GUduJBfMkanY+bqXrYFxllgXIweHhICJxOrp3l2MXBxCAksZJZ5dXsjYxcgJFJeSWLp0EZQt LPHnWhcbRFELk8T5s5/AEmwC+hIzF31iA7FFBGQlVv+bAmYLC9hKfG2eyQxiswioSrTOPgBm 8wpYSlxp2whlC0qcnPmEBcRmFtCWeHrzKZQtL7H97RxmiMUKEj+fLmOFmK8nsfjte6gaEYkb j1oYJzAKzEIyahaSUbOQjJqFpGUBI8sqRpHU0uLc9NxiQ73ixNzi0rx0veT83E2MwPDeduzn 5h2M81591DvEyMTBeIhRgoNZSYTX6hhLshBvSmJlVWpRfnxRaU5q8SFGU6DfJjJLiSbnAyMs ryTe0MzA1NDEzNLA1NLMWEmc17OgI1FIID2xJDU7NbUgtQimj4mDU6qByVNMxtb8hqVg6Kbq rzMdggXKnnWE+goempzV7y9lfqj3aM5/5o4C1SbNlrNbLDfp/JJp2qM2tTbOxpH5day6VrYY H+fDNPYwXc5DU8ys+TLvnQnd6NkdVypUvp/1QIP4h/dy8x64PKv3YVd9fep45JsnZt7r4x4/ NjffPfP91rR71dXCkcYKmwVbxIxeLipqfl3Um7HuiFFOlqlappxag76r4S33uLd2fkUTCxP/ 6Xza7Hj6J7Oftv3WbPdV7mq+SZpNrKHLNK59P3xi0gIXxc1vNIQX7IpYGt9X7hVqY3H0hLfh emPm92d2bf118+3UMDt/8eXz+6Um2i1jSK7azlqXzpFZ/iI+48P180osxRmJhlrMRcWJAHWQ oX/4AgAA X-CMS-MailID: 20220825133500eucas1p2dfa18eddfc17fb93bec160f7a91c6a11 X-Msg-Generator: CA X-RootMTR: 20220825133500eucas1p2dfa18eddfc17fb93bec160f7a91c6a11 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220825133500eucas1p2dfa18eddfc17fb93bec160f7a91c6a11 References: Subject: [FFmpeg-devel] [FFmpeg-devel v10 1/9] 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 1+i6FaoolaDu 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 65c8535359..7d56a03fca 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1674,6 +1674,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 06dfe55d0f..d992374bb8 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -1909,6 +1909,14 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("WBMP (Wireless Application Protocol Bitmap) image"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, }, + { + .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 2247bc0309..ba32a33692 100644 --- a/libavcodec/codec_id.h +++ b/libavcodec/codec_id.h @@ -318,6 +318,7 @@ enum AVCodecID { AV_CODEC_ID_PHM, AV_CODEC_ID_RADIANCE_HDR, AV_CODEC_ID_WBMP, + 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 12421666b9..91d6f8272e 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 42 +#define LIBAVCODEC_VERSION_MINOR 43 #define LIBAVCODEC_VERSION_MICRO 102 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ From patchwork Thu Aug 25 13:35:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawid Kozinski X-Patchwork-Id: 37475 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp344269pzh; Thu, 25 Aug 2022 06:35:36 -0700 (PDT) X-Google-Smtp-Source: AA6agR7VmHZpsrJfdEyNWC1gaZkPtpYiD1IXkzXWEKAVaKqp+ldVZbB1FjkI8damxBDnmUj3zm59 X-Received: by 2002:a05:6402:330e:b0:446:b79c:996 with SMTP id e14-20020a056402330e00b00446b79c0996mr3389103eda.260.1661434535908; Thu, 25 Aug 2022 06:35:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661434535; cv=none; d=google.com; s=arc-20160816; b=XjSx6PznHrjLrJ0JBS0p1Gqjvsx0s/d4IEcLt0MzKYaDkHLtnlmgttrbQ+09vKKik3 lXX3Bk5bFajEdtgHM1+Elw7qu3dD1Ufd98+R387hHPmID2pz7sn/cGcf7o/104APDNs+ SZ7s1rxWw5FMccfGggj1kTRmNOvykyiZwte7BXynwxEhrzFkwkxbI3FmJiwILeqVMOOg cV641+9zyXz4vsB5Uzwk1CjFDnyizhrNnjrmqyyb6zTF9fDkVmSO7dFKHz886vjSRQKc h/mr68N3bEp+qMt+2wMKv1z5ZHQMFXTC56IqV3RsMUQvd4ZpbnGj21F16fxzZzsn92HK r81g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:references:cms-type:content-language :thread-index:mime-version:message-id:date:to:from:dkim-signature :dkim-filter:delivered-to; bh=v1XnWoziW7SYvOaW/fpvOFIJPRY1wUAtw4xZ8bradyc=; b=cTJYdL5ClB1/ELDl2ymmLXEjPR7FUAbn6EKNQcVdJZQI4tjdd8pfiwqrr1tOlRlz6G roA/rrT4rBErPZYTn21ICVusaRocSkWq4yEKSYYCanGnhxRk1DoV3nXajXnxkCkjtKI0 GYYXExLuB1iLApR6IuRrrfg4aPXpqHL9HXIRAMZIGCIItJS/NcIzVaoTpmXgbUGNw0+I cHzJiSb0lkyEkE303YJvT14pY6fBHLqcT/CjpMnH9zRQYUM8jJ2M/jB/mqqxJRbDFkGO 0RaWDvhMM7qP6T4BGzp1FU9dHH74F/9+0/Xcys/C1HvY3emJ9N+jEGuMOHahKwRULFOT 2Bag== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=gcc68tjV; 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 cw5-20020a170906478500b00732f76a97bdsi3828532ejc.907.2022.08.25.06.35.27; Thu, 25 Aug 2022 06:35:35 -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=gcc68tjV; 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 37EBF68BA0F; Thu, 25 Aug 2022 16:35:13 +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 C8BBD68B8C9 for ; Thu, 25 Aug 2022 16:35:06 +0300 (EEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220825133505euoutp01f5cd1b3b66ef745392f03c80bbe275f3~OmeFO2V7h2180521805euoutp01Z for ; Thu, 25 Aug 2022 13:35:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220825133505euoutp01f5cd1b3b66ef745392f03c80bbe275f3~OmeFO2V7h2180521805euoutp01Z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1661434505; bh=AcqYDDJRUvDrEj0Ylt0r1KG0mVtWc8o4J68f9CDyyIM=; h=From:To:Subject:Date:References:From; b=gcc68tjVTT+W+5VirK/DA7WOXCMYqvrQZIW5MIYPcb+XhGRQHoWOgWJxAlFZWoGG1 azJCBBSoGXVUdunuzfQyTz6WHKySDMkMrv65UgJcvvHO3GX0kofUp0KZ6yDOCifjFQ g4qxvGr91pVDf0LNjPEevxG+4vFy+IxeOzHtbPyE= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220825133505eucas1p27bfc73c5e747cd62e3d9a94d1c39ee76~OmeE9x-9V3110331103eucas1p2K for ; Thu, 25 Aug 2022 13:35:05 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 2C.67.29727.98A77036; Thu, 25 Aug 2022 14:35:05 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220825133504eucas1p253e7d5e6ddb461beed36b91cadd3d847~OmeEnrs8J2496324963eucas1p2l for ; Thu, 25 Aug 2022 13:35:04 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220825133504eusmtrp1f380e78c82b70c12a8c1fda257ba1915~OmeEnBVUm1614816148eusmtrp1k for ; Thu, 25 Aug 2022 13:35:04 +0000 (GMT) X-AuditID: cbfec7f2-205ff7000001741f-d8-63077a89e4be Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 6F.83.07473.88A77036; Thu, 25 Aug 2022 14:35:04 +0100 (BST) Received: from AMDN3260 (unknown [106.210.132.171]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220825133504eusmtip21ea42cb32b7117a94a0385c71f6c386f~OmeEUSvM90117601176eusmtip2B for ; Thu, 25 Aug 2022 13:35:04 +0000 (GMT) From: "Dawid Kozinski" To: Date: Thu, 25 Aug 2022 15:35:04 +0200 Message-ID: <014901d8b887$7be635d0$73b2a170$@samsung.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: Adi4c2yWNnW7mSSBSs20zOJRrxLJvQ== Content-Language: pl X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrJIsWRmVeSWpSXmKPExsWy7djP87qdVezJBnPmcFl8+3SG2YHR48+i zSwBjFFcNimpOZllqUX6dglcGXuuHWEpOPSWseLO11uMDYzzljF2MXJySAiYSFzY2gVkc3EI CaxglPi+rw/KmcQk8WXdDbAqIYGJQM5RY5iOyS/OMUEULWeU+PdgLyuE08Yk8ePeN2aQKjYB fYmZiz6xgdgiArISq/9NAbI5OIQFPCWWXXQACbMIqEpsnL2GCcTmFbCU6N63gxnCFpQ4OfMJ C4jNLCAvsf3tHGaIxQoSP58uY4UYqSfxeMYVNogaEYkbj1rArpYQ+Mku8WPffHaIBheJhx17 2CBsYYlXx7dAxWUkTk/uYQG5R0KgWOJQvwOEWSNx6Ec6RIW1xNvG44wgYWYBTYn1u/Qhwo4S b58fZYOo5pO48VYQ4gA+iUnbpjNDhHklOtqEIEwVib5OMYhGKYmny2De8JBonvuceQKj4iwk 385C8u0sJF/NQjhhASPLKkbx1NLi3PTUYsO81HK94sTc4tK8dL3k/NxNjMDUcPrf8U87GOe+ +qh3iJGJg/EQowQHs5IIr9UxlmQh3pTEyqrUovz4otKc1OJDjNIcLErivMmZGxKFBNITS1Kz U1MLUotgskwcnFINTI5dDacOxgdbvpiUu8Yoz0u98mZoO8uW3OdnlA7K3D2ZGnP6y9o93zbq Zf7f1m9zaqf23IR/n7xkFpdk/OQMuv5Kdo3umo3pD5v9Yq6YrT858Ul7YY/MQ8kmS/U047Av Biu5kyuiEqKMj5wLe7g2cN7s7RFvn2wXdo19yO920yumecbzI5HTJ5uk++3pulNyRdPt67L3 Halh7OyOZd6CkyPmZv57k5HRkZdrtWszhymn4psIsdONy6+2f2LvP2wVoZ5mHyX6ZyXPwRPJ gbcXlJWEaPJa1e5e2PPQgafuzde7x2+0/Mn5O5n3f5D49CR/g/iU5ohZbws/ZNqLT3f6/GLa 9WvGNfwLl9ZGFFw1V2Ipzkg01GIuKk4EAKdVKwR8AwAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOLMWRmVeSWpSXmKPExsVy+t/xe7odVezJBqs+a1t8+3SG2YHR48+i zSwBjFF6NkX5pSWpChn5xSW2StGGFkZ6hpYWekYmlnqGxuaxVkamSvp2NimpOZllqUX6dgl6 GXuuHWEpOPSWseLO11uMDYzzljF2MXJySAiYSEx+cY4JxBYSWMoosXdLGERcSmLp0kVQNcIS f651sXUxcgHVtDBJ7Ju3BSzBJqAvMXPRJzYQW0RAVmL1vylANgeHsICnxLKLDiBhFgFViY2z 14DN5xWwlOjet4MZwhaUODnzCQuIzSygLfH05lMoW15i+9s5zBB7FSR+Pl3GCjFeT+LxjCts EDUiEjcetTBOYBSYhWTULCSjZiEZNQtJywJGllWMIqmlxbnpucWGesWJucWleel6yfm5mxiB Ib7t2M/NOxjnvfqod4iRiYPxEKMEB7OSCK/VMZZkId6UxMqq1KL8+KLSnNTiQ4ymQL9NZJYS Tc4HRlleSbyhmYGpoYmZpYGppZmxkjivZ0FHopBAemJJanZqakFqEUwfEwenVAPTgS8dEuns yxLfx2xb+iD5o7V+ZR7roZp7XdEfL/rXG86p1y7Vmv/vrA9/jGV6wq5jdxbYX2xSrzLTbA4s 9Z5674jU1g3itrUFM1Z+vRUYUu+zi1vfwub51AMq//6+tL379nh/C+vpp1IbU6fOZFj1bBu3 war9RvrpC24eE26Labj+SmSK8Zk9JUVaF6e8C8vW6Dn5v+9Lk+7n4CyHIJmnbz62e/bPsWgK 7bNk4nu/YbFOj9fVstcqrxIr2DeKNMybalS2IU/9kvHB487bcqKj5stn7Fm1olQl4o7tmnL1 92pTzy8sKJtaJ2H7afobyc02f65/ei7ocEUneMdxjQeTNvxwu+h+9ZLwM67pPR3cSizFGYmG WsxFxYkABzs+QfoCAAA= X-CMS-MailID: 20220825133504eucas1p253e7d5e6ddb461beed36b91cadd3d847 X-Msg-Generator: CA X-RootMTR: 20220825133504eucas1p253e7d5e6ddb461beed36b91cadd3d847 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220825133504eucas1p253e7d5e6ddb461beed36b91cadd3d847 References: Subject: [FFmpeg-devel] [FFmpeg-devel v10 2/9] 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: z1UMbSQCdWmZ Signed-off-by: Dawid Kozinski --- libavcodec/Makefile | 1 + libavcodec/evc_parser.c | 758 ++++++++++++++++++++++++++++++++++++++++ libavcodec/parsers.c | 1 + 3 files changed, 760 insertions(+) create mode 100644 libavcodec/evc_parser.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index cb80f73d99..3d2e5d9bc2 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1129,6 +1129,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_G723_1_PARSER) += g723_1_parser.o OBJS-$(CONFIG_G729_PARSER) += g729_parser.o diff --git a/libavcodec/evc_parser.c b/libavcodec/evc_parser.c new file mode 100644 index 0000000000..0ae0eaa08a --- /dev/null +++ b/libavcodec/evc_parser.c @@ -0,0 +1,758 @@ +/* + * 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" + +// 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 */ +#define MAX_SPS_CNT (16) /* defined value in EVC standard */ +#define MAX_PPS_CNT (64) /* defined value in EVC standard */ + +#define MAX_NUM_TILES_ROW (22) +#define MAX_NUM_TILES_COL (20) + +// NALU types +// @see ISO_IEC_23094-1_2020 7.4.2.2 NAL unit header semantics +// +#define EVC_NUT_NONIDR (0) /* Coded slice of a non-IDR picture */ +#define EVC_NUT_IDR (1) /* Coded slice of an IDR picture */ +#define EVC_NUT_SPS (24) /* Sequence parameter set */ +#define EVC_NUT_PPS (25) /* Picture paremeter set */ +#define EVC_NUT_APS (26) /* Adaptation parameter set */ +#define EVC_NUT_FD (27) /* Filler data */ +#define EVC_NUT_SEI (28) /* Supplemental enhancement information */ + +// slice type +// @see ISO_IEC_23094-1_2020 7.4.5 Slice header semantics +// +#define SLICE_TYPE_UNKNOWN (-1) +#define SLICE_TYPE_B (0) +#define SLICE_TYPE_P (1) +#define SLICE_TYPE_I (2) + +#define MAX_NUM_RPLS (32) +#define MAX_NUM_REF_PICS (21) + +// rpl structure +typedef struct RefPicListStruct { + int poc; + int tid; + int ref_pic_num; + int ref_pic_active_num; + int ref_pics[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][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[MAX_NUM_TILES_ROW]; // ue(v) + int tile_row_height_minus1[MAX_NUM_TILES_COL]; // 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[MAX_NUM_TILES_ROW][MAX_NUM_TILES_COL]; // 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[MAX_NUM_TILES_ROW * MAX_NUM_TILES_COL]; // 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[MAX_SPS_CNT]; + EVCParserPPS pps[MAX_PPS_CNT]; + EVCParserSliceHeader slice_header[MAX_PPS_CNT]; + 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 >= MAX_SPS_CNT) + 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 > MAX_PPS_CNT) + 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 >= MAX_SPS_CNT) + 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 >= MAX_PPS_CNT) + 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->pict_type = AV_PICTURE_TYPE_NONE; + 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_NUT_SPS) { // 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_NUT_PPS) { // 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_NUT_SEI) // NAL unit type: SEI (Supplemental Enhancement Information) + return 0; + else if (nalu_type == EVC_NUT_IDR || nalu_type == EVC_NUT_NONIDR) { // 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 SLICE_TYPE_B: { + s->pict_type = AV_PICTURE_TYPE_B; + break; + } + case SLICE_TYPE_P: { + s->pict_type = AV_PICTURE_TYPE_P; + break; + } + case 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_NUT_IDR) ? 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 a8d52af6cb..ca00c63176 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_g723_1_parser; extern const AVCodecParser ff_g729_parser; From patchwork Thu Aug 25 13:35:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawid Kozinski X-Patchwork-Id: 37476 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp344403pzh; Thu, 25 Aug 2022 06:35:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR5lkHfL9HdTYQmxUj/w0GAySXKSHhUkWdbkCk5CVn8sB6zMh2wBz77mxmUsrMWZSmRev7Ey X-Received: by 2002:a05:6402:1945:b0:446:692:8aeb with SMTP id f5-20020a056402194500b0044606928aebmr3170148edz.403.1661434547964; Thu, 25 Aug 2022 06:35:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661434547; cv=none; d=google.com; s=arc-20160816; b=dpwIYbdF8VNWu3dZSoVdsTbCm8F7EaribKGSxgMSakq0WopXLcHKYo4DYRslWOxYvE S0P4XM0GAt98l0Je8x4+SlDAnDRWWlJ3+5IG7gzEWYfjEAlRd0RToUpbXLo4gyhMlQCF jqdT7WWAcYFGTSCW053Lt6TAD2uSNQZnd8KmX7AIltSOp3Cyn/mZ7w8pbOMGaWuVfHMW yJS5fKbqfaV5PBZdp9knJxpZQ6R9OFa8r2QyiRPT5JL8WWVRV5OYQ6h7Vd+sWYQrKzrj dW01Jz5G8ByhdCtHzGiwSjBOvAdzu5lWpLKkPzvunq1FKol5SoPy4gM2SlUp+4Px7uCu UExA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:references:cms-type:content-language :thread-index:mime-version:message-id:date:to:from:dkim-signature :dkim-filter:delivered-to; bh=561vMb+kfD/2ZEMFf7ddb/j2ngu4o/DZZOUIg3uT91I=; b=a5+TuIpR9nAGHg/g2evfCalwhYsA5TUXbycKhvKnyBpqKzj8ZBvvf0Tf7UTIzxCWhw tFJXwE3SYv79naEk01VazMY/aBQnUiETS76AgWgMp0dgkqH2iMMqdRxj/7BOanFovjXy boU1VwPKiEDBEHy0C8WDi8GIMNq4FerADzDnGoQ4xpIAKhy3Kk4ph6BLaglxeDGMJ/1L VPgoY8YVdXrqpVX3LGWON93D4BHcqTWiBslETzPgq6c+XDVo17IOXNW4oBi/R3/8niI+ O/edzetkRNNZfkjYyzkiabKMBQeh0Kpg+D1yfIn5LMDnYGx4YG1+2ge7CQrngllZjpCG Tiqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=ksK9dN7K; 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 q27-20020a50c35b000000b0043e5ca9a0e2si4930749edb.628.2022.08.25.06.35.38; Thu, 25 Aug 2022 06:35:47 -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=ksK9dN7K; 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 6D87668BA0A; Thu, 25 Aug 2022 16:35:16 +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 EDFBD68BA0A for ; Thu, 25 Aug 2022 16:35:09 +0300 (EEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220825133509euoutp0252404a11d9c70d1ea08e67dd527f030c~OmeI7XvUN2953629536euoutp02b for ; Thu, 25 Aug 2022 13:35:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220825133509euoutp0252404a11d9c70d1ea08e67dd527f030c~OmeI7XvUN2953629536euoutp02b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1661434509; bh=Euq+bg9+8missZ6TaWGDhAd2cWTaDa9UglRGZwAXNO4=; h=From:To:Subject:Date:References:From; b=ksK9dN7KhjVdvhUdBDfKumtJtvCUliz0Fn6dBLirJCoUsuletFoiE7y1W1QUstr/C +YVM0Eh4ZyKgSXFCpPvQPgXSFJdSyd71pkZelC2RnGvhT7jOCxjOZXESqasPr3LX26 FEvJOYBgpoDrqcTlYVDwy+TWn9CCdTV7RguuTjYU= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220825133509eucas1p2da93d771f612571e36508bdefdbca876~OmeIwPotf0167801678eucas1p2C for ; Thu, 25 Aug 2022 13:35:09 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 7F.55.07817.D8A77036; Thu, 25 Aug 2022 14:35:09 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220825133508eucas1p1d4d060385bde82b1e298286f0522cd12~OmeIX-j2C1616916169eucas1p1a for ; Thu, 25 Aug 2022 13:35:08 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220825133508eusmtrp1cdea760b2a742c10f35a3220aa6c4790~OmeIXXLb51642116421eusmtrp1B for ; Thu, 25 Aug 2022 13:35:08 +0000 (GMT) X-AuditID: cbfec7f4-893ff70000011e89-82-63077a8d65fb Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 0C.F4.10862.C8A77036; Thu, 25 Aug 2022 14:35:08 +0100 (BST) Received: from AMDN3260 (unknown [106.210.132.171]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220825133508eusmtip294ed085e6ddd593e7c0539e131005fcb~OmeIBasEN0117601176eusmtip2D for ; Thu, 25 Aug 2022 13:35:08 +0000 (GMT) From: "Dawid Kozinski" To: Date: Thu, 25 Aug 2022 15:35:08 +0200 Message-ID: <014a01d8b887$7e453470$7acf9d50$@samsung.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: Adi4dSdzkLTwRDXQRDGiqzVORbtiFQ== Content-Language: pl X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCIsWRmVeSWpSXmKPExsWy7djPc7q9VezJBief8lh8+3SG2YHR48+i zSwBjFFcNimpOZllqUX6dglcGS+au1gK3ohW3Nz7nb2B8bdAFyMnh4SAicTXdzsZuxi5OIQE VjBKdH6bxQzhTGKSmLhwLiuEM5FJ4tC+bmaYlk+t+1hAbCGB5YwSj+eWQdhtTBKTz5SC2GwC +hIzF31iA7FFBGQlVv+bAmYLC+RLHF55BGgOBweLgKrEytd2IGFeAUuJjrN/2CBsQYmTM5+A jWcWkJfY/nYO1FoFiZ9Pl7GCtIoI6ElselEGUSIiceNRC9gDEgJf2SV2nuphgah3kfh59BAr hC0s8er4FnYIW0bi9GSQGg4gu1jiUL8DhFkjcehHOkSFtcTbxuOMIGFmAU2J9bv0ISocJd69 Y4Iw+SRuvBWE2M8nMWnbdGaIMK9ER5sQhKki0dcpBjFOSuLpMpgnPCS+PLvAPoFRcRaSX2ch +XUWkqdmIVywgJFlFaN4amlxbnpqsVFearlecWJucWleul5yfu4mRmBCOP3v+JcdjMtffdQ7 xMjEwXiIUYKDWUmE1+oYS7IQb0piZVVqUX58UWlOavEhRmkOFiVx3uTMDYlCAumJJanZqakF qUUwWSYOTqkGJkUBme1fZpU/fHom0X6Z2dLXcktOHr+3RK5IOHvD8RCG8wW3Qg+uvTd1tb/+ q/3n1SVPLqp9uHgTs+O1tJVro6T0LZLO/hX6ofNJLO7Yq8r82IAz1hq3ZkbZ3nhzunuNsu3X oJjQoL+hy6b/1+zbdKUrLY7lqGGx+Z2HCwpWtit4rdNYFxod4iB58F+fzkxZneC9Z7OsONx8 ljbmuC90kKxK3dC/ppTV8q78ofTPeuytU7dnzkx99CpB42dwRaC5zXKz/ildLe3OG60i53+9 f3iNz5vrydNP75q8ME5aYF67HG96m9yV1y3Htx702nlZqpxtd0fg0dNuHs8c9uz+XX1Zgufi urJSRafXlW6FcUosxRmJhlrMRcWJAFVQHqF3AwAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrKLMWRmVeSWpSXmKPExsVy+t/xe7o9VezJBnc+aVp8+3SG2YHR48+i zSwBjFF6NkX5pSWpChn5xSW2StGGFkZ6hpYWekYmlnqGxuaxVkamSvp2NimpOZllqUX6dgl6 GS+au1gK3ohW3Nz7nb2B8bdAFyMnh4SAicSn1n0sXYxcHEICSxklHu29wwiRkJJYunQRlC0s 8edaFxtEUQuTxPol29hBEmwC+hIzF31iA7FFBGQlVv+bAmYLC+RK3DvyDKiGg4NFQFVi5Ws7 kDCvgKVEx9k/bBC2oMTJmU9YQGxmAW2JpzefQtnyEtvfzmGG2Ksg8fPpMlaQMSICehKbXpRB lIhI3HjUwjiBUWAWkkmzkEyahWTSLCQtCxhZVjGKpJYW56bnFhvpFSfmFpfmpesl5+duYgSG 97ZjP7fsYFz56qPeIUYmDsZDjBIczEoivFbHWJKFeFMSK6tSi/Lji0pzUosPMZoCfTaRWUo0 OR8YYXkl8YZmBqaGJmaWBqaWZsZK4ryeBR2JQgLpiSWp2ampBalFMH1MHJxSDUxp/p2RBv6H 3bcs2HBS46cH80sPk6YXc3aWVl42MLn24bDQH2WmlENbz9w9Es14sPCpyMaK6BQl+z99O8Le FXJMTym/t+aC6qXZt1abau+VMf4kyzLxpYNFypGYw2GNCcuPNMVLFZyRst9qqlq/ZK1ifV+r tZLUnNXPtvQvyTVe3PTX52KiXnmRtortXad3AoWfPrUF62edne0n09F+oSvZ6Pyxgv9T+PjD i39yiFg7nW1/eycvaX35/Mssoes9NSZ43Z4tk/evUsLNc8Ol5v/b1fRubztp2/3eZvu+uQ0d Enbcs+5MjYuq6199jjd0d+hPg1dLFa5wH5X5fCWogi3vUGjLJ/XoiUZ64leDjZVYijMSDbWY i4oTAfQiD0X4AgAA X-CMS-MailID: 20220825133508eucas1p1d4d060385bde82b1e298286f0522cd12 X-Msg-Generator: CA X-RootMTR: 20220825133508eucas1p1d4d060385bde82b1e298286f0522cd12 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220825133508eucas1p1d4d060385bde82b1e298286f0522cd12 References: Subject: [FFmpeg-devel] [FFmpeg-devel v10 3/9] 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: tE1o97421vCc - 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 f67a99f839..7e3f0e6794 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -249,6 +249,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 ae4479fb7a..31508b69f0 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -148,6 +148,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 Thu Aug 25 13:35:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawid Kozinski X-Patchwork-Id: 37477 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp344471pzh; Thu, 25 Aug 2022 06:35:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR5byOOoqLEFFrrnnmuwW+Tn4XuMD/wuSUTyA6vbYJsh0I53BBOCNLn5HSVQHfib+ybdTAWU X-Received: by 2002:a17:907:845:b0:731:2f6c:6dbd with SMTP id ww5-20020a170907084500b007312f6c6dbdmr2484736ejb.551.1661434556131; Thu, 25 Aug 2022 06:35:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661434556; cv=none; d=google.com; s=arc-20160816; b=eb6FtjsV/JBE6JoWobB7n9hAw03RZVHtvFEmPFCTjZ/PjpLSLWdfHstlvh+EScuzQe w9pfkUah5M5x2YJd6+UnwyrzkuM/LcsegzrnrsAnv3UlecFUdb8G6ueXFZMX16TCygL5 +AKoxSzoq/H+T+ftVQwadoB3CxzTw6EC/yPt6SSmm2UHMiL9uM3y7Cz0ZrYrMcbyKfxa 6qhFdAjXmdkDgbdQwJlZcunkBwRx68NwOpmUau2lj0mMBxcOHEj3ZqrsJrZQbTnr4tCw d6TnoSdKAWhNnTFQrtcom+swNlO6avm8+7mR/z/Jg7veFxbkPvq/u2RDqctnmLp6XHii ZIpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:references:cms-type:content-language :thread-index:mime-version:message-id:date:to:from:dkim-signature :dkim-filter:delivered-to; bh=mzY6bOmz8zWBntvlIoI1FV0Cbnb43l8R8cHEJQ/Fkmc=; b=OHXIBLdRDwe4iuL5JMHrAr/IlHm6OIxpdJHvIZTKWfaDWq4BQub5G90XI/m2V5agNg ZXLDKJn/CbRZw2yQG77lot6A+SErA9kS2HCl85WbZ5z2zTR/fxPbjNZjV2MVITnKAXYJ garvRsMZOLfzu+uyqBo6hcSqOG0vHEoZv/g3Hl2/PpxrHIz/k5Fe6Z/LBzrY0Nt94Eos TV/yRI130TcagyZc668aLuRq7smDCcmSWAPEzyQwUPKh/HBQjyXq0PhujJBqwppvUYTd ROINUYVB/GuYqV43MBBp0WCAzAJwFfAEMgnRkAvZXr89zNEoZY5ihW8d2mQMXoIgRgoN zXKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=tIIH3BKM; 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 go37-20020a1709070da500b0073d7515b235si3912078ejc.533.2022.08.25.06.35.48; Thu, 25 Aug 2022 06:35:56 -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=tIIH3BKM; 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 7CBB368BA2D; Thu, 25 Aug 2022 16:35:21 +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 628D368BA1B for ; Thu, 25 Aug 2022 16:35:14 +0300 (EEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220825133513euoutp01b95fae8f14cfd378326d822df2f58d24~OmeNF6n3n2180521805euoutp01c for ; Thu, 25 Aug 2022 13:35:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220825133513euoutp01b95fae8f14cfd378326d822df2f58d24~OmeNF6n3n2180521805euoutp01c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1661434513; bh=2s8hzJJNeum7aEOmSdmvD6EeHANRaLZSDyn0FBc75/4=; h=From:To:Subject:Date:References:From; b=tIIH3BKMb8Z6Eins0dEyKNKiZhDoeRiBZSGGOK81uugnFQqCmWrG+bd+i3iYleQKm uKZDP5hJTqk00EdBfDQ2VVp1+OGKNnEvHLvbmc6RJ6jPxgyFvua+FVQSeYrtk7n47B Kf0WsPk0HAWsJV7ej51ezatksJvX3ojtdqje0yU0= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220825133513eucas1p242edd25f42eac51e0fcbede1a6d71ea0~OmeMw2My40372603726eucas1p2I for ; Thu, 25 Aug 2022 13:35:13 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id AF.77.29727.19A77036; Thu, 25 Aug 2022 14:35:13 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220825133513eucas1p1edf35903e69b0ce6197352b587d834a4~OmeMXu1F_0257702577eucas1p1f for ; Thu, 25 Aug 2022 13:35:13 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220825133513eusmtrp18ccd09196d6761b8f4e2a9ea514e8ec4~OmeMXLIqH1642116421eusmtrp1K for ; Thu, 25 Aug 2022 13:35:13 +0000 (GMT) X-AuditID: cbfec7f2-205ff7000001741f-f2-63077a91f472 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 65.93.07473.09A77036; Thu, 25 Aug 2022 14:35:13 +0100 (BST) Received: from AMDN3260 (unknown [106.210.132.171]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220825133512eusmtip198746505556408dc1d9de14f00e74a4c~OmeMFKQ4J1662916629eusmtip1J for ; Thu, 25 Aug 2022 13:35:12 +0000 (GMT) From: "Dawid Kozinski" To: Date: Thu, 25 Aug 2022 15:35:12 +0200 Message-ID: <014b01d8b887$80de7cf0$829b76d0$@samsung.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: Adi4dtlfidmNtke3RsOeM4MIN7XElQ== Content-Language: pl X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOIsWRmVeSWpSXmKPExsWy7djPc7oTq9iTDbrPKFl8+3SG2YHR48+i zSwBjFFcNimpOZllqUX6dglcGVu3H2QumG1UcX/XXqYGxumqXYycHBICJhLvNu1k72Lk4hAS WMEosXfeLzYIZxKTxNv9f6GciUwSf252McG0nP13mR3EFhJYziixa6k1RFEbk0T7gTnMIAk2 AX2JmYs+sYHYIgKyEqv/TQGzhQUCJZ41rWQFsVkEVCU+nboDVs8rYCnR9P00lC0ocXLmExYQ m1lAXmL7W4iZEgIKEj+fLmOFmKkn0flpJTNEjYjEjUctjBA1X9klFp1xgbBdJA5vbmKDsIUl Xh3fwg5hy0icntwDNJ8DyC6WONTvAGHWSBz6kQ5RYS3xtvE4I0iYWUBTYv0ufYiwo8SKxxvY Iar5JG68FYTYzycxadt0Zogwr0RHmxCEqSLR1ykG0Sgl8XQZzBceEo9v/GSbwKg4C8mzs5A8 OwvJU7MQTljAyLKKUTy1tDg3PbXYMC+1XK84Mbe4NC9dLzk/dxMjMC2c/nf80w7Gua8+6h1i ZOJgPMQowcGsJMJrdYwlWYg3JbGyKrUoP76oNCe1+BCjNAeLkjhvcuaGRCGB9MSS1OzU1ILU IpgsEwenVANTq3nb8e/bdXwCIjgStt1w+5a5Uss/TsPXxrtGda637GNr/aMX1vRMesMQ/Hhx yi4mDbs/yyLWeNlorPo992rh8dZU39u7HNcvi5tgYFZ2/YVxtqlgzZv0uYyCz9gsFepO7hJf oX3CoJ335t2l/jnLFmbe3RO88eC/20HhHZr6r19P373+0pI3kiK3pD1C1a88Os9ecCTIxPDU suSpB8+7nkj0d84/9etC4/c9V1i5rsxtZt96ZEbjXaalwsarznEnlRXsUrm+wuq9d4rA7mVl Wuv2h25amMqTtCpqW5LWmvBf0S5LPz9xK1zp+F75QpVLl4YY/5YHZcybSksXS7wJfronkqXs 7veFDvGeD5sslViKMxINtZiLihMBA40/c3oDAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGLMWRmVeSWpSXmKPExsVy+t/xu7oTq9iTDY7tZLL49ukMswOjx59F m1kCGKP0bIryS0tSFTLyi0tslaINLYz0DC0t9IxMLPUMjc1jrYxMlfTtbFJSczLLUov07RL0 MrZuP8hcMNuo4v6uvUwNjNNVuxg5OSQETCTO/rvM3sXIxSEksJRR4uuneUwQCSmJpUsXMULY whJ/rnWxgdhCAi1MEvvPJYDYbAL6EjMXfQKLiwjISqz+NwXMFhbwl1h64hbYHBYBVYlPp+4w g9i8ApYSTd9PQ9mCEidnPmEBsZkFtCWe3nwKZctLbH87hxlir4LEz6fLWCHm60l0flrJDFEj InHjUQvjBEaBWUhGzUIyahaSUbOQtCxgZFnFKJJaWpybnltsqFecmFtcmpeul5yfu4kRGODb jv3cvINx3quPeocYmTgYDzFKcDArifBaHWNJFuJNSaysSi3Kjy8qzUktPsRoCvTbRGYp0eR8 YIzllcQbmhmYGpqYWRqYWpoZK4nzehZ0JAoJpCeWpGanphakFsH0MXFwSjUwNffsNnjHmzd/ 3qQri8/6tGackXs0L4wv1HxSGbOtRFRogE797gdrwo3cd9ulbvlxf+eba58/7ZDZ0ya/LfiQ QM82gfJMF65dBUe2PXM4ms4Wf6HESYbTsMzmyJP3n85ZSBRtmb9b6ptGbsJ+0fgDJ/vZzU49 2MLcLWq84HrGvflyj0+U/prqNv2byTu9HRrsn95z2ejVRv6YobxnSplDe2N2cOQBzQt3n+3J dZ/WWJHVWPx+qdDyA2lz7O/JSKR7PTy7+ejUS3YJfrlubqwbHsZ/Z3nFf25d/d2KOSkrpA7M cBCZL336Nn802+u952fMZ1B60/fit9HuOV8ZU8XeRVWvep7rdE3L1d5syplXdkosxRmJhlrM RcWJABD4sin5AgAA X-CMS-MailID: 20220825133513eucas1p1edf35903e69b0ce6197352b587d834a4 X-Msg-Generator: CA X-RootMTR: 20220825133513eucas1p1edf35903e69b0ce6197352b587d834a4 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220825133513eucas1p1edf35903e69b0ce6197352b587d834a4 References: Subject: [FFmpeg-devel] [FFmpeg-devel v10 4/9] 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Fs+Lx2Y2BdpU - 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 | 142 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 144 insertions(+) create mode 100644 libavformat/evcdec.c diff --git a/libavformat/Makefile b/libavformat/Makefile index 7e3f0e6794..a320cac22b 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -249,6 +249,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 31508b69f0..dfce49d149 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -148,6 +148,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..58dc671d24 --- /dev/null +++ b/libavformat/evcdec.c @@ -0,0 +1,142 @@ +/* + * 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 "rawdec.h" +#include "avformat.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 */ +#define MAX_SPS_CNT (16) /* defined value in EVC standard */ + +// NALU types +// @see ISO_IEC_23094-1_2020 7.4.2.2 NAL unit header semantics +// +#define EVC_NUT_NONIDR (0) /* Coded slice of a non-IDR picture */ +#define EVC_NUT_IDR (1) /* Coded slice of an IDR picture */ +#define EVC_NUT_SPS (24) /* Sequence parameter set */ +#define EVC_NUT_PPS (25) /* Picture paremeter set */ +#define EVC_NUT_APS (26) /* Adaptation parameter set */ +#define EVC_NUT_FD (27) /* Filler data */ +#define EVC_NUT_SEI (28) /* Supplemental enhancement information */ + +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) { + av_log(NULL, AV_LOG_ERROR, "Cannot get bitstream information. Malformed bitstream.\n"); + 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_NUT_SPS) + ev->got_sps++; + else if (nalu_type == EVC_NUT_PPS) + ev->got_pps++; + else if (nalu_type == EVC_NUT_IDR ) + ev->got_idr++; + else if (nalu_type == EVC_NUT_NONIDR) + 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 Thu Aug 25 13:35: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: 37478 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp344565pzh; Thu, 25 Aug 2022 06:36:07 -0700 (PDT) X-Google-Smtp-Source: AA6agR7QbzVcBlaWE4auWMvVyFUUN65/aHPqYUQ3JOWE3+B4Na1NnVg/a8a5/tSchlpj3OBAfXIY X-Received: by 2002:a05:6402:5205:b0:447:bcde:9353 with SMTP id s5-20020a056402520500b00447bcde9353mr2043242edd.343.1661434567507; Thu, 25 Aug 2022 06:36:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661434567; cv=none; d=google.com; s=arc-20160816; b=XYPbA/aBgyCZpdB7y2odrtRBdvW7y1xPpwDKULaEMmYpYUtsTk1nGASVF8Owxq9K0n lvW/vmBu6261W6Ukje2qZxIrVj7y3/OiHPaWf+kAuUbSOvLRBZWPvSfYWLl5KCam/WgV AVD6N6TSlyWg/aBQEaPhdAdTUeIaDJyeVh6Alep9Vt5XUL/oABip84KqyzCXgKTRW9SO R5ddr+smaoG0euTNymSkhWjftnjMQSxwqmNNcJJ3+GQ+7g2dCYGCSY0U13BPofrqQ1g3 xJZMy/Igu5XCSNJayDWVtUmjUzSk4VHlnNI8hUq3gtO+GAEpqjeAS2bl5j6c2wqmAuuL WkPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:references:cms-type:content-language :thread-index:mime-version:message-id:date:to:from:dkim-signature :dkim-filter:delivered-to; bh=9goeix0EMhkSM4Gtl7ZQHdwCwR9c6ul35qlKkBTNScM=; b=T+fr+YNUdNh50U1POyRd74K6yiVxQEb4NToPBejZ3LMK+/HVr8jk0lRMrericlqQeh w3vzzekhHoRYNRKQyhO1fA5aiz9oB+3yUz5/p5IEeOTi9bUMIQVCQ90dPtiNhppse3Ap UjjOWPGH3eAPUB6IbQZW7kbZpHz/uMTzwU1EbxDYt+SKMlFc2xKNvkn91km66vu9eAKg R8cWWTI5xdoi6MZsDMpsLF3Hagp1oKFDK1oTLK+wjHgbYROU5aH8vrvOuMiLdstF8ch3 cuqW1Ek+tDFMRq596HCN5J24blVazirzA4X7MfPrmGZUY2bUrAXLL7QVnyOd8hDjEI8y rgHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=Vh3xbQwg; 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 gt18-20020a1709072d9200b0073132e7e79bsi4692253ejc.784.2022.08.25.06.35.58; Thu, 25 Aug 2022 06:36:07 -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=Vh3xbQwg; 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 A18FF68BA23; Thu, 25 Aug 2022 16:35: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 E3C0868BA26 for ; Thu, 25 Aug 2022 16:35:17 +0300 (EEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220825133517euoutp01c2248339f5245d4ade8aea4ef90bf041~OmeQZJIaz2580225802euoutp01P for ; Thu, 25 Aug 2022 13:35:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220825133517euoutp01c2248339f5245d4ade8aea4ef90bf041~OmeQZJIaz2580225802euoutp01P DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1661434517; bh=GivYqDO/6Wv7APp+aFhRD7gWoH1AV08XMB6SsnBd6cw=; h=From:To:Subject:Date:References:From; b=Vh3xbQwguz6Mm3lyvxJQeyue9YElzNsRE996VWbmpiDa0VYY14DTz8CgVzHmg0eQ8 3MGgCV4J+auoJtvVEFK67t5KYI4HRvzQWUi5uW8paQQJ2Dmv8bPPcgAY1MDY7aDexb ldfSPr6/gn1+pFst786K4y6WM9PsPbl0358iIFB0= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220825133517eucas1p269cb68a58d2683da96cbc0fa020bf9c9~OmeQSuLpH3110831108eucas1p2j for ; Thu, 25 Aug 2022 13:35:17 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 04.65.07817.59A77036; Thu, 25 Aug 2022 14:35:17 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220825133516eucas1p2fe528f7ba802b8cd1093e508b1b4fff2~OmeP6m-gY3110331103eucas1p2f for ; Thu, 25 Aug 2022 13:35:16 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220825133516eusmtrp1db61ca15b0e5ba59dc9b5cca2eab4854~OmeP6DAEj1642116421eusmtrp1U for ; Thu, 25 Aug 2022 13:35:16 +0000 (GMT) X-AuditID: cbfec7f4-893ff70000011e89-9a-63077a955dfc Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 77.93.07473.49A77036; Thu, 25 Aug 2022 14:35:16 +0100 (BST) Received: from AMDN3260 (unknown [106.210.132.171]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220825133516eusmtip123d6a0e2959a2e79d98513abe9a25b54~OmePqiUHI1301713017eusmtip1W for ; Thu, 25 Aug 2022 13:35:16 +0000 (GMT) From: "Dawid Kozinski" To: Date: Thu, 25 Aug 2022 15:35:16 +0200 Message-ID: <014c01d8b887$832a1aa0$897e4fe0$@samsung.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: Adi4eMnhe8bOsqwgTg+3SlMsBLhLzg== Content-Language: pl X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBIsWRmVeSWpSXmKPExsWy7djP87pTq9iTDe53CVp8+3SG2YHR48+i zSwBjFFcNimpOZllqUX6dglcGZ9W/2AsON7JVDH9vVoD47HTjF2MnBwSAiYSq2YvY+9i5OIQ EljBKDHj5RQ2CGcSk8S1cxdZQKqEBCYySRzqFIbpmLXrAxNE0XJGiaX7z7NAOG1MEkc3vGID qWIT0JeYuegTmC0iICux+t8UMFtYwEFi0r91YDaLgKrEtJnz2EFsXgFLiVV/DjNC2IISJ2c+ AdvMLKAtsWzha2aIzQoSP58uY4WYqSexteclK0SNiMSNRy1Q/3xll+i5pgVhu0js+3mECcIW lnh1fAs7hC0jcXpyD9B8DiC7WOJQvwOEWSNx6Ec6RIW1xNvG44wgYWYBTYn1u/Qhwo4S8/rX MUJU80nceCsIsZ9PYtK26cwQYV6JjjYhCFNFoq9TDKJRSuLpsjlQX3hILP/3lm0Co+IsJM/O QvLsLCRPzUI4YQEjyypG8dTS4tz01GKjvNRyveLE3OLSvHS95PzcTYzAxHD63/EvOxiXv/qo d4iRiYPxEKMEB7OSCK/VMZZkId6UxMqq1KL8+KLSnNTiQ4zSHCxK4rzJmRsShQTSE0tSs1NT C1KLYLJMHJxSDUyWn3oPW+U91s8712mdsTGplF/sR2hyx5ZHX413PbjHVbbYXnGxqvxEv19x J9rmWVm/fsxbo6r/6u8kVX2r4L3p6lMtzjRN2VPGyjZxCfdyNRaRP4lq0h1L3jsv5eyvETdd uVL55kX75yH+ncnmoSYyK/8tlM0MvVn/7EjlV0Ud6Yu/bBWXNWjM51lz2HPfuevp62NbL7Ee Z5EM7lkj7xvwTPJwUfuD1bLZclG2vBN7hBOvTEta3HDA9IKkRGPbrms+tzxvL04rNLqRGim0 LzrxTrX96oOW3l7Sso8T2mI3f/l7NT008Eq+qmuPdeMLzcenEzgV09w7H7jOCqjRnRLV/Ijp oViyf5oMT2m/EktxRqKhFnNRcSIAiTEkiHsDAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrJLMWRmVeSWpSXmKPExsVy+t/xu7pTqtiTDb6dN7f49ukMswOjx59F m1kCGKP0bIryS0tSFTLyi0tslaINLYz0DC0t9IxMLPUMjc1jrYxMlfTtbFJSczLLUov07RL0 Mj6vn8xU0PGXsWJHx2PmBsbW/YxdjJwcEgImErN2fWDqYuTiEBJYyigxc/sKJoiElMTSpYug ioQl/lzrYoMoamGSeHK2iQ0kwSagLzFz0ScwW0RAVmL1vylgtrCAg8Skf+vAbBYBVYlpM+ex g9i8ApYSq/4cZoSwBSVOznzCAmIzC2hLPL35FM5etvA1M8RiBYmfT5exQszXk9ja85IVokZE 4sajFsYJjAKzkIyahWTULCSjZiFpWcDIsopRJLW0ODc9t9hQrzgxt7g0L10vOT93EyMwzLcd +7l5B+O8Vx/1DjEycTAeYpTgYFYS4bU6xpIsxJuSWFmVWpQfX1Sak1p8iNEU6LeJzFKiyfnA SMsriTc0MzA1NDGzNDC1NDNWEuf1LOhIFBJITyxJzU5NLUgtgulj4uCUamBS+HzFbt6U8ouZ T5Kn/n9oW6CwKWjLH/eJ9o9O73Nq0WRYL3n5zunJn1apaO0KL//wptNU4qOGluMhj/nOe9ie hPRUJ2rESG70lJBZblUcGDXx0K+WeS1blpToPDD04SuZt1tXcEfqnhOdVzLm2vdyNzt8fy08 3cFPKscx78L8AI+03XOPeIvq1705cDPuYJRA9Kd3R4Sn89o/XtDX+fR9jO/U1T9tN8x4Xnac O2Atx/dC9rNpt0JlO7K79HUsnnZciNqwzcQs8mOt62t5uVNaaSxy55ZNWLg2N8zu4kONNVoX nA87cLlatOcqT85rfmHTdLj4n57OOn2zr6z8gvO+HD4fZL6m6Tarl2N8bYUSS3FGoqEWc1Fx IgDzTttM/AIAAA== X-CMS-MailID: 20220825133516eucas1p2fe528f7ba802b8cd1093e508b1b4fff2 X-Msg-Generator: CA X-RootMTR: 20220825133516eucas1p2fe528f7ba802b8cd1093e508b1b4fff2 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220825133516eucas1p2fe528f7ba802b8cd1093e508b1b4fff2 References: Subject: [FFmpeg-devel] [FFmpeg-devel v10 5/9] 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: m7OYeBAsyUX4 - 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 | 601 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 687 insertions(+) create mode 100644 libavcodec/libxeve.c diff --git a/configure b/configure index 932ea5b553..8fe8bc0d49 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] @@ -1875,6 +1876,7 @@ EXTERNAL_LIBRARY_LIST=" libvorbis libvpx libwebp + libxeve libxml2 libzimg libzmq @@ -3398,6 +3400,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" @@ -6719,6 +6722,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 d36464d629..40496f760d 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -2892,6 +2892,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 86ec6d606b..3fb4aeb206 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 @@ -591,6 +599,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 @@ -930,6 +939,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 3d2e5d9bc2..24e58c77b4 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1102,6 +1102,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 6939a4e25f..4f9c0b5e63 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -802,6 +802,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..bb9c26e57c --- /dev/null +++ b/libavcodec/libxeve.c @@ -0,0 +1,601 @@ +/* + * 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 +} 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); + } + + /* 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 }, + { 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 Thu Aug 25 13:35:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawid Kozinski X-Patchwork-Id: 37479 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp344647pzh; Thu, 25 Aug 2022 06:36:17 -0700 (PDT) X-Google-Smtp-Source: AA6agR6O8SLvlgJM7OjjyJpqqGtUqT/TWA6tCkzVNVIEoSe+ifSpMUJLa7ybPuLnXDsadcRry9YP X-Received: by 2002:a17:907:a424:b0:73d:7f49:390b with SMTP id sg36-20020a170907a42400b0073d7f49390bmr2748840ejc.20.1661434577143; Thu, 25 Aug 2022 06:36:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661434577; cv=none; d=google.com; s=arc-20160816; b=kMotOGfzBsGiKyvRhq/bdMkzufU+naLhOz2nlysPXYwUNwAyJNU60Q9l4ez+MUwptR lC1g63lg3Qqyo5McwHoFrShZZ+fg4MTf6ykp6v0a4dHQMYrBBYp4dcU5HqyhlMrT1hnc pcEv5CmdWKg2dgvsFBPMpUGm7My68Xy387bGOvRSNlXEFOm1YDztsmIzj1yHV+e2iQ5d AIkinSnN06PT4Jabo6ki2GoKfAwIsyjM2oxM3ywLOZSMYIbsEf5ZjCfJZWhyrHRg4+P4 k4xVqmtZkMSaepyvPNZH7PmCwIKFhtBOD7o4QWvUuItuchy1RMxK4RI770M/9xBbluyT cfCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:references:cms-type:content-language :thread-index:mime-version:message-id:date:to:from:dkim-signature :dkim-filter:delivered-to; bh=030ACZI8J5bJKLuRvGLxtBGXsOEaQiXJG6vWpiszoGY=; b=cruZ5S63248e5rxIX5RWAQtxO6aoxYvzWdJMOkVkEn2RLqqXwFdwI6NKjewl6eDHw8 0sQRAIXi9z+NAIBwbuEMmEjLiAzaJxWRbqJpS4OzWDiA0yFrxyV3pJ+9GAlZL/8glLnA ogOr0rTezD73iXyzWX0zFjLpXZsOso3gcd7e4fKvzTvLEClnhIR24dik8CMAKRr5/NfZ 31iW9FGrcGmm080sfdPscbYF6PMNrQaofalMx9hy3tNwsOI1HP+Yw+RnChwl+8oJBfAh MZanYbodqnN9BZTauQiVVsRvXwL0jZoJyfWPd+MFOwA1Y7F0BT/VKxybjpD0/W2BPuBs B6Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=rbWx7t8x; 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 h20-20020a056402281400b0043d9ec0eb4fsi7157577ede.16.2022.08.25.06.36.09; Thu, 25 Aug 2022 06:36: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=rbWx7t8x; 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 9AF1A68BA4A; Thu, 25 Aug 2022 16:35:25 +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 D500968BA0C for ; Thu, 25 Aug 2022 16:35:23 +0300 (EEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220825133523euoutp0119227fd7e3497b453f987cb93f2ef12b~OmeV0gzxe2578525785euoutp01L for ; Thu, 25 Aug 2022 13:35:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220825133523euoutp0119227fd7e3497b453f987cb93f2ef12b~OmeV0gzxe2578525785euoutp01L DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1661434523; bh=pllGo/Nj7m/abXnBDpV4gzcEznnG0j0smFHwCq9HZHg=; h=From:To:Subject:Date:References:From; b=rbWx7t8xA6tykLtaXjF41g+qaaszTcLbBF90QM8gy72FVcwNz7HENlFR3vnjcihxE ezlajvq0SnG6ReiGfxzxyIFpXRLsWSPpsaCItFRMibu71HcFUUL259nEBSMRgNVucG xREycuEqNGXtqv2aQjnvEwXMl7fZgDepJMXsOimk= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220825133523eucas1p1e133199a9d831ea5c1a811898a4685d7~OmeVsrBw00258202582eucas1p15 for ; Thu, 25 Aug 2022 13:35:23 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id A4.87.29727.B9A77036; Thu, 25 Aug 2022 14:35:23 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220825133522eucas1p1dc4ac67c6add913f249b81d0d34ee5c7~OmeVJq-ZC0258202582eucas1p14 for ; Thu, 25 Aug 2022 13:35:22 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220825133522eusmtrp155014eec236314740cc2797421f8360b~OmeVJAu8l1614816148eusmtrp1W for ; Thu, 25 Aug 2022 13:35:22 +0000 (GMT) X-AuditID: cbfec7f2-205ff7000001741f-0e-63077a9b3da7 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 54.05.10862.A9A77036; Thu, 25 Aug 2022 14:35:22 +0100 (BST) Received: from AMDN3260 (unknown [106.210.132.171]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220825133522eusmtip2b0610b1a2c520f8195164b37d654ff8c~OmeU47cyn0517405174eusmtip2K for ; Thu, 25 Aug 2022 13:35:22 +0000 (GMT) From: "Dawid Kozinski" To: Date: Thu, 25 Aug 2022 15:35:22 +0200 Message-ID: <014d01d8b887$86818300$93848900$@samsung.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: Adi4eqTtDbcVgI/+SzOB9U8DQ/aMyQ== Content-Language: pl X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBIsWRmVeSWpSXmKPExsWy7djPc7qzq9iTDbpa2S2+fTrD7MDo8WfR ZpYAxigum5TUnMyy1CJ9uwSujL6H25gL9q9hrNh74RtTA+P++i5GTg4JAROJ50f3sHUxcnEI CaxglNjVtosVwpnEJHF15jQWCGcik8SKpvmMMC0dR2awg9hCAssZJY7e9YcoamOS+LRlDStI gk1AX2Lmok9sILaIgKzE6n9TwGxhAQeJ/pVfwJpZBFQlPt5+zwRi8wpYSmzZvwnKFpQ4OfMJ C4jNLKAtsWzha2aIxQoSP58uY4WYqSfxf/l2qBoRiRuPWhhBjpAQ+MgucXx9L1SDi0Tz3zlQ VwtLvDq+hR3ClpE4PbkHqJkDyC6WONTvAGHWSBz6kQ5RYS3xtvE4I0iYWUBTYv0ufYiwo8Sy TwdZIar5JG68FYQ4gE9i0rbpzBBhXomONiEIU0Wir1MMolFK4umyOVAVHhLfj8lPYFScheTZ WUienYXkqVkIFyxgZFnFKJ5aWpybnlpsmJdarlecmFtcmpeul5yfu4kRmBhO/zv+aQfj3Fcf 9Q4xMnEwHmKU4GBWEuG1OsaSLMSbklhZlVqUH19UmpNafIhRmoNFSZw3OXNDopBAemJJanZq akFqEUyWiYNTqoFp4vqbLMsrXpvGLf9mbhk8ozHX9PAEJ8eUGUfWTFbesHm6U+H5WYu0j1y3 P9Nc8kVKxZrLVs5r0c2KwNcRK1SPnyld539mfezMxZNvmboalPKfbN3zg+8Ef8ura9wM2cFz vzbO1uDYqL/q9oLmaS3vxO5q7EzT2sJur2O19VLH9+nM7428r6mbaa1pNA1/FG9/ZZIPv/JW U7/v7kW9Epw2Bf/P3D6QtbcqcK8T6yzWB3UC82OfpZyweGPPrDXxoFG22M3I9tMrrj4u3ypb ynPnevPez3/PZh8+9+/Py/Bq/xTWrbxrufh2WQheEfyc83mubm5XpUd51EXTg6U3DvVUznxh xNlbIfuh6fAP19URSizFGYmGWsxFxYkAeKIDW3sDAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBLMWRmVeSWpSXmKPExsVy+t/xe7qzqtiTDeavl7f49ukMswOjx59F m1kCGKP0bIryS0tSFTLyi0tslaINLYz0DC0t9IxMLPUMjc1jrYxMlfTtbFJSczLLUov07RL0 Mra2/WAr+L+UseL0wTksDYzfK7oYOTkkBEwkOo7MYO9i5OIQEljKKHG98QQ7REJKYunSRYwQ trDEn2tdbBBFLUwSR07vAEuwCehLzFz0iQ3EFhGQlVj9bwqYLSzgING/8gvYIBYBVYmPt98z gdi8ApYSW/ZvgrIFJU7OfMICYjMLaEs8vfkUzl628DUzxGIFiZ9Pl7FCzNeT+L98O1SNiMSN Ry2MExgFZiEZNQvJqFlIRs1C0rKAkWUVo0hqaXFuem6xkV5xYm5xaV66XnJ+7iZGYJBvO/Zz yw7Gla8+6h1iZOJgPMQowcGsJMJrdYwlWYg3JbGyKrUoP76oNCe1+BCjKdBvE5mlRJPzgXGW VxJvaGZgamhiZmlgamlmrCTO61nQkSgkkJ5YkpqdmlqQWgTTx8TBKdXA5LXr/uKLJ3NdJvu1 7/Q3KlesszNtOMDIK3/X7E9F2Hpn8QlOG3oaLLbZ5C46tuRuqOik2uN8m0sMv8d5xRWnLA14 nzAtRlA1RfXF8aJnmptnOZZt38it5CMVZ5bA9yqg5crhC8sY3KbKpL+4tPZaTLyovOO9s9Kv 8u2YilOzC6cXrMzcLPFmpeZDdT+RhwwLjcvitzst0Vrk/mZi9sm5NVecnS+tmO6wMd7WJeFu +I2J0fM7Veqt/+hGTQ1203dOV1VjeXP4j0B4eD5DcJ1lhw8Ht9TRezuvzdP+Vvr+h3uTV5Ny WMrCKzpt7a9e3n8ZNX/e2yLvdIb1Dlpbpzz9/oKJyahFXdR378JOTXYlluKMREMt5qLiRABG oaWx+wIAAA== X-CMS-MailID: 20220825133522eucas1p1dc4ac67c6add913f249b81d0d34ee5c7 X-Msg-Generator: CA X-RootMTR: 20220825133522eucas1p1dc4ac67c6add913f249b81d0d34ee5c7 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220825133522eucas1p1dc4ac67c6add913f249b81d0d34ee5c7 References: Subject: [FFmpeg-devel] [FFmpeg-devel v10 6/9] 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: a+rDcqVSyAZN - 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 | 422 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 461 insertions(+), 1 deletion(-) create mode 100644 libavcodec/libxevd.c diff --git a/configure b/configure index 8fe8bc0d49..b191d2d9db 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] @@ -1876,6 +1877,7 @@ EXTERNAL_LIBRARY_LIST=" libvorbis libvpx libwebp + libxevd libxeve libxml2 libzimg @@ -3400,6 +3402,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" @@ -6722,6 +6725,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 3fb4aeb206..89236047ea 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 @@ -940,7 +948,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 24e58c77b4..ea9566b20c 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1102,6 +1102,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 4f9c0b5e63..fc2882c7fd 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -803,6 +803,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..cddbfbcb1c --- /dev/null +++ b/libavcodec/libxevd.c @@ -0,0 +1,422 @@ +/* + * 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" + +#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 Thu Aug 25 13:35:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawid Kozinski X-Patchwork-Id: 37480 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp344691pzh; Thu, 25 Aug 2022 06:36:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR5r1Lext8gocfvsDX8qja4tZh5FWadHn7tzM4FuyTZPAcfFb0MDDG9YxaJP5jHS0RNdqQSa X-Received: by 2002:a17:906:9b0a:b0:730:d37b:4712 with SMTP id eo10-20020a1709069b0a00b00730d37b4712mr2367144ejc.537.1661434580958; Thu, 25 Aug 2022 06:36:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661434580; cv=none; d=google.com; s=arc-20160816; b=DXCYq2vHn9aC3jAcbJsL71ykb/Tyvmw47TV1CLb55lMY0T1LDgVgDSWqwcBAQvalCM zcQZBkYGkMGGnQY1wgrARMbjWt5Qg75xw7puDQhs/h07QVwH0mC1oxvK8742cq6HBsZ0 Eg1tKfMQCfOBUCbIDQNFAD0NHyJDqUxUuUZgZNtgnk8v01sbJ/boik8rcgk6qCYso00j bLb2d0O2s6lYzv/TMkg68xkudECQuWvTwUK0ta3C/aPtSy2CY9QvaKXVe0Rq/yQfEveU nE8613moRtb0TNMpRCpV1cbdecDu8jBC8PlGfPcFr3i8bQW8yLiDTaj8R18aWz/hJrXl 0B4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:references:cms-type:content-language :thread-index:mime-version:message-id:date:to:from:dkim-signature :dkim-filter:delivered-to; bh=kwuoznKXtq3Boz4RZOhnTyW55J0+9x+ms9z2q0IMnfI=; b=Vf4Mi0vB2GwoihV1a/xNH3I4aMA9ERCZl5qrPPXrtAyY8jYRp+vTuXr4b8Ak+ssERO v1M7xEy25OXotz4C21pjgCd5fjTtQyzPpuBuUG/dqVV2rtb79W0ehRUryNgYic8ufbUu lhUWQp2Z6t5b/zRXocKjWFIXnTs266YmgJ0X1wfOpmBEXu6chPMsaidV19uaWNO98xpA F4OiMAfM5YXLsxeITCVaSS5DXdRUL+RaBLpR17+SSLESV8YQh1e0SZDUtZDs2QqLsQ6w zxnSlK7IK6R8NDKIhEskHcp2tOebE85yMqFdwgu3faK5nPUO5zrA8CP3rNkeqpv15Ugh xTUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=Gd1gKLpv; 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 s24-20020a508d18000000b0043d4293adbasi5828562eds.506.2022.08.25.06.36.20; Thu, 25 Aug 2022 06:36: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=Gd1gKLpv; 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 BBE4B68BA0C; Thu, 25 Aug 2022 16:35:28 +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 69EA568BA3B for ; Thu, 25 Aug 2022 16:35:27 +0300 (EEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220825133526euoutp0100a3b6b742399533e1a82237b4180de1~OmeZGlxqE2180521805euoutp01j for ; Thu, 25 Aug 2022 13:35:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220825133526euoutp0100a3b6b742399533e1a82237b4180de1~OmeZGlxqE2180521805euoutp01j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1661434526; bh=wq7XCTbD7EXg+uXIvOcEZAxgoRkW6AbLc3CykCYcXjs=; h=From:To:Subject:Date:References:From; b=Gd1gKLpvgfWuyHKYCyE6nwt60yRduatvfUC14OEHRhi8gJC0lGZPUWztDgu+NAnBR ZDzNu0BY+AZLSjMlnEQ66CinysWHqu88S3Wz76YWc8zdBaIUepotuKpPf8ng20UBIW qZrGqM0i8Wp3DWe6mGMCRuyGKazXv+BhAUJpeaYc= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220825133526eucas1p1d9275b8c663d758d51c065ea38baa477~OmeY3mgQE1616916169eucas1p1m for ; Thu, 25 Aug 2022 13:35:26 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 66.87.29727.E9A77036; Thu, 25 Aug 2022 14:35:26 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220825133526eucas1p25db7e811b6777eecf9338dcfdc896217~OmeYYEWDS0167801678eucas1p2Y for ; Thu, 25 Aug 2022 13:35:26 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220825133526eusmtrp11f69bc2437afe17f9f9ce6e2cd291e27~OmeYXhARN1642116421eusmtrp1n for ; Thu, 25 Aug 2022 13:35:26 +0000 (GMT) X-AuditID: cbfec7f2-205ff7000001741f-1a-63077a9e7d99 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 7D.93.07473.D9A77036; Thu, 25 Aug 2022 14:35:26 +0100 (BST) Received: from AMDN3260 (unknown [106.210.132.171]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220825133525eusmtip2b250e69299a2e0b541cef6e7f08ea5a6~OmeYI1_Jf0341403414eusmtip2T for ; Thu, 25 Aug 2022 13:35:25 +0000 (GMT) From: "Dawid Kozinski" To: Date: Thu, 25 Aug 2022 15:35:25 +0200 Message-ID: <014e01d8b887$8895e410$99c1ac30$@samsung.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: Adi4e5eFRfWMrQOcRH2hleRATPGYbQ== Content-Language: pl X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOIsWRmVeSWpSXmKPExsWy7djP87rzqtiTDTZtl7X49ukMswOjx59F m1kCGKO4bFJSczLLUov07RK4Mo68bWEvWPiYsWLt3sesDYwvljB2MXJySAiYSMxovcDUxcjF ISSwglFi3+sWFpCEkMAkJon/93ghEhOZJF78OALX8WH7TKiO5YwSmxvesUA4bUwSx6cdZQKp YhPQl5i56BMbiC0iICux+t8UMFtYIEBi5aVOoBoODhYBVYm5d2NAwrwClhLrD/5igbAFJU7O fAJmMwtoSyxb+JoZYrGCxM+ny1ghRupJ3Fp6kR2iRkTixqMWRpAbJAQ+skts3nuXEWS+hICL RNcZEYheYYlXx7ewQ9gyEqcn97BAlBRLHOp3gDBrJA79SIeosJZ423gcbAizgKbE+l36EGFH iT0bbjNDVPNJ3HgrCLGfT2LStulQYV6JjjYhCFNFoq9TDKJRSuLpsjlQFR4Sm6eVTGBUnIXk 11lIfp2F5KdZCBcsYGRZxSieWlqcm55abJiXWq5XnJhbXJqXrpecn7uJEZgWTv87/mkH49xX H/UOMTJxMB5ilOBgVhLhtTrGkizEm5JYWZValB9fVJqTWnyIUZqDRUmcNzlzQ6KQQHpiSWp2 ampBahFMlomDU6qBSfPV3soctS6FqzuL+I3YfIym+fJu4tLYcX1F9NOVN1RE5vxxW7TtnMb1 l19ZleuadjSv6J6wNJphsahlnySDNmsq68zzyq8SJ1u7GDyy3nz604ap1vZMxcknYs0v/cq9 yflbMurS18xLet8burmuhzn+iuS8u1Lu22PphZxFmyd4F/eZXjmVcaPRIcP/gYaqXcTSI+vU zwq9qWIyE+W51BL/7bJfFb/eZUWf+6kHT2x6U+IrEqR61HVGQU3462090zTidiirT+iom154 +9MRQ94VJ6Wftv50Wx52VO9g2/ZK5VNWGec0MtwmhHMy1R42qDXVKvuXWfh56qUZ8Wl9lkLf n2aYG0lFPve9dPCHEktxRqKhFnNRcSIAKMHzpnoDAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGLMWRmVeSWpSXmKPExsVy+t/xe7rzqtiTDV5VWXz7dIbZgdHjz6LN LAGMUXo2RfmlJakKGfnFJbZK0YYWRnqGlhZ6RiaWeobG5rFWRqZK+nY2Kak5mWWpRfp2CXoZ P45NYS14dYexYlmTeQPj/HmMXYycHBICJhIfts9k6mLk4hASWMoo0XLjMVRCSmLp0kVQtrDE n2tdbBBFLUwSfWfXsIAk2AT0JWYu+sQGYosIyEqs/jcFzBYW8JM48v8fkM3BwSKgKjH3bgxI mFfAUmL9wV8sELagxMmZT8BsZgFtiac3n8LZyxa+ZobYqyDx8+kyVojxehK3ll5kh6gRkbjx qIVxAqPALCSjZiEZNQvJqFlIWhYwsqxiFEktLc5Nzy021CtOzC0uzUvXS87P3cQIDPBtx35u 3sE479VHvUOMTByMhxglOJiVRHitjrEkC/GmJFZWpRblxxeV5qQWH2I0BXptIrOUaHI+MMby SuINzQxMDU3MLA1MLc2MlcR5PQs6EoUE0hNLUrNTUwtSi2D6mDg4pRqYdum8+uAYfbU22Jvj m5Zyh5HmH5uOxd7mnqzZa+cp7HizofjvH47rAqFJyq6ctwTzRQTf7XklNEXo6qKlf6+/1vF1 Ll+culj+e+2Cd9I9fI5vnt6fn3N53o6PTx/wpr6QfrQvX7Lg09sHcy6UGkf82qPTHmc+g+G3 18LUlv2hzF+YA/ceuGB+N28J1/Q5hxmdC88Kz11wcXdMr1Rex9s1js0BJ0Jurpvi0fT6Z/95 dYHpuv27Q7+mzzMsqTuVb6B04a2gSMrCl0wvF0sIh67+mm9dtVb8unzxge2/P3M79KSfTE24 kFpx9vqylC8sIj1FXr9kbr1R3/Bhf/TWO4EGh6QrElh2zJ69ds8jh+fhO5RYijMSDbWYi4oT AfahmT75AgAA X-CMS-MailID: 20220825133526eucas1p25db7e811b6777eecf9338dcfdc896217 X-Msg-Generator: CA X-RootMTR: 20220825133526eucas1p25db7e811b6777eecf9338dcfdc896217 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220825133526eucas1p25db7e811b6777eecf9338dcfdc896217 References: Subject: [FFmpeg-devel] [FFmpeg-devel v10 7/9] 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 24jlB4f/zNIj - 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 | 460 ++++++++++++++++++++++++++++++++++++++++ libavformat/evc.h | 147 +++++++++++++ libavformat/isom_tags.c | 2 + libavformat/movenc.c | 35 ++- 5 files changed, 644 insertions(+), 2 deletions(-) create mode 100644 libavformat/evc.c create mode 100644 libavformat/evc.h diff --git a/libavformat/Makefile b/libavformat/Makefile index a320cac22b..bb4e96e460 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -360,7 +360,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..153fe6daeb --- /dev/null +++ b/libavformat/evc.c @@ -0,0 +1,460 @@ +/* + * 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 "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 */ + +// 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; + +typedef struct EVCNALUnitArray { + uint8_t array_completeness; + uint8_t NAL_unit_type; + uint16_t numNalus; + uint16_t *nalUnitLength; + uint8_t **nalUnit; +} 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: + * 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 *array; +} 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; + 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 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; +} + +static int evcc_array_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size, + uint8_t nal_type, int ps_array_completeness, + EVCDecoderConfigurationRecord *evcc) +{ + int ret; + uint8_t index; + uint16_t numNalus; + EVCNALUnitArray *array; + + for (index = 0; index < evcc->num_of_arrays; index++) + if (evcc->array[index].NAL_unit_type == nal_type) + break; + + if (index >= evcc->num_of_arrays) { + uint8_t i; + + ret = av_reallocp_array(&evcc->array, index + 1, sizeof(EVCNALUnitArray)); + if (ret < 0) + return ret; + + for (i = evcc->num_of_arrays; i <= index; i++) + memset(&evcc->array[i], 0, sizeof(EVCNALUnitArray)); + evcc->num_of_arrays = index + 1; + } + + array = &evcc->array[index]; + 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] = 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) + 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) +{ + uint8_t i; + + for (i = 0; i < evcc->num_of_arrays; i++) { + evcc->array[i].numNalus = 0; + av_freep(&evcc->array[i].nalUnit); + av_freep(&evcc->array[i].nalUnitLength); + } + + evcc->num_of_arrays = 0; + av_freep(&evcc->array); +} + +static int evcc_write(AVIOContext *pb, EVCDecoderConfigurationRecord *evcc) +{ + uint8_t i; + uint16_t j, aps_count = 0, sps_count = 0, pps_count = 0; + + 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 (i = 0; i < evcc->num_of_arrays; i++) { + av_log(NULL, AV_LOG_TRACE, "array_completeness[%"PRIu8"]: %"PRIu8"\n", + i, evcc->array[i].array_completeness); + av_log(NULL, AV_LOG_TRACE, "NAL_unit_type[%"PRIu8"]: %"PRIu8"\n", + i, evcc->array[i].NAL_unit_type); + av_log(NULL, AV_LOG_TRACE, "numNalus[%"PRIu8"]: %"PRIu16"\n", + i, evcc->array[i].numNalus); + for (j = 0; j < evcc->array[i].numNalus; j++) + av_log(NULL, AV_LOG_TRACE, + "nalUnitLength[%"PRIu8"][%"PRIu16"]: %"PRIu16"\n", + i, j, evcc->array[i].nalUnitLength[j]); + } + + /* + * We need at least one SPS. + */ + for (i = 0; i < evcc->num_of_arrays; i++) + switch (evcc->array[i].NAL_unit_type) { + case EVC_APS_NUT: + aps_count += evcc->array[i].numNalus; + break; + case EVC_SPS_NUT: + sps_count += evcc->array[i].numNalus; + break; + case EVC_PPS_NUT: + pps_count += evcc->array[i].numNalus; + break; + default: + break; + } + 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 (i = 0; i < evcc->num_of_arrays; i++) { + /* + * bit(1) array_completeness; + * unsigned int(1) reserved = 0; + * unsigned int(6) NAL_unit_type; + */ + avio_w8(pb, evcc->array[i].array_completeness << 7 | + evcc->array[i].NAL_unit_type & 0x3f); + + /* unsigned int(16) numNalus; */ + avio_wb16(pb, evcc->array[i].numNalus); + + for (j = 0; j < evcc->array[i].numNalus; j++) { + /* unsigned int(16) nalUnitLength; */ + avio_wb16(pb, evcc->array[i].nalUnitLength[j]); + + /* bit(8*nalUnitLength) nalUnit; */ + avio_write(pb, evcc->array[i].nalUnit[j], + evcc->array[i].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; + unsigned char *bits = (unsigned char *)data; + int bytes_to_read = size; + + 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) { + uint8_t *nalu_buf = NULL; + 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); + nalu_buf = bits; + + switch (nalu_type) { + case EVC_APS_NUT: + case EVC_SPS_NUT: + case EVC_PPS_NUT: + ret = evcc_array_add_nal_unit(nalu_buf, nalu_size, nalu_type, ps_array_completeness, &evcc); + if (ret < 0) + goto end; + else if (nalu_type == EVC_SPS_NUT) + ret = evcc_parse_sps(nalu_buf, nalu_size, &evcc); + if (ret < 0) + goto end; + break; + default: + break; + } + + bits += 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..dfe038cc80 --- /dev/null +++ b/libavformat/evc.h @@ -0,0 +1,147 @@ +/* + * 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" + +/** + * @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, + EVC_IDR_NUT = 1, + 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, + EVC_PPS_NUT = 25, + EVC_APS_NUT = 26, + EVC_FD_NUT = 27, + EVC_SEI_NUT = 28, + 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 +}; + +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, + + // 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, +}; + +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 362cb77e8f..98f866094b 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 c8b2e141cb..93e4f64a63 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) { @@ -2280,6 +2308,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) { @@ -6030,7 +6061,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; @@ -7689,6 +7721,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 Thu Aug 25 13:35:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawid Kozinski X-Patchwork-Id: 37481 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp344800pzh; Thu, 25 Aug 2022 06:36:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR4IZ+/ETYsGnwyICDin7mEzdA05fIPH97IiHLuMEnLfg/nCX5sCYZidlR08hq4ffudaD/iP X-Received: by 2002:a05:6402:5203:b0:446:a378:54a5 with SMTP id s3-20020a056402520300b00446a37854a5mr3219647edd.321.1661434595008; Thu, 25 Aug 2022 06:36:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661434595; cv=none; d=google.com; s=arc-20160816; b=dxT2YhvciCBvrPZEVEQYB03XMtjq6VBEqUfwL5V5QFggx9UxDimEPsJK80ZyZ9Uc2T RlhYCXYByfM71gQx4Va4H7VqoJXUDQku/IDhnVh15zCi0H4jEzf3NDlPNtvKQfL/+A20 exEfBNjNBQc7wAA+HR9UaqgutS22/XLS0bbCfCbucF+zuL1u3VxJawdHSR0o9qrBJjqo HCxUE1zJvb7xYU93/MqfPAIlxX1ydHhJsYR2zJmgCadVFfpkaNrQyxiBJmO0EITruF4D qHjjgxVJV1X07ImYkXURMn065BJjQtl83DgwBPtrTBtpEMJgnghdilCkzE7VPRjKAnXH NY+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:references:cms-type:content-language :thread-index:mime-version:message-id:date:to:from:dkim-signature :dkim-filter:delivered-to; bh=UDdJqk8Q/DyrS500ObtXu6K20jsjW6B82PBzypJTgYU=; b=u7UX1bqo7Bj1IIl9KCDOSdRMPeBvEXvKYCeaG2wyh39RnosFj8ZGvoO+hmOXosGKtv WElVgIVAPqyMDb4u0al6qWmDsYzWSU+qJrYCntnxxu+yHHPtz73uY8pkg6hEgBQ1egD+ PjhspTVzc1KFZnWEaS3vNUVOg0C29lI1CdQ8G+QiFq8+H4IbYwtwyhSD9IDPnY0tWSq6 PX5inFAHhFNzPJDAyIUjdJK4fVQ1U+WMV4QE3jBpCdhxTtxw6bCTAWUKx5LikMUg6Fdq 3F1nY7PDsGzdjV0aJsmWhouNNwGfnnErwonl1zu0A4mxETm4T2yUsWwubHfkCVh8KZp3 RzAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=k4lMPOHm; 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 nd39-20020a17090762a700b0073dd47c3873si1071626ejc.878.2022.08.25.06.36.30; Thu, 25 Aug 2022 06:36:34 -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=k4lMPOHm; 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 D792B68BA5A; Thu, 25 Aug 2022 16:35:35 +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 9785068BA55 for ; Thu, 25 Aug 2022 16:35:30 +0300 (EEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220825133530euoutp01097c15ef84d31140f497350633f1b224~OmecNpor42578525785euoutp01Q for ; Thu, 25 Aug 2022 13:35:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220825133530euoutp01097c15ef84d31140f497350633f1b224~OmecNpor42578525785euoutp01Q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1661434530; bh=oXDdVm1ae2Zy/rv5gAhagfo9wgaRR/hqzj7BtMs6r48=; h=From:To:Subject:Date:References:From; b=k4lMPOHmIRe56PY3UyA4RQ7Nj7/WEvGXI1d+KuyYg/cpjezQIni9d/17nHBZWbKAM s3MPlTUiOqT174ue5ZeZIEfN06pWmWH+DOo3pNjATk9lJz3TJognvtzZI37xFFUpvq dZTVnk2i84kS4SsYk2ZHCAveTeUt8ZQO4v0UIQXs= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220825133530eucas1p1a5cb60cf08d6ebfc726092e194a86736~OmecClpCi1815218152eucas1p1W for ; Thu, 25 Aug 2022 13:35:30 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 99.87.29727.1AA77036; Thu, 25 Aug 2022 14:35:29 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220825133529eucas1p29fd7a315ecf2c40823755ca9f3895d4f~OmebzZ8xf0167801678eucas1p2b for ; Thu, 25 Aug 2022 13:35:29 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220825133529eusmtrp1da880eeeb23fea2a98cdb09dec6feef2~Omeby46Z21642116421eusmtrp12 for ; Thu, 25 Aug 2022 13:35:29 +0000 (GMT) X-AuditID: cbfec7f2-205ff7000001741f-2a-63077aa16cdd Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 6F.93.07473.1AA77036; Thu, 25 Aug 2022 14:35:29 +0100 (BST) Received: from AMDN3260 (unknown [106.210.132.171]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220825133529eusmtip218f46e8e3c27d012b5d1231360f6acfe~Omebk4Uv30117601176eusmtip2N for ; Thu, 25 Aug 2022 13:35:29 +0000 (GMT) From: "Dawid Kozinski" To: Date: Thu, 25 Aug 2022 15:35:29 +0200 Message-ID: <014f01d8b887$8ac917c0$a05b4740$@samsung.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: Adi4fJtlUvRu6e6jTTmCMljya68k0A== Content-Language: pl X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrJIsWRmVeSWpSXmKPExsWy7djPc7oLq9iTDbZcsrb49ukMswOjx59F m1kCGKO4bFJSczLLUov07RK4Mnp2X2AruMNWcbZ1PmMD4xbWLkZODgkBE4nvN48zdTFycQgJ rGCUmHttNSuEM4lJ4tjeSYwQzkQmiYXbO9hgWvYdP8ICkVjOKNH4vAmqqo1J4vurXnaQKjYB fYmZiz6BdYgIyEqs/jcFzBYWCJKYdOgyE4jNIqAqser7GRYQm1fAUuLl429MELagxMmZT8Di zALyEtvfzmGG2Kwg8fPpMlaImXoSmxe2sEHUiEjceNQCdoSEwEd2iU8nbzNBNLhIHDryHups YYlXx7ewQ9gyEqcn9wAt4ACyiyUO9TtAmDUSh36kQ1RYS7xtPM4IEmYW0JRYv0sfIuwosf7i WnaIaj6JG28FIQ7gk5i0bTozRJhXoqNNCMJUkejrFINolJJ4ugzmDQ+JnesuM09gVJyF5NtZ SL6dheSrWQgnLGBkWcUonlpanJueWmyYl1quV5yYW1yal66XnJ+7iRGYGk7/O/5pB+PcVx/1 DjEycTAeYpTgYFYS4bU6xpIsxJuSWFmVWpQfX1Sak1p8iFGag0VJnDc5c0OikEB6Yklqdmpq QWoRTJaJg1Oqgcm6zKxV3SD4lXXBowRWibvZV/bmsU/gWva876jX0vsnLnIVtmfeaPtlcv2k ML/1pXeCsrqpivLv1widc79dzW6o7f52zu5Ttvl3C++tuSLr9u6N/Z/tCe5HXG58u860erNf pgBLxZm15xboKYlOcDmxfJrJo7QjJyVi/vf6ynPuV+MKX3d+hapY+3/HJyzHnj+b++KCEZvs 0sw1T2W89lSY3pyg6t9Ydknep1j16+uHUlXPj97KnPaC+8YZ2W0dk5Kzjpv9FFy3ZOZBjwx5 OZ1vxQXlRfrG16rnzFWv5vw1MaFE8xyj6rbYY9XTtmY2f9vxouppxkXOedYJq/d637C7ffrK LWXt1RdiKnW63sYqsRRnJBpqMRcVJwIAzmxzDnwDAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOLMWRmVeSWpSXmKPExsVy+t/xe7oLq9iTDTZd1rb49ukMswOjx59F m1kCGKP0bIryS0tSFTLyi0tslaINLYz0DC0t9IxMLPUMjc1jrYxMlfTtbFJSczLLUov07RL0 Mnp2X2AruMNWcbZ1PmMD4xbWLkZODgkBE4l9x4+wdDFycQgJLGWUODZxCjNEQkpi6dJFjBC2 sMSfa11sEEUtTBITV61nA0mwCehLzFz0CcwWEZCVWP1vCpgtLBAg0TThB5jNIqAqser7GRYQ m1fAUuLl429MELagxMmZT8DizALaEk9vPoWy5SW2v50DdYSCxM+ny1gh5utJbF7YwgZRIyJx 41EL4wRGgVlIRs1CMmoWklGzkLQsYGRZxSiSWlqcm55bbKhXnJhbXJqXrpecn7uJERji2479 3LyDcd6rj3qHGJk4GA8xSnAwK4nwWh1jSRbiTUmsrEotyo8vKs1JLT7EaAr020RmKdHkfGCU 5ZXEG5oZmBqamFkamFqaGSuJ83oWdCQKCaQnlqRmp6YWpBbB9DFxcEo1MHmkzz3RqZ1grm8s uPtl4FbFyQI8V1YdUv1jeHQS+9Z73gwpdckxYbPO6a+eOGGnn3HkOf4vE/efd9g6RaJNsLG3 bcMjzd3pBkGvdfjZPT3m7gtIadoTGrapolRscV2v/RnJQOcVlw6G9TGviPaVUXywffmcky6L tvJaM88NrptvNrWRhzVi/3++zS/5p/z5JXRnwraEVe0sAtc/s18uWTFrt1D9TV/Gpe6s1qsP vhbQFYkXv2j3Z6WC8h3F6uzQwjApvbo5RovClgde7F7jtPDCItnGWA2/eWL7ZTay+hY9T7we MKc5bv6ktLPPaliOc3/zTmZ77fXxTkeixZ39/w4HKJTMOvlJTCSwpbrznxJLcUaioRZzUXEi AGGQCFr6AgAA X-CMS-MailID: 20220825133529eucas1p29fd7a315ecf2c40823755ca9f3895d4f X-Msg-Generator: CA X-RootMTR: 20220825133529eucas1p29fd7a315ecf2c40823755ca9f3895d4f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220825133529eucas1p29fd7a315ecf2c40823755ca9f3895d4f References: Subject: [FFmpeg-devel] [FFmpeg-devel v10 8/9] 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Cr6FmSyIlrfR - Added evc extension to the list of extensions for ff_mov_demuxer Signed-off-by: Dawid Kozinski --- libavformat/mov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 1d8c5b2904..be9501655b 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -9119,7 +9119,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 Thu Aug 25 13:35: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: 37482 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp344920pzh; Thu, 25 Aug 2022 06:36:47 -0700 (PDT) X-Google-Smtp-Source: AA6agR574HmVl9Tldqi1SJj4SGJIGyzE6zbQbcN569QmJ+PggE8Nb6H/6Z51JUEgg5sLWQxWlgKo X-Received: by 2002:a17:906:6a0a:b0:73d:6c6a:1b8f with SMTP id qw10-20020a1709066a0a00b0073d6c6a1b8fmr2520422ejc.240.1661434607072; Thu, 25 Aug 2022 06:36:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661434607; cv=none; d=google.com; s=arc-20160816; b=gDqfEnxBJc48giaR55iEZpoU5xeH9Wrkq5ojNkeSWq++qFvpLLXITFKpUu9toZ837o 51vPaBdJLwLckdYP00nGySEBwyQypvX0PvrTKfUK1FI8QOrv4nVu3l+XcW/pO0IpE0/V KeMxG6kYsuN6nFSQSUhP6tNTXn3iTDRuNz0Q1kaGRMxGNJHFk6LssS5wkiry2j6opoDK ZAKtUE+LgImvJ6hkfvmXyjXn8yBlpgH1SpU+bidOKJyF3cRNns3yiXZiY/JiuMuH+pkC zl1hsYwvVKM0632CTRbK5MI4LjYE+0qjUH1lJX1OiHsdv/E7nEzU3dRLsnw7JG+yiufL yRWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:references:cms-type:content-language :thread-index:mime-version:message-id:date:to:from:dkim-signature :dkim-filter:delivered-to; bh=Wq6vwcLyPa4t3hEOpl/0drWL5foboa3L3tR/xhm6hfo=; b=Bmdr2LN7YwMZenaUGqyck+u711+M359nsvUXYp6XhxDMwmPGf19U5XV1SlP6e85k6O ygjs3hTF+9KMcDvt5N2W8aq43S/OIkSk3ptYIfqCKOFkvMYnKwmbYprM4EujKy1P/y2L 28aY86m4sUHlgM+9Q8qZkwZ0UOmXUpu9FCcCuBwdSvhJf0t1pAVO4yRkJ8JVcY5kSZj1 jaU2ZmY9+FWcybbKggHgLTx5MJPsL6CPEOQ+G75U1yIq1zs+VXCuV/Lemv2ibxyYR775 HRNWY9haX1U4UcYySW3ex/ZJGZSVmRaJv7pQoMz5l+B69GvgzoaqMIgYUD6Aig2mFG6q XvTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=EVhenYSf; 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 b12-20020a056402084c00b0043da4dd1b2dsi7310065edz.575.2022.08.25.06.36.40; Thu, 25 Aug 2022 06:36:47 -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=EVhenYSf; 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 0CD4F68BA59; Thu, 25 Aug 2022 16:35:39 +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 F08C868BA5B for ; Thu, 25 Aug 2022 16:35:36 +0300 (EEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220825133536euoutp01c982e564abcbb0943b9498bb7f1e4fea~OmeiDBBuf2578825788euoutp01U for ; Thu, 25 Aug 2022 13:35:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220825133536euoutp01c982e564abcbb0943b9498bb7f1e4fea~OmeiDBBuf2578825788euoutp01U DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1661434536; bh=uh/8lOTt4CHw66kFLmoBPcdNFDTAztd+5fI8CpejSOE=; h=From:To:Subject:Date:References:From; b=EVhenYSfWhsi0h0tKUJJxLrQkrI/1Cloy3TPXudpT3W/w+nD7UT4W1CZ6st3SdnN8 WNf9AXylsvv7ucqkHSvFoeB4b4HuoBYBmbi073vZhowbMq+4ULrLAB+bsGvOex7k8G fekGoabK7FsLRYK35M5I6hq6NaXUCSgv0UZVnkco= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220825133536eucas1p28e31ab1fb02d1278459b525209ac8245~Omeh2aWvQ3110331103eucas1p20 for ; Thu, 25 Aug 2022 13:35:36 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 1F.65.07817.8AA77036; Thu, 25 Aug 2022 14:35:36 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220825133535eucas1p2ec871ae5a02f56c11097aac31c39e13d~Omehf9_u13111231112eucas1p2y for ; Thu, 25 Aug 2022 13:35:35 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220825133535eusmtrp14a5c236d2530ab71819757101dd86e9d~OmehfYQB-1642116421eusmtrp1K for ; Thu, 25 Aug 2022 13:35:35 +0000 (GMT) X-AuditID: cbfec7f4-893ff70000011e89-da-63077aa87b67 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id CD.05.10862.7AA77036; Thu, 25 Aug 2022 14:35:35 +0100 (BST) Received: from AMDN3260 (unknown [106.210.132.171]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220825133535eusmtip10ff0ae15943746ebe743df4ec1a1d170~OmehS5Qoy1733417334eusmtip1c for ; Thu, 25 Aug 2022 13:35:35 +0000 (GMT) From: "Dawid Kozinski" To: Date: Thu, 25 Aug 2022 15:35:35 +0200 Message-ID: <015001d8b887$8e7297c0$ab57c740$@samsung.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: Adi4faQKhR5W89g+QXGg3tqS2IhjBw== Content-Language: pl X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBIsWRmVeSWpSXmKPExsWy7djP87orqtiTDZ6+4rH49ukMswOjx59F m1kCGKO4bFJSczLLUov07RK4MpZ8/sdW8IGvon3ZZeYGxnccXYycHBICJhItk/sZuxi5OIQE VjBKLHm5kAXCmcQkse7pf2YIZyKTxIfWXywwLQu+HIZqWc4osWxZIzuE08YksWHxfzaQKjYB fYmZiz6B2SICshKr/00Bs4UFvCS+b1wPNolFQFVi94eZTF2MHBy8ApYSz7/HgoR5BQQlTs58 AlbCLCAvsf3tHGaIxQoSP58uY4UYqSfRt/gvG0SNiMSNRy1gB0kI/GSXuLdjPVSDi0TjhE3s ELawxKvjW6BsGYnTk3tYQPZKCBRLHOp3gDBrJA79SIeosJZ423icESTMLKApsX6XPkTYUeLk ix1sENV8EjfeCkIcwCcxadt0Zogwr0RHmxCEqSLR1ykG0Sgl8XQZzBseEpfX7WGcwKg4C8m3 s5B8OwvJV7MQTljAyLKKUTy1tDg3PbXYKC+1XK84Mbe4NC9dLzk/dxMjMDGc/nf8yw7G5a8+ 6h1iZOJgPMQowcGsJMJrdYwlWYg3JbGyKrUoP76oNCe1+BCjNAeLkjhvcuaGRCGB9MSS1OzU 1ILUIpgsEwenVAOTdPoh1lt/XF34EhO/mrmGVu7VY5jxdOn01LKHtx/u1FpwrkDFt9U5r3bp b9m3bSlSYcZnQ7JO632LOG3/vKtya8Gy6rCv/U0tjtr8Sdsi/nCeO5bz1qa665gg38ZvMhOU W3pOb+f5maS9djpHxuOT5S2P6peeC1pU9rttjldn94pfrxzVvzN5qxa9SJaYfi+2kH3hzfjn mUEL3vT2ieqGftpoYLf/m888xnPHP+aeEZfpOHi9zDTuj+0DL8sNgeXmLy5dcZU8xGnIxnDu aX3LMy5nW3MxubXva5vYBPWcK19PuViVa9OrfmjCvHca2bdEAzm9I1TF7/z4Gdq49ESRWEiE lemVzMQCJVW1v0osxRmJhlrMRcWJAOrwZDV7AwAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGLMWRmVeSWpSXmKPExsVy+t/xu7rLq9iTDU5+M7T49ukMswOjx59F m1kCGKP0bIryS0tSFTLyi0tslaINLYz0DC0t9IxMLPUMjc1jrYxMlfTtbFJSczLLUov07RL0 MpZ8/sdW8IGvon3ZZeYGxnccXYycHBICJhILvhxm7GLk4hASWMoosbzlNSNEQkpi6dJFULaw xJ9rXWwQRS1MEvuWPmABSbAJ6EvMXPSJDcQWEZCVWP1vCpgtLOAl8X3jerAaFgFVid0fZjJ1 MXJw8ApYSjz/HgsS5hUQlDg58wlYCbOAtsTTm0+hbHmJ7W/nMEPsVZD4+XQZK8R4PYm+xX/Z IGpEJG48amGcwCgwC8moWUhGzUIyahaSlgWMLKsYRVJLi3PTc4uN9IoTc4tL89L1kvNzNzEC A3zbsZ9bdjCufPVR7xAjEwfjIUYJDmYlEV6rYyzJQrwpiZVVqUX58UWlOanFhxhNgV6byCwl mpwPjLG8knhDMwNTQxMzSwNTSzNjJXFez4KORCGB9MSS1OzU1ILUIpg+Jg5OqQamkFsvpirX LmmZ6/cgPPf4WwN26+pXTk/fPV9azae157JROmvktuvekkfb7q5f+NfUTfuvBNvKoDLhLWy3 Xhp8bzJ59eIwg8Lql/N6PrT9O1Frk2776pTqwkbhDx9SbnCUCka8vH9XuWD3tpICxpv1kyfM yQmve2DwYdYm7roLGX6KAuGLbPumZWTxmyt9Dec4eVYvIGT6LR6/+4K7z86vmHZogchcs9TU BUf3+zZf2Xdr4fF2c8mE9kVNN6zOJf62nXD35BPmL3LFBlc9eZ5skLJWYZ+deuipf7falTxT genxU51PJMY8DK75UxiewCe2W2/aJC/Zh78/nQnMOyPPElhV+fPYu/TTuVX/Gy74KLEUZyQa ajEXFScCANmJ2nj5AgAA X-CMS-MailID: 20220825133535eucas1p2ec871ae5a02f56c11097aac31c39e13d X-Msg-Generator: CA X-RootMTR: 20220825133535eucas1p2ec871ae5a02f56c11097aac31c39e13d X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220825133535eucas1p2ec871ae5a02f56c11097aac31c39e13d References: Subject: [FFmpeg-devel] [FFmpeg-devel v10 9/9] 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: tcPFkdhn8NiC - Changelog update - MAINTAINERS update Signed-off-by: Dawid Kozinski --- Changelog | 4 ++-- MAINTAINERS | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index fa83786a20..9631262858 100644 --- a/Changelog +++ b/Changelog @@ -36,7 +36,8 @@ version 5.1: - PHM image format support - remap_opencl filter - added chromakey_cuda filter - +- eXtra-fast Essential Video Encoder (XEVE) +- eXtra-fast Essential Video Decoder (XEVD) version 5.0: - ADPCM IMA Westwood encoder @@ -83,7 +84,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 ed2ec0b90c..69fc04e1d6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -206,6 +206,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 @@ -426,6 +428,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