From patchwork Tue Sep 6 11:39:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawid Kozinski X-Patchwork-Id: 37701 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp3201269pzh; Tue, 6 Sep 2022 04:40:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR6l4z9BCRoCXtBP4/mfKvG9ssmKmQw+PZ1PVbZh9XpzzOGGXFnB5ijOt4GjbYZY4sOb4VCa X-Received: by 2002:a17:906:e9b:b0:730:a6a1:9fc9 with SMTP id p27-20020a1709060e9b00b00730a6a19fc9mr39080228ejf.601.1662464415719; Tue, 06 Sep 2022 04:40:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662464415; cv=none; d=google.com; s=arc-20160816; b=v80VFiSullMYwzr2ooAWzPgUiLtWuf0YEFK4Een31qP0URBcRREA3NSLa2H5y6tTzm 44zSgt4l1kc7pM1M7T/AbDmi1Yg42Fdi6izYne2xVRO4Arafqzkc7sP47eQHzPtMtLy4 HnOy9fK7X6MXvEqnwd2kMaGFS0RcOYHaUsYoX+eBAIJ3/ofKFvBkw3KO4j/UWbRxl/xg TpKUaoQkse2ayo6GPHpAJQ2rgK01hMlhnh2wOoO3PwhYShU16mI8E2PivtwRY88alssI h1nW/I9+gWhLDurhdZWqOAxCMgwGTCjRaurm4oZQIdnJ7MeJnp8NroOsWBWqoyozVsb7 IK1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:cms-type:mime-version :message-id:date:to:from:dkim-signature:dkim-filter:delivered-to; bh=t8phpAxQMfTsys2sgQFWfAA1YTFu7cwCaJA9Rt5T0hA=; b=ODYPP5C/6pCTuucy6654kMNxPrPVZ2VIMNpwWgBR2xFSTZr45+lvwfRnihONEp3Vfz UAqxKJqTm1Bpwzs4IfpsDbksK2rISN7rsHD2vKdT0n3f56YVbzf+A8hC6T8kMg9Tvuul 4QZXchuweMLaeZ9jsMEyzTHyh1spL+clsV22HIb8+HEKxUWFTm3AlFIV7KRB3U0sn/Dp E6KF3YF3l7JmkO2Rut9qVXobuVD1TBELc0D+fhPrxsfqkpt3Vxr7riHn/gO2JVCm9Khb RtsRdjFSfEd7GJ5lb6gmrAbmyk2McTuBrTYNeB6t5z2EAWjMWszLnJiDVA81h0WpMkm3 A11w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=mh4KjNiB; 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 f1-20020a50a6c1000000b0043dcd3625e4si892935edc.328.2022.09.06.04.40.15; Tue, 06 Sep 2022 04:40:15 -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=mh4KjNiB; 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 2EACB68BB05; Tue, 6 Sep 2022 14:40:12 +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 5846568B5CD for ; Tue, 6 Sep 2022 14:40:06 +0300 (EEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220906113953euoutp01f344584cf149bb8241727bb45fd6552e~SQo6wgxU72716427164euoutp01n for ; Tue, 6 Sep 2022 11:39:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220906113953euoutp01f344584cf149bb8241727bb45fd6552e~SQo6wgxU72716427164euoutp01n DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662464393; bh=5wGc1pupXUpvXxOcK5Nfwl6bsV0eCgf7OX884KkjjAc=; h=From:To:Cc:Subject:Date:References:From; b=mh4KjNiBGld6iVpPCsovaerfk1wyop57S3iKQbg+N495sMz7CpIclD/dx1QrmqUo3 x8gkkiSCILJv5Tps7J39gYLF7cvgsryLyE3XMPqDcMVClmlBkq8L1Z/MHZmO+MBdXf yGYY6Zwq9Rij5zpvCohgVZ0LjSKGV4tCH61rEVJo= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220906113951eucas1p2840408a18faa95a95cd5f9d6f080ccfc~SQo49-Aau0589605896eucas1p2N; Tue, 6 Sep 2022 11:39:51 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id C7.46.29727.68137136; Tue, 6 Sep 2022 12:39:50 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220906113950eucas1p1e82a79200cba7d8535273645a3f0b920~SQo4dCX0Y1501915019eucas1p11; Tue, 6 Sep 2022 11:39:50 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220906113950eusmtrp1ea45a056f989521141b7f68229e18672~SQo4cVAkx1350713507eusmtrp1C; Tue, 6 Sep 2022 11:39:50 +0000 (GMT) X-AuditID: cbfec7f2-205ff7000001741f-13-63173186b6d4 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id BE.CB.10862.68137136; Tue, 6 Sep 2022 12:39:50 +0100 (BST) Received: from AMDN3260.EU.corp.samsungelectronics.net (unknown [106.210.132.171]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220906113950eusmtip2cf02b427cd6cda732ec139d77607a9f8~SQo4GIa2O1676116761eusmtip2T; Tue, 6 Sep 2022 11:39:50 +0000 (GMT) From: Dawid Kozinski To: d.frankiewic@samsung.com, ffmpeg-devel@ffmpeg.org Date: Tue, 6 Sep 2022 13:39:42 +0200 Message-Id: <20220906113942.703-1-d.kozinski@samsung.com> X-Mailer: git-send-email 2.24.0.windows.2 MIME-Version: 1.0 X-Unsent: 1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrFIsWRmVeSWpSXmKPExsWy7djP87pthuLJBjdPGll8ufaF2WLlt98s Ft8+nWF2YPb4s2gzi0ffllWMAUxRXDYpqTmZZalF+nYJXBmPp2xjLpglU/Fp2l2mBsZZYl2M nBwSAiYSPx/cZOli5OIQEljBKLGofzqU84VRYsa6/UwQzmdGifY9V9hgWh6sPMYEYgsJLGeU WHYuGaKonUni5NvT7CAJNgFdiZcfHoEViQiYSpxs3gvWzCygLbHu7ncwW1jAWeL1vx/MIDaL gKpEy/v/QHEODl4BS4k/v5IgdmlKzJ7QDlbCKyAocXLmExaIOLfEulmXWCFGyks0b53NDHKD hMBPdolvr44yQxS5SLScPgJ1tLDEq+Nb2CFsGYnTk3tYQHZJCBRLHOp3gDBrJA79SIeosJZ4 23icESTMDHTC+l36EGFHicP3DrNBVPNJ3HgrCHEAn8SkbdOZIcK8Eh1tQhCmikRfJzSUpSSe LpsDdZWHxM/bD5kmMCrOQvLVLCSfzEJYu4CReRWjeGppcW56arFhXmq5XnFibnFpXrpecn7u JkZgcjj97/inHYxzX33UO8TIxMF4iFGCg1lJhDdlh0iyEG9KYmVValF+fFFpTmrxIUZpDhYl cd7kzA2JQgLpiSWp2ampBalFMFkmDk6pBqa4DNPDJhGnWG0ZDk9ZFbXlpm755SkTOC4clp8x bd5/pblyUfL//vy4p8QqoMfNv6Q88sizcr7cqQKzgptUlTYu9/M+InvHk7/8uX2icqbsz5SJ UiGTVoubPj+8adfvndPidCWu9Ea9yy74nHvlWxsj++Sc6mUs69sCbzT9WqNavufrugSTvL3M unGxh4+4HF+3Z23VtM/KU7orAn0Npj7rebqx887ceWn8LlqXHoU/b6pxi8i4f/XnzaXfIqPP 7v24Pmgy57PpEld+r7gkxj9RLMY9coudZlrt036zw7wFWnUzu/12XtxZe/uY6XtGnmP+aoFv 5/A7HdjZ8cd9w8tJKfJff1y9doJtWVD0zWWzlViKMxINtZiLihMB1PQr5H0DAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrILMWRmVeSWpSXmKPExsVy+t/xe7pthuLJBqcOK1h8ufaF2WLlt98s Ft8+nWF2YPb4s2gzi0ffllWMAUxRejZF+aUlqQoZ+cUltkrRhhZGeoaWFnpGJpZ6hsbmsVZG pkr6djYpqTmZZalF+nYJehmPp2xjLpglU/Fp2l2mBsZZYl2MnBwSAiYSD1YeY+pi5OIQEljK KHHp/jwWiISUxNKlixghbGGJP9e62CCKWpkk3qw/DFbEJqAr8fLDIyYQW0TAXOLiultgDcwC 2hLr7n5nA7GFBZwlXv/7wQxiswioSrS8/w8U5+DgFbCU+PMrCWK+psTsCe1gJbwCghInZz6B uoFbYt2sS6wQI+UlmrfOZp7AyD8LSdksJKkFjEyrGEVSS4tz03OLjfSKE3OLS/PS9ZLzczcx AsN227GfW3Ywrnz1Ue8QIxMH4yFGCQ5mJRHelB0iyUK8KYmVValF+fFFpTmpxYcYTYFOncgs JZqcD4ycvJJ4QzMDU0MTM0sDU0szYyVxXs+CjkQhgfTEktTs1NSC1CKYPiYOTqkGJk5Zdm/9 wPlrbrs8D1oREhR9746RraaFsvWdxvwn9kbtD3NfVH3jD325dNuLsI7TPev/VXPN2Rui8eTw 9yAbrR9zIhPn7mjeuC1zb4CH1mG54Lm37Y6fmD/7T8iJtElVTkK1Z13VrGamiHEq7nxUfHNz tHN/zY/F09VVza5fCzMt+XUsWfl24MT+01tSXBMTs6xmCO06HMNi33L7XvEBvoIdzcvedk85 wKDtzfvIRI3Lp95Jv57ryOuP6159Z2mI2ib42OrOudne5x5Gz1x7mL1stdVspb/S1+w/ytvL XFY4I2X6sMd3fpnvPb0mpSaft1+nbJjkpLKlqGChyHYdfd8pn9pWrLqoH9Is3c84V4mlOCPR UIu5qDgRACOp0hnkAgAA X-CMS-MailID: 20220906113950eucas1p1e82a79200cba7d8535273645a3f0b920 X-Msg-Generator: CA X-RootMTR: 20220906113950eucas1p1e82a79200cba7d8535273645a3f0b920 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220906113950eucas1p1e82a79200cba7d8535273645a3f0b920 References: Subject: [FFmpeg-devel] [PATCH v12 1/9] avcodec/evc: MPEG-5 EVC codec registration X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Dawid Kozinski Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: n0XSpDiAJAfl 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 7db5d1b1c5..cd1fda5f1f 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1687,6 +1687,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 d251ae2eff..3476ad7dc2 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 104 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ From patchwork Tue Sep 6 11:40:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawid Kozinski X-Patchwork-Id: 37702 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp3201848pzh; Tue, 6 Sep 2022 04:41:20 -0700 (PDT) X-Google-Smtp-Source: AA6agR50myXnatYHa5Ah4S09uXK8oXInRf9nIKSjFfBvoiEufVS7rqsFHz10BPG2Was3JziACE9+ X-Received: by 2002:a50:ef03:0:b0:44e:82bf:28e6 with SMTP id m3-20020a50ef03000000b0044e82bf28e6mr7672597eds.270.1662464480087; Tue, 06 Sep 2022 04:41:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662464480; cv=none; d=google.com; s=arc-20160816; b=DYDIJtqE/QN5BMwm21RvjaRn/KeCEHy4NbnP9G1gSiZZ6Tj3eh4ZcowpGbWcafzXN/ dbpXn90f8lxqFJsChvEGxeqnFIle9CQKlS42/8M1AdOTNmNQbW4GmCJSPtqZloj1g5aN 0E4zgouuETBpgtVMTZLl/z8wd8hEoPfzZd9NalTO5O6iy9cY0wj1Gjz2dO8Xv184bRXc uth4dwwvnOcZ4RZaU1ZS/dXn50ZHHVvN5vWMbpWNnmHCabhJPjl494U3AIwuFWFfa99D F0/28FN/cTXLyiii2B+KtZLeKxpQUxE2cj6zltr1V0arj57X1uRGZ5IxOxVPFf4exloS MHrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:cms-type:mime-version :message-id:date:to:from:dkim-signature:dkim-filter:delivered-to; bh=tffbgHyW/Ml6bmInO9G3ZM+oLN8g3GtqPrKBDi4bruc=; b=moV2O0oY9j/Bph1Ps9ocuLn6rJAnEwSR2y9/OTCFdkM6h9kDCwuBEuvn46zW1BHc9s Am1LF2FFbHdbU+xH03XdX/a5+2xFh+ZgP9PqR+DRT4wE3s2PZ+l5OrL9kId03N24t4T8 HnmL5mngL0h+Q9dR/HQok7qZo4nLRvSPVwOhugi7TIHRV3NKlyi9TMEeHsGUJxK8VSyH AarNpLZJWkWNiluci30JenWz01WvWfxIiXmHh86wlQFzoZxUce/q8m8g34cLVCzU0Fso DEJIc+5L3H+TN80lU9fC35zHeS6fEZ5m+4cZjChimcw0h7YqasTnqCmNiDfpou7hUmU5 +gLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=JoRhhXmF; 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 g10-20020a056402090a00b00447978abf00si1653024edz.226.2022.09.06.04.41.19; Tue, 06 Sep 2022 04:41: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=JoRhhXmF; 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 5F90A68BB00; Tue, 6 Sep 2022 14:41:17 +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 E66C168BB01 for ; Tue, 6 Sep 2022 14:41:10 +0300 (EEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220906114059euoutp02be2e8c56c9f4a3a0e64a1ff5354ea91c~SQp42Fyhg0380503805euoutp02J for ; Tue, 6 Sep 2022 11:40:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220906114059euoutp02be2e8c56c9f4a3a0e64a1ff5354ea91c~SQp42Fyhg0380503805euoutp02J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662464459; bh=IWSrLwL1w/1njh8jdbbIRLYebkQy13R2wpmFoWfevw8=; h=From:To:Cc:Subject:Date:References:From; b=JoRhhXmFkATw61lKPP+fh4Zyfs/Dlm4SGPqfS/3YfAvOKTmVj+1yFh2b51LgqwNd0 IRvh/JDxpDgCDmKNw3zEnT4OuXS6EeBy1HtBmeU1bJy+uQG30ojqpmLiBL3FPtyKaH havuEp5HGgUWv4co5g9sUbReXAS0p9Wp41kDuLik= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220906114059eucas1p27d199a9100f57525e5cfa88f777aa241~SQp4X3cLO1865718657eucas1p2I; Tue, 6 Sep 2022 11:40:59 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 6C.D2.07817.BC137136; Tue, 6 Sep 2022 12:40:59 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220906114058eucas1p2518b526802d028c144095982ea25d93d~SQp3_enef2977529775eucas1p2J; Tue, 6 Sep 2022 11:40:58 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220906114058eusmtrp1afc51de6537636fc7ea319352e3c6f11~SQp39s2XZ1404114041eusmtrp18; Tue, 6 Sep 2022 11:40:58 +0000 (GMT) X-AuditID: cbfec7f4-893ff70000011e89-e7-631731cbccf0 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id FF.49.07473.AC137136; Tue, 6 Sep 2022 12:40:58 +0100 (BST) Received: from AMDN3260.EU.corp.samsungelectronics.net (unknown [106.210.132.171]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220906114057eusmtip16446f9cc99ee4411fa5c4fa225e34050~SQp3FxJwD3214032140eusmtip1S; Tue, 6 Sep 2022 11:40:57 +0000 (GMT) From: Dawid Kozinski To: d.frankiewic@samsung.com, ffmpeg-devel@ffmpeg.org Date: Tue, 6 Sep 2022 13:40:46 +0200 Message-Id: <20220906114046.903-1-d.kozinski@samsung.com> X-Mailer: git-send-email 2.24.0.windows.2 MIME-Version: 1.0 X-Unsent: 1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDIsWRmVeSWpSXmKPExsWy7djP87qnDcWTDaY85rD4cu0Ls8XKb79Z LL59OsPswOzxZ9FmFo++LasYA5iiuGxSUnMyy1KL9O0SuDLu33nCVHBxElPFwplmDYy3DjB2 MXJySAiYSOw9u4a1i5GLQ0hgBaPE6ov72CGcL4wSdzc+YoZwPjNKzHrQCtdy5lQLG0RiOaPE rifXmCCcdiaJ/iWbmUGq2AR0JV5+eMQEYosImEqcbN7LBmIzC2hLrLv7Hcjm4BAWiJDYf1YL JMwioCpxav1WsBJeAUuJv7s+sEAs05SYPaGdGSIuKHFy5hOoOLfEulmXWCFGyks0b50NdqmE wFd2ibXv7kJd6iKx++xBqAZhiVfHt7BD2DISpyf3sIDcICFQLHGo3wHCrJE49CMdosJa4m3j cUaQMDPQCet36UOEHSWub/zJBFHNJ3HjrSDEAXwSk7ZNZ4YI80p0tAlBmCoSfZ1iEI1SEk+X zWGGsD0krl5rYpzAqDgLyVezkHwyC2HtAkbmVYziqaXFuempxUZ5qeV6xYm5xaV56XrJ+bmb GIEJ4vS/4192MC5/9VHvECMTB+MhRgkOZiUR3pQdIslCvCmJlVWpRfnxRaU5qcWHGKU5WJTE eZMzNyQKCaQnlqRmp6YWpBbBZJk4OKUamHrSl0w1vM1h7PTr34fq8gpRiYQNvMuv5FgIcpnd vNw49WS/cc3EFMGvkpMuXbrqIMGrafmRf0Xty/UBd5tXSvnXneUu4hKTLtLT/nBb0uaPWbjj krNRhfd/hryI/RITwPrk0HSf0zUpOSl+oRuTZl0KtBY2dBdZcnqLWuD2pxnroxd2fjov6+aU HNFgtjtD7cyXk9ZlslrGd+efXi24tj/uJ9Pt22xbX5m+dTlyS/D4mh2maidYjt+rlZZz79TP ObHrwL5bL9tW/Df3+qO+LuHRnoTiMx9/culfXChpFm+/Jv1Z4ay70752b4jWVXxx7+fMTQ2/ WMQfMpdO3Ms45aRjpuSKOc7iZ25vqnrT9kWJpTgj0VCLuag4EQC5tUGGfwMAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrMLMWRmVeSWpSXmKPExsVy+t/xu7qnDMWTDR4s0rD4cu0Ls8XKb79Z LL59OsPswOzxZ9FmFo++LasYA5ii9GyK8ktLUhUy8otLbJWiDS2M9AwtLfSMTCz1DI3NY62M TJX07WxSUnMyy1KL9O0S9DLu33nCVHBxElPFwplmDYy3DjB2MXJySAiYSJw51cLWxcjFISSw lFFizd/Z7BAJKYmlSxdBFQlL/LnWBVXUyiTR3r+RFSTBJqAr8fLDIyYQW0TAXOLiultgDcwC 2hLr7n5nA7GFBcIkNq08DVbPIqAqcWr9VrA4r4ClxN9dH1ggFmhKzJ7QzgwRF5Q4OfMJVJxb Yt2sS6wQM+UlmrfOZp7AyD8LSdksJKkFjEyrGEVSS4tz03OLDfWKE3OLS/PS9ZLzczcxAkN3 27Gfm3cwznv1Ue8QIxMH4yFGCQ5mJRHelB0iyUK8KYmVValF+fFFpTmpxYcYTYFuncgsJZqc D4yevJJ4QzMDU0MTM0sDU0szYyVxXs+CjkQhgfTEktTs1NSC1CKYPiYOTqkGpkNiWv7LVI1W bC2ZsTB2d2jrTRaGw+t5b6ta6K8N3XCTr9ko8GXgWX3Hah+l7wF5vydUm1Z2Tc+rnx9VtElL Yy9jdwTT3boV8ZUCje9131h8rzp6qPKe5ZHfnlst70Skf95Rahu6vvRNofl/zRds03+rZP60 3J4l31CwUS5Q8an/Jxm9kCtLZNxMhZrtpm/uv2mq9CDu90V35WVmm/YL1Bi9Uv91//RCK+MZ W+v+7PtiUXpN7saev+79QUpc6jeWNMc9Mbhhr78jvul97xnBiMJ/IRf5pjPsDuTTMTziJvIg 7FfXlUelNcYxDudvd4v33vrWU75s+QJHQ5YDCZwqkQ2NqX4Piwt2z3D65bdNiaU4I9FQi7mo OBEAr5dOEOYCAAA= X-CMS-MailID: 20220906114058eucas1p2518b526802d028c144095982ea25d93d X-Msg-Generator: CA X-RootMTR: 20220906114058eucas1p2518b526802d028c144095982ea25d93d X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220906114058eucas1p2518b526802d028c144095982ea25d93d References: Subject: [FFmpeg-devel] [PATCH v12 2/9] avcodec/evc_parser: Added parser implementaion for EVC format X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Dawid Kozinski Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: qabj2UYu1l7c Signed-off-by: Dawid Kozinski --- libavcodec/Makefile | 1 + libavcodec/evc.h | 155 +++++++++ libavcodec/evc_parser.c | 725 ++++++++++++++++++++++++++++++++++++++++ libavcodec/parsers.c | 1 + 4 files changed, 882 insertions(+) create mode 100644 libavcodec/evc.h create mode 100644 libavcodec/evc_parser.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 945908e3b8..d2eaa8f54f 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.h b/libavcodec/evc.h new file mode 100644 index 0000000000..b3e648796c --- /dev/null +++ b/libavcodec/evc.h @@ -0,0 +1,155 @@ +/* + * EVC definitions and enums + * Copyright (c) 2022 Dawid Kozinski + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_EVC_H +#define AVCODEC_EVC_H + +// The length field that indicates the length in bytes of the following NAL unit is configured to be of 4 bytes +#define EVC_NAL_UNIT_LENGTH_BYTE (4) /* byte */ +#define EVC_NAL_HEADER_SIZE (2) /* byte */ + +/** + * @see ISO_IEC_23094-1_2020, 7.4.2.2 NAL unit header semantic + * Table 4 - NAL unit type codes and NAL unit type classes + */ +enum EVCNALUnitType { + EVC_NOIDR_NUT = 0, /* Coded slice of a non-IDR picture */ + EVC_IDR_NUT = 1, /* Coded slice of an IDR picture */ + EVC_RSV_VCL_NUT02 = 2, + EVC_RSV_VCL_NUT03 = 3, + EVC_RSV_VCL_NUT04 = 4, + EVC_RSV_VCL_NUT05 = 5, + EVC_RSV_VCL_NUT06 = 6, + EVC_RSV_VCL_NUT07 = 7, + EVC_RSV_VCL_NUT08 = 8, + EVC_RSV_VCL_NUT09 = 9, + EVC_RSV_VCL_NUT10 = 10, + EVC_RSV_VCL_NUT11 = 11, + EVC_RSV_VCL_NUT12 = 12, + EVC_RSV_VCL_NUT13 = 13, + EVC_RSV_VCL_NUT14 = 14, + EVC_RSV_VCL_NUT15 = 15, + EVC_RSV_VCL_NUT16 = 16, + EVC_RSV_VCL_NUT17 = 17, + EVC_RSV_VCL_NUT18 = 18, + EVC_RSV_VCL_NUT19 = 19, + EVC_RSV_VCL_NUT20 = 20, + EVC_RSV_VCL_NUT21 = 21, + EVC_RSV_VCL_NUT22 = 22, + EVC_RSV_VCL_NUT23 = 23, + EVC_SPS_NUT = 24, /* Sequence parameter set */ + EVC_PPS_NUT = 25, /* Picture paremeter set */ + EVC_APS_NUT = 26, /* Adaptation parameter set */ + EVC_FD_NUT = 27, /* Filler data */ + EVC_SEI_NUT = 28, /* Supplemental enhancement information */ + EVC_RSV_NONVCL29 = 29, + EVC_RSV_NONVCL30 = 30, + EVC_RSV_NONVCL31 = 31, + EVC_RSV_NONVCL32 = 32, + EVC_RSV_NONVCL33 = 33, + EVC_RSV_NONVCL34 = 34, + EVC_RSV_NONVCL35 = 35, + EVC_RSV_NONVCL36 = 36, + EVC_RSV_NONVCL37 = 37, + EVC_RSV_NONVCL38 = 38, + EVC_RSV_NONVCL39 = 39, + EVC_RSV_NONVCL40 = 40, + EVC_RSV_NONVCL41 = 41, + EVC_RSV_NONVCL42 = 42, + EVC_RSV_NONVCL43 = 43, + EVC_RSV_NONVCL44 = 44, + EVC_RSV_NONVCL45 = 45, + EVC_RSV_NONVCL46 = 46, + EVC_RSV_NONVCL47 = 47, + EVC_RSV_NONVCL48 = 48, + EVC_RSV_NONVCL49 = 49, + EVC_RSV_NONVCL50 = 50, + EVC_RSV_NONVCL51 = 51, + EVC_RSV_NONVCL52 = 52, + EVC_RSV_NONVCL53 = 53, + EVC_RSV_NONVCL54 = 54, + EVC_RSV_NONVCL55 = 55, + EVC_UNSPEC_NUT56 = 56, + EVC_UNSPEC_NUT57 = 57, + EVC_UNSPEC_NUT58 = 58, + EVC_UNSPEC_NUT59 = 59, + EVC_UNSPEC_NUT60 = 60, + EVC_UNSPEC_NUT61 = 61, + EVC_UNSPEC_NUT62 = 62 +}; + +// slice type +// @see ISO_IEC_23094-1_2020 7.4.5 Slice header semantics +// +enum EVCSliceType { + EVC_SLICE_TYPE_B = 0, + EVC_SLICE_TYPE_P = 1, + EVC_SLICE_TYPE_I = 2 +}; + +enum { + // 7.4.3.2: aps_video_parameter_set_id is u(4). + EVC_MAX_APS_COUNT = 32, + + // 7.4.3.1: sps_seq_parameter_set_id is in [0, 15]. + EVC_MAX_SPS_COUNT = 16, + + // 7.4.3.2: pps_pic_parameter_set_id is in [0, 63]. + EVC_MAX_PPS_COUNT = 64, + + // 7.4.5: slice header slice_pic_parameter_set_id in [0, 63] + EVC_MAX_SH_COUNT = 64, + + // E.3.2: cpb_cnt_minus1[i] is in [0, 31]. + EVC_MAX_CPB_CNT = 32, + + // A.4.1: in table A.1 the highest level allows a MaxLumaPs of 35 651 584. + EVC_MAX_LUMA_PS = 35651584, + + EVC_MAX_NUM_REF_PICS = 21, + + EVC_MAX_NUM_RPLS = 32, + + // A.4.1: pic_width_in_luma_samples and pic_height_in_luma_samples are + // constrained to be not greater than sqrt(MaxLumaPs * 8). Hence height/ + // width are bounded above by sqrt(8 * 35651584) = 16888.2 samples. + EVC_MAX_WIDTH = 16888, + EVC_MAX_HEIGHT = 16888, + + // A.4.1: table A.1 allows at most 22 tile rows for any level. + EVC_MAX_TILE_ROWS = 22, + // A.4.1: table A.1 allows at most 20 tile columns for any level. + EVC_MAX_TILE_COLUMNS = 20, + + // A.4.1: table A.1 allows at most 600 slice segments for any level. + EVC_MAX_SLICE_SEGMENTS = 600, + + // 7.4.7.1: in the worst case (tiles_enabled_flag and + // entropy_coding_sync_enabled_flag are both set), entry points can be + // placed at the beginning of every Ctb row in every tile, giving an + // upper bound of (num_tile_columns_minus1 + 1) * PicHeightInCtbsY - 1. + // Only a stream with very high resolution and perverse parameters could + // get near that, though, so set a lower limit here with the maximum + // possible value for 4K video (at most 135 16x16 Ctb rows). + HEVC_MAX_ENTRY_POINT_OFFSETS = EVC_MAX_TILE_COLUMNS * 135, +}; + +#endif // AVCODEC_EVC_H diff --git a/libavcodec/evc_parser.c b/libavcodec/evc_parser.c new file mode 100644 index 0000000000..c4de06f73e --- /dev/null +++ b/libavcodec/evc_parser.c @@ -0,0 +1,725 @@ +/* + * EVC format parser + * + * Copyright (C) 2021 Dawid Kozinski + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include "libavutil/common.h" +#include "parser.h" +#include "golomb.h" +#include "evc.h" + +// rpl structure +typedef struct RefPicListStruct { + int poc; + int tid; + int ref_pic_num; + int ref_pic_active_num; + int ref_pics[EVC_MAX_NUM_REF_PICS]; + char pic_type; + +} RefPicListStruct; + +// The sturcture reflects SPS RBSP(raw byte sequence payload) layout +// @see ISO_IEC_23094-1 section 7.3.2.1 +// +// The following descriptors specify the parsing process of each element +// u(n) - unsigned integer using n bits +// ue(v) - unsigned integer 0-th order Exp_Golomb-coded syntax element with the left bit first +typedef struct EVCParserSPS { + int sps_seq_parameter_set_id; // ue(v) + int profile_idc; // u(8) + int level_idc; // u(8) + int toolset_idc_h; // u(32) + int toolset_idc_l; // u(32) + int chroma_format_idc; // ue(v) + int pic_width_in_luma_samples; // ue(v) + int pic_height_in_luma_samples; // ue(v) + int bit_depth_luma_minus8; // ue(v) + int bit_depth_chroma_minus8; // ue(v) + + int sps_btt_flag; // u(1) + int log2_ctu_size_minus5; // ue(v) + int log2_min_cb_size_minus2; // ue(v) + int log2_diff_ctu_max_14_cb_size; // ue(v) + int log2_diff_ctu_max_tt_cb_size; // ue(v) + int log2_diff_min_cb_min_tt_cb_size_minus2; // ue(v) + + int sps_suco_flag; // u(1) + int log2_diff_ctu_size_max_suco_cb_size; // ue(v) + int log2_diff_max_suco_min_suco_cb_size; // ue(v) + + int sps_admvp_flag; // u(1) + int sps_affine_flag; // u(1) + int sps_amvr_flag; // u(1) + int sps_dmvr_flag; // u(1) + int sps_mmvd_flag; // u(1) + int sps_hmvp_flag; // u(1) + + int sps_eipd_flag; // u(1) + int sps_ibc_flag; // u(1) + int log2_max_ibc_cand_size_minus2; // ue(v) + + int sps_cm_init_flag; // u(1) + int sps_adcc_flag; // u(1) + + int sps_iqt_flag; // u(1) + int sps_ats_flag; // u(1) + + int sps_addb_flag; // u(1) + int sps_alf_flag; // u(1) + int sps_htdf_flag; // u(1) + int sps_rpl_flag; // u(1) + int sps_pocs_flag; // u(1) + int sps_dquant_flag; // u(1) + int sps_dra_flag; // u(1) + + int log2_max_pic_order_cnt_lsb_minus4; // ue(v) + int log2_sub_gop_length; // ue(v) + int log2_ref_pic_gap_length; // ue(v) + + int max_num_tid0_ref_pics; // ue(v) + + int sps_max_dec_pic_buffering_minus1; // ue(v) + int long_term_ref_pic_flag; // u(1) + int rpl1_same_as_rpl0_flag; // u(1) + int num_ref_pic_list_in_sps[2]; // ue(v) + RefPicListStruct rpls[2][EVC_MAX_NUM_RPLS]; + + int picture_cropping_flag; // u(1) + int picture_crop_left_offset; // ue(v) + int picture_crop_right_offset; // ue(v) + int picture_crop_top_offset; // ue(v) + int picture_crop_bottom_offset; // ue(v) + + // @note + // Currently the structure does not reflect the entire SPS RBSP layout. + // It contains only the fields that are necessary to read from the NAL unit all the values + // necessary for the correct initialization of the AVCodecContext structure. + + // @note + // If necessary, add the missing fields to the structure to reflect + // the contents of the entire NAL unit of the SPS type + +} EVCParserSPS; + +typedef struct EVCParserPPS { + int pps_pic_parameter_set_id; // ue(v) + int pps_seq_parameter_set_id; // ue(v) + int num_ref_idx_default_active_minus1[2]; // ue(v) + int additional_lt_poc_lsb_len; // ue(v) + int rpl1_idx_present_flag; // u(1) + int single_tile_in_pic_flag; // u(1) + int num_tile_columns_minus1; // ue(v) + int num_tile_rows_minus1; // ue(v) + int uniform_tile_spacing_flag; // u(1) + int tile_column_width_minus1[EVC_MAX_TILE_ROWS]; // ue(v) + int tile_row_height_minus1[EVC_MAX_TILE_COLUMNS]; // ue(v) + int loop_filter_across_tiles_enabled_flag; // u(1) + int tile_offset_len_minus1; // ue(v) + int tile_id_len_minus1; // ue(v) + int explicit_tile_id_flag; // u(1) + int tile_id_val[EVC_MAX_TILE_ROWS][EVC_MAX_TILE_COLUMNS]; // u(v) + int pic_dra_enabled_flag; // u(1) + int pic_dra_aps_id; // u(5) + int arbitrary_slice_present_flag; // u(1) + int constrained_intra_pred_flag; // u(1) + int cu_qp_delta_enabled_flag; // u(1) + int log2_cu_qp_delta_area_minus6; // ue(v) + +} EVCParserPPS; + +// The sturcture reflects Slice Header RBSP(raw byte sequence payload) layout +// @see ISO_IEC_23094-1 section 7.3.2.6 +// +// The following descriptors specify the parsing process of each element +// u(n) - unsigned integer using n bits +// ue(v) - unsigned integer 0-th order Exp_Golomb-coded syntax element with the left bit first +// u(n) - unsigned integer using n bits. +// When n is "v" in the syntax table, the number of bits varies in a manner dependent on the value of other syntax elements. +typedef struct EVCParserSliceHeader { + int slice_pic_parameter_set_id; // ue(v) + int single_tile_in_slice_flag; // u(1) + int first_tile_id; // u(v) + int arbitrary_slice_flag; // u(1) + int last_tile_id; // u(v) + int num_remaining_tiles_in_slice_minus1; // ue(v) + int delta_tile_id_minus1[EVC_MAX_TILE_ROWS * EVC_MAX_TILE_COLUMNS]; // ue(v) + + int slice_type; // ue(v) + + // @note + // Currently the structure does not reflect the entire Slice Header RBSP layout. + // It contains only the fields that are necessary to read from the NAL unit all the values + // necessary for the correct initialization of the AVCodecContext structure. + + // @note + // If necessary, add the missing fields to the structure to reflect + // the contents of the entire NAL unit of the SPS type + +} EVCParserSliceHeader; + +typedef struct EVCParserContext { + ParseContext pc; + EVCParserSPS sps[EVC_MAX_SPS_COUNT]; + EVCParserPPS pps[EVC_MAX_PPS_COUNT]; + EVCParserSliceHeader slice_header[EVC_MAX_PPS_COUNT]; + int is_avc; + int nal_length_size; + int to_read; + int incomplete_nalu_prefix_read; // The flag is set to 1 when an incomplete NAL unit prefix has been read + +} EVCParserContext; + +static int get_nalu_type(const uint8_t *bits, int bits_size, AVCodecContext *avctx) +{ + int unit_type_plus1 = 0; + + if (bits_size >= EVC_NAL_HEADER_SIZE) { + unsigned char *p = (unsigned char *)bits; + // forbidden_zero_bit + if ((p[0] & 0x80) != 0) + return -1; + + // nal_unit_type + unit_type_plus1 = (p[0] >> 1) & 0x3F; + } + + return unit_type_plus1 - 1; +} + +static uint32_t read_nal_unit_length(const uint8_t *bits, int bits_size, AVCodecContext *avctx) +{ + uint32_t nalu_len = 0; + + if (bits_size >= EVC_NAL_UNIT_LENGTH_BYTE) { + + int t = 0; + unsigned char *p = (unsigned char *)bits; + + for (int i = 0; i < EVC_NAL_UNIT_LENGTH_BYTE; i++) + t = (t << 8) | p[i]; + + nalu_len = t; + if (nalu_len == 0) + return 0; + } + + return nalu_len; +} + +// @see ISO_IEC_23094-1 (7.3.2.1 SPS RBSP syntax) +static EVCParserSPS *parse_sps(const uint8_t *bs, int bs_size, EVCParserContext *ev) +{ + GetBitContext gb; + EVCParserSPS *sps; + int sps_seq_parameter_set_id; + + if (init_get_bits8(&gb, bs, bs_size) < 0) + return NULL; + + sps_seq_parameter_set_id = get_ue_golomb(&gb); + + if (sps_seq_parameter_set_id >= EVC_MAX_SPS_COUNT) + return NULL; + + sps = &ev->sps[sps_seq_parameter_set_id]; + sps->sps_seq_parameter_set_id = sps_seq_parameter_set_id; + + // the Baseline profile is indicated by profile_idc eqal to 0 + // the Main profile is indicated by profile_idc eqal to 1 + sps->profile_idc = get_bits(&gb, 8); + + sps->level_idc = get_bits(&gb, 8); + + skip_bits_long(&gb, 32); /* skip toolset_idc_h */ + skip_bits_long(&gb, 32); /* skip toolset_idc_l */ + + // 0 - monochrome + // 1 - 4:2:0 + // 2 - 4:2:2 + // 3 - 4:4:4 + sps->chroma_format_idc = get_ue_golomb(&gb); + + sps->pic_width_in_luma_samples = get_ue_golomb(&gb); + sps->pic_height_in_luma_samples = get_ue_golomb(&gb); + + sps->bit_depth_luma_minus8 = get_ue_golomb(&gb); + sps->bit_depth_chroma_minus8 = get_ue_golomb(&gb); + + sps->sps_btt_flag = get_bits(&gb, 1); + if (sps->sps_btt_flag) { + sps->log2_ctu_size_minus5 = get_ue_golomb(&gb); + sps->log2_min_cb_size_minus2 = get_ue_golomb(&gb); + sps->log2_diff_ctu_max_14_cb_size = get_ue_golomb(&gb); + sps->log2_diff_ctu_max_tt_cb_size = get_ue_golomb(&gb); + sps->log2_diff_min_cb_min_tt_cb_size_minus2 = get_ue_golomb(&gb); + } + + sps->sps_suco_flag = get_bits(&gb, 1); + if (sps->sps_suco_flag) { + sps->log2_diff_ctu_size_max_suco_cb_size = get_ue_golomb(&gb); + sps->log2_diff_max_suco_min_suco_cb_size = get_ue_golomb(&gb); + } + + sps->sps_admvp_flag = get_bits(&gb, 1); + if (sps->sps_admvp_flag) { + sps->sps_affine_flag = get_bits(&gb, 1); + sps->sps_amvr_flag = get_bits(&gb, 1); + sps->sps_dmvr_flag = get_bits(&gb, 1); + sps->sps_mmvd_flag = get_bits(&gb, 1); + sps->sps_hmvp_flag = get_bits(&gb, 1); + } + + sps->sps_eipd_flag = get_bits(&gb, 1); + if (sps->sps_eipd_flag) { + sps->sps_ibc_flag = get_bits(&gb, 1); + if (sps->sps_ibc_flag) + sps->log2_max_ibc_cand_size_minus2 = get_ue_golomb(&gb); + } + + sps->sps_cm_init_flag = get_bits(&gb, 1); + if (sps->sps_cm_init_flag) + sps->sps_adcc_flag = get_bits(&gb, 1); + + sps->sps_iqt_flag = get_bits(&gb, 1); + if (sps->sps_iqt_flag) + sps->sps_ats_flag = get_bits(&gb, 1); + + sps->sps_addb_flag = get_bits(&gb, 1); + sps->sps_alf_flag = get_bits(&gb, 1); + sps->sps_htdf_flag = get_bits(&gb, 1); + sps->sps_rpl_flag = get_bits(&gb, 1); + sps->sps_pocs_flag = get_bits(&gb, 1); + sps->sps_dquant_flag = get_bits(&gb, 1); + sps->sps_dra_flag = get_bits(&gb, 1); + + if (sps->sps_pocs_flag) + sps->log2_max_pic_order_cnt_lsb_minus4 = get_ue_golomb(&gb); + + if (!sps->sps_pocs_flag || !sps->sps_rpl_flag) { + sps->log2_sub_gop_length = get_ue_golomb(&gb); + if (sps->log2_sub_gop_length == 0) + sps->log2_ref_pic_gap_length = get_ue_golomb(&gb); + } + + // @note + // If necessary, add the missing fields to the EVCParserSPS structure + // and then extend parser implementation + + return sps; +} + +// @see ISO_IEC_23094-1 (7.3.2.2 SPS RBSP syntax) +static EVCParserPPS *parse_pps(const uint8_t *bs, int bs_size, EVCParserContext *ev) +{ + GetBitContext gb; + EVCParserPPS *pps; + + int pps_pic_parameter_set_id; + + if (init_get_bits8(&gb, bs, bs_size) < 0) + return NULL; + + pps_pic_parameter_set_id = get_ue_golomb(&gb); + if (pps_pic_parameter_set_id > EVC_MAX_PPS_COUNT) + return NULL; + + pps = &ev->pps[pps_pic_parameter_set_id]; + + pps->pps_pic_parameter_set_id = pps_pic_parameter_set_id; + + pps->pps_seq_parameter_set_id = get_ue_golomb(&gb); + if (pps->pps_seq_parameter_set_id >= EVC_MAX_SPS_COUNT) + return NULL; + + pps->num_ref_idx_default_active_minus1[0] = get_ue_golomb(&gb); + pps->num_ref_idx_default_active_minus1[1] = get_ue_golomb(&gb); + pps->additional_lt_poc_lsb_len = get_ue_golomb(&gb); + pps->rpl1_idx_present_flag = get_bits(&gb, 1); + pps->single_tile_in_pic_flag = get_bits(&gb, 1); + + if (!pps->single_tile_in_pic_flag) { + pps->num_tile_columns_minus1 = get_ue_golomb(&gb); + pps->num_tile_rows_minus1 = get_ue_golomb(&gb); + pps->uniform_tile_spacing_flag = get_bits(&gb, 1); + + if (!pps->uniform_tile_spacing_flag) { + for (int i = 0; i < pps->num_tile_columns_minus1; i++) + pps->tile_column_width_minus1[i] = get_ue_golomb(&gb); + + for (int i = 0; i < pps->num_tile_rows_minus1; i++) + pps->tile_row_height_minus1[i] = get_ue_golomb(&gb); + } + pps->loop_filter_across_tiles_enabled_flag = get_bits(&gb, 1); + pps->tile_offset_len_minus1 = get_ue_golomb(&gb); + } + + pps->tile_id_len_minus1 = get_ue_golomb(&gb); + pps->explicit_tile_id_flag = get_bits(&gb, 1); + + if (pps->explicit_tile_id_flag) { + for (int i = 0; i <= pps->num_tile_rows_minus1; i++) { + for (int j = 0; j <= pps->num_tile_columns_minus1; j++) + pps->tile_id_val[i][j] = get_bits(&gb, pps->tile_id_len_minus1 + 1); + } + } + + pps->pic_dra_enabled_flag = 0; + pps->pic_dra_enabled_flag = get_bits(&gb, 1); + + if (pps->pic_dra_enabled_flag) + pps->pic_dra_aps_id = get_bits(&gb, 5); + + pps->arbitrary_slice_present_flag = get_bits(&gb, 1); + pps->constrained_intra_pred_flag = get_bits(&gb, 1); + pps->cu_qp_delta_enabled_flag = get_bits(&gb, 1); + + if (pps->cu_qp_delta_enabled_flag) + pps->log2_cu_qp_delta_area_minus6 = get_ue_golomb(&gb); + + return pps; +} + +// @see ISO_IEC_23094-1 (7.3.2.6 Slice layer RBSP syntax) +static EVCParserSliceHeader *parse_slice_header(const uint8_t *bs, int bs_size, EVCParserContext *ev) +{ + GetBitContext gb; + EVCParserSliceHeader *sh; + EVCParserPPS *pps; + int num_tiles_in_slice = 0; + int slice_pic_parameter_set_id; + + if (init_get_bits8(&gb, bs, bs_size) < 0) + return NULL; + + slice_pic_parameter_set_id = get_ue_golomb(&gb); + + if (slice_pic_parameter_set_id < 0 || slice_pic_parameter_set_id >= EVC_MAX_PPS_COUNT) + return NULL; + + sh = &ev->slice_header[slice_pic_parameter_set_id]; + pps = &ev->pps[slice_pic_parameter_set_id]; + + sh->slice_pic_parameter_set_id = slice_pic_parameter_set_id; + + if (!pps->single_tile_in_pic_flag) { + sh->single_tile_in_slice_flag = get_bits(&gb, 1); + sh->first_tile_id = get_bits(&gb, pps->tile_id_len_minus1 + 1); + } else + sh->single_tile_in_slice_flag = 1; + + if (!sh->single_tile_in_slice_flag) { + if (pps->arbitrary_slice_present_flag) + sh->arbitrary_slice_flag = get_bits(&gb, 1); + + if (!sh->arbitrary_slice_flag) + sh->last_tile_id = get_bits(&gb, pps->tile_id_len_minus1 + 1); + else { + sh->num_remaining_tiles_in_slice_minus1 = get_ue_golomb(&gb); + num_tiles_in_slice = sh->num_remaining_tiles_in_slice_minus1 + 2; + for (int i = 0; i < num_tiles_in_slice - 1; ++i) + sh->delta_tile_id_minus1[i] = get_ue_golomb(&gb); + } + } + + sh->slice_type = get_ue_golomb(&gb); + + // @note + // If necessary, add the missing fields to the EVCParserSliceHeader structure + // and then extend parser implementation + + return sh; +} + +static int parse_nal_units(AVCodecParserContext *s, const uint8_t *bs, + int bs_size, AVCodecContext *avctx) +{ + EVCParserContext *ev = s->priv_data; + int nalu_type, nalu_size; + unsigned char *bits = (unsigned char *)bs; + int bits_size = bs_size; + + avctx->codec_id = AV_CODEC_ID_EVC; + s->picture_structure = AV_PICTURE_STRUCTURE_FRAME; + s->key_frame = -1; + + nalu_size = read_nal_unit_length(bits, bits_size, avctx); + if (nalu_size == 0) { + av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit size: (%d)\n", nalu_size); + return -1; + } + + bits += EVC_NAL_UNIT_LENGTH_BYTE; + bits_size -= EVC_NAL_UNIT_LENGTH_BYTE; + + nalu_type = get_nalu_type(bits, bits_size, avctx); + + bits += EVC_NAL_HEADER_SIZE; + bits_size -= EVC_NAL_HEADER_SIZE; + + if (nalu_type == EVC_SPS_NUT) { // NAL Unit type: SPS (Sequence Parameter Set) + EVCParserSPS *sps; + + sps = parse_sps(bits, bits_size, ev); + if (!sps) { + av_log(avctx, AV_LOG_ERROR, "SPS parsing error\n"); + return -1; + } + + s->coded_width = sps->pic_width_in_luma_samples; + s->coded_height = sps->pic_height_in_luma_samples; + s->width = sps->pic_width_in_luma_samples; + s->height = sps->pic_height_in_luma_samples; + + if (sps->profile_idc == 1) avctx->profile = FF_PROFILE_EVC_MAIN; + else avctx->profile = FF_PROFILE_EVC_BASELINE; + + // Currently XEVD decoder supports ony YCBCR420_10LE chroma format for EVC stream + switch (sps->chroma_format_idc) { + case 0: /* YCBCR400_10LE */ + av_log(avctx, AV_LOG_ERROR, "YCBCR400_10LE: Not supported chroma format\n"); + s->format = AV_PIX_FMT_GRAY10LE; + return -1; + case 1: /* YCBCR420_10LE */ + s->format = AV_PIX_FMT_YUV420P10LE; + break; + case 2: /* YCBCR422_10LE */ + av_log(avctx, AV_LOG_ERROR, "YCBCR422_10LE: Not supported chroma format\n"); + s->format = AV_PIX_FMT_YUV422P10LE; + return -1; + case 3: /* YCBCR444_10LE */ + av_log(avctx, AV_LOG_ERROR, "YCBCR444_10LE: Not supported chroma format\n"); + s->format = AV_PIX_FMT_YUV444P10LE; + return -1; + default: + s->format = AV_PIX_FMT_NONE; + av_log(avctx, AV_LOG_ERROR, "Unknown supported chroma format\n"); + return -1; + } + + // @note + // The current implementation of parse_sps function doesn't handle VUI parameters parsing. + // If it will be needed, parse_sps function could be extended to handle VUI parameters parsing + // to initialize fields of the AVCodecContex i.e. color_primaries, color_trc,color_range + + } else if (nalu_type == EVC_PPS_NUT) { // NAL Unit type: PPS (Video Parameter Set) + EVCParserPPS *pps; + + pps = parse_pps(bits, bits_size, ev); + if (!pps) { + av_log(avctx, AV_LOG_ERROR, "PPS parsing error\n"); + return -1; + } + } else if (nalu_type == EVC_SEI_NUT) // NAL unit type: SEI (Supplemental Enhancement Information) + return 0; + else if (nalu_type == EVC_IDR_NUT || nalu_type == EVC_NOIDR_NUT) { // NAL Unit type: Coded slice of a IDR or non-IDR picture + EVCParserSliceHeader *sh; + + sh = parse_slice_header(bits, bits_size, ev); + if (!sh) { + av_log(avctx, AV_LOG_ERROR, "Slice header parsing error\n"); + return -1; + } + switch (sh->slice_type) { + case EVC_SLICE_TYPE_B: { + s->pict_type = AV_PICTURE_TYPE_B; + break; + } + case EVC_SLICE_TYPE_P: { + s->pict_type = AV_PICTURE_TYPE_P; + break; + } + case EVC_SLICE_TYPE_I: { + s->pict_type = AV_PICTURE_TYPE_I; + break; + } + default: { + s->pict_type = AV_PICTURE_TYPE_NONE; + } + } + s->key_frame = (nalu_type == EVC_IDR_NUT) ? 1 : 0; + } else { + av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit type: %d\n", nalu_type); + return -1; + } + + return 0; +} + +/** + * Find the end of the current frame in the bitstream. + * @return the position of the first byte of the next frame, or END_NOT_FOUND + */ +static int evc_find_frame_end(AVCodecParserContext *s, const uint8_t *buf, + int buf_size, AVCodecContext *avctx) +{ + EVCParserContext *ev = s->priv_data; + + if (!ev->to_read) { + int nal_unit_size = 0; + int next = END_NOT_FOUND; + + // This is the case when buffer size is not enough for buffer to store NAL unit length + if (buf_size < EVC_NAL_UNIT_LENGTH_BYTE) { + ev->to_read = EVC_NAL_UNIT_LENGTH_BYTE; + ev->nal_length_size = buf_size; + ev->incomplete_nalu_prefix_read = 1; + + return END_NOT_FOUND; + } + + nal_unit_size = read_nal_unit_length(buf, buf_size, avctx); + ev->nal_length_size = EVC_NAL_UNIT_LENGTH_BYTE; + + next = nal_unit_size + EVC_NAL_UNIT_LENGTH_BYTE; + ev->to_read = next; + if (next < buf_size) + return next; + else + return END_NOT_FOUND; + } else if (ev->to_read > buf_size) + return END_NOT_FOUND; + else { + if (ev->incomplete_nalu_prefix_read == 1) { + EVCParserContext *ev = s->priv_data; + ParseContext *pc = &ev->pc; + uint8_t nalu_len[EVC_NAL_UNIT_LENGTH_BYTE] = {0}; + int nal_unit_size = 0; + + // 1. pc->buffer contains previously read bytes of NALU prefix + // 2. buf contains the rest of NAL unit prefix bytes + // + // ~~~~~~~ + // EXAMPLE + // ~~~~~~~ + // + // In the following example we assumed that the number of already read NAL Unit prefix bytes is equal 1 + // + // ---------- + // pc->buffer -> conatins already read bytes + // ---------- + // __ pc->index == 1 + // | + // V + // ------------------------------------------------------- + // | 0 | 1 | 2 | 3 | 4 | ... | N | + // ------------------------------------------------------- + // | 0x00 | 0xXX | 0xXX | 0xXX | 0xXX | ... | 0xXX | + // ------------------------------------------------------- + // + // ---------- + // buf -> contains newly read bytes + // ---------- + // ------------------------------------------------------- + // | 0 | 1 | 2 | 3 | 4 | ... | N | + // ------------------------------------------------------- + // | 0x00 | 0x00 | 0x3C | 0xXX | 0xXX | ... | 0xXX | + // ------------------------------------------------------- + // + for (int i = 0; i < EVC_NAL_UNIT_LENGTH_BYTE; i++) { + if (i < pc->index) + nalu_len[i] = pc->buffer[i]; + else + nalu_len[i] = buf[i - pc->index]; + } + + // ---------- + // nalu_len + // ---------- + // --------------------------------- + // | 0 | 1 | 2 | 3 | + // --------------------------------- + // | 0x00 | 0x00 | 0x00 | 0x3C | + // --------------------------------- + // | NALU LENGTH | + // --------------------------------- + // NAL Unit lenght = 60 (0x0000003C) + + nal_unit_size = read_nal_unit_length(nalu_len, EVC_NAL_UNIT_LENGTH_BYTE, avctx); + + ev->to_read = nal_unit_size + EVC_NAL_UNIT_LENGTH_BYTE - pc->index; + + ev->incomplete_nalu_prefix_read = 0; + + if (ev->to_read > buf_size) + return END_NOT_FOUND; + else + return ev->to_read; + } + return ev->to_read; + } + + return END_NOT_FOUND; +} + +static int evc_parser_init(AVCodecParserContext *s) +{ + EVCParserContext *ev = s->priv_data; + + ev->nal_length_size = EVC_NAL_UNIT_LENGTH_BYTE; + ev->incomplete_nalu_prefix_read = 0; + + return 0; +} + +static int evc_parse(AVCodecParserContext *s, AVCodecContext *avctx, + const uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size) +{ + int next; + EVCParserContext *ev = s->priv_data; + ParseContext *pc = &ev->pc; + int is_dummy_buf = !buf_size; + const uint8_t *dummy_buf = buf; + + if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) + next = buf_size; + else { + next = evc_find_frame_end(s, buf, buf_size, avctx); + if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { + *poutbuf = NULL; + *poutbuf_size = 0; + ev->to_read -= buf_size; + return buf_size; + } + } + + is_dummy_buf &= (dummy_buf == buf); + + if (!is_dummy_buf) + parse_nal_units(s, buf, buf_size, avctx); + + // poutbuf contains just one NAL unit + *poutbuf = buf; + *poutbuf_size = buf_size; + ev->to_read -= next; + + return next; +} + +const AVCodecParser ff_evc_parser = { + .codec_ids = { AV_CODEC_ID_EVC }, + .priv_data_size = sizeof(EVCParserContext), + .parser_init = evc_parser_init, + .parser_parse = evc_parse, + .parser_close = ff_parse_close, +}; diff --git a/libavcodec/parsers.c b/libavcodec/parsers.c index 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 Tue Sep 6 11:41:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawid Kozinski X-Patchwork-Id: 37703 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp3202326pzh; Tue, 6 Sep 2022 04:42:24 -0700 (PDT) X-Google-Smtp-Source: AA6agR762KYiwlkPWa110E0Zss2tBwoL5p+jPZeVF4sZfG+8QYtOcNEuvs8h9Q70ErGgywWXcUVu X-Received: by 2002:a17:907:7f02:b0:73d:dffa:57b3 with SMTP id qf2-20020a1709077f0200b0073ddffa57b3mr37304537ejc.19.1662464544180; Tue, 06 Sep 2022 04:42:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662464544; cv=none; d=google.com; s=arc-20160816; b=Lj+64qQfx7JsRXEmLpOsgk4Zhtg5+uZCLPKRsJyT2wC393sqrFQmr0EXA0R1pphr20 87Jmy7q6aDQbjircuX/06y5kOUX8yOB1a+5x4tr1kUryqF9ZwlXX58ZH2OFB9GK6AbIV CMrwXV5rqbmesUfBtU1E+qB9l2HPV+TAxqHyLs4iybDPSH7quKeDH2wnMnyKvO/fYV9r OEAidvUQBb6O7swmGXoSXsFTUOr3guCf6Pe2x+6CoWKdDqT4uUq0Orye1xR5HZi13RwN msKJcTo6vPiFgc+NULMlJ88RAP8kf8YE7K2q2Y4/IVNe7nFHZEDO3dE1+J1DvnujDg5A qmlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:cms-type:mime-version :message-id:date:to:from:dkim-signature:dkim-filter:delivered-to; bh=Ekui4gLiUr9HUQ9E0+T2Xu9tkDIGi13DxKcAmuUCRsQ=; b=Jfr9sJq77ChaYOza1Zkis8H9MECAJlA576/1UOwCe7sG4PuqRdym8zsjVokK3rDPVU njM8V1X8i30c05Z1miVCvSfMvz9TzbimZlkUKRHGdxvP363aIWyJcxd9ZwFfC5otgcBQ njr1+fjw798i+puqYJxv6u4BF3nNRGLYdh7TREFIsrvUT0Lm29Isn5KAGkDUf55R0cyD pvK6CcDntrcXBgiH5XFr4r+aFB0RDTPswNgEaW1ijGuf7e+fpLkvJ1UOtDjsIDw87YDS AMPTihP1QIXoxnXLJHaY16OywmugnUC5MvJSWf4aC4ns5KB/Iczo9aGtQkmeKuKzz6NW J0BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=jfS5WVk0; 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 y13-20020a056402270d00b00447f0236543si10550518edd.514.2022.09.06.04.42.23; Tue, 06 Sep 2022 04:42:24 -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=jfS5WVk0; 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 788FE68BB14; Tue, 6 Sep 2022 14:42: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 C757C68BAB0 for ; Tue, 6 Sep 2022 14:42:14 +0300 (EEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220906114204euoutp0175d9b8839bbef88e05a3a4b7f14ae66c~SQq1CXDg-2931529315euoutp01q for ; Tue, 6 Sep 2022 11:42:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220906114204euoutp0175d9b8839bbef88e05a3a4b7f14ae66c~SQq1CXDg-2931529315euoutp01q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662464524; bh=GRGTYkY98XONaz0JRdOMTVBegs3qoDq3ZQ4R4Shwztw=; h=From:To:Cc:Subject:Date:References:From; b=jfS5WVk0vxwzxxYy/cT9r4juQeWJqiQNFqRkpy9P918F3sn53cVvw82Y0lgrFGkLW AL4U1vdLd3fJYW/X2qwuHThDPRGh72QmwFDSl992bNziiikg7AwWwYC/DXa8H7kdsN dQO8dJmBZbcghPBIxvmObFeeQct64caMlyZJr8Dw= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220906114203eucas1p28bbcc7e2da1ff4c075612d82b3afb8ca~SQq0lKKbU1867618676eucas1p2G; Tue, 6 Sep 2022 11:42:03 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id B7.4B.19378.B0237136; Tue, 6 Sep 2022 12:42:03 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220906114203eucas1p19479cd611dfe86f8e6ebc8cb8d989dbf~SQq0DJRQ30193001930eucas1p1R; Tue, 6 Sep 2022 11:42:03 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220906114203eusmtrp12302139bd63c6603fd88475475100e72~SQq0CS51S1459214592eusmtrp1N; Tue, 6 Sep 2022 11:42:03 +0000 (GMT) X-AuditID: cbfec7f5-a4dff70000014bb2-b5-6317320bb490 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 2A.79.07473.B0237136; Tue, 6 Sep 2022 12:42:03 +0100 (BST) Received: from AMDN3260.EU.corp.samsungelectronics.net (unknown [106.210.132.171]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220906114202eusmtip19ecbccd25eb57eac09f5997ca034214c~SQqzoJS6f3266832668eusmtip1Q; Tue, 6 Sep 2022 11:42:02 +0000 (GMT) From: Dawid Kozinski To: d.frankiewic@samsung.com, ffmpeg-devel@ffmpeg.org Date: Tue, 6 Sep 2022 13:41:56 +0200 Message-Id: <20220906114156.1575-1-d.kozinski@samsung.com> X-Mailer: git-send-email 2.24.0.windows.2 MIME-Version: 1.0 X-Unsent: 1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrFIsWRmVeSWpSXmKPExsWy7djP87rcRuLJBi/2G1p8ufaF2WLlt98s Ft8+nWF2YPb4s2gzi0ffllWMAUxRXDYpqTmZZalF+nYJXBldu/6yF7wSrZg/5TBrA+NvgS5G Tg4JAROJjh//GbsYuTiEBFYwSjQ9ngblfGGU+Hr5BjOE85lR4lnnRlaYllvPTjKB2EICyxkl HvRAFbUzSZw4exqsiE1AV+Llh0dgRSICphInm/eygdjMAtoS6+5+B7OFBWokbtx7xNLFyMHB IqAqsfBxHkiYV8BKYt3f2SwQuzQlZk9oZ4aIC0qcnPkEKs4tsW7WJVaIkfISzVtng90gIfCV XaLr/j8miCIXicX3X0LZwhKvjm9hh7BlJE5P7gHbKyFQLHGo3wHCrJE49CMdosJa4m3jcUaQ MDPQCet36UOEHSU+ze2GauSTuPFWEOIAPolJ26YzQ4R5JTrahCBMFYm+TjGIRimJp8vmMEPY HhKdk36wT2BUnIXkq1lIPpmFsHYBI/MqRvHU0uLc9NRi47zUcr3ixNzi0rx0veT83E2MwORw +t/xrzsYV7z6qHeIkYmD8RCjBAezkghvyg6RZCHelMTKqtSi/Pii0pzU4kOM0hwsSuK8yZkb EoUE0hNLUrNTUwtSi2CyTBycUg1MWlHt1dW2Z1nKgictEt96QEz7+gv+zvxvMuUHWoW+bevL e5cv5qJlcC2if1PEg3Xb1d992RLnrMXN1Jx1z+3folA976wVGfYC9dXZ7cHKidsE+U90qLw+ 6/t3Bp/F3P57Ijv+SWzs9vs+nzecr3GXw5II/7/nW/7FMt9mCXi5/0+2/9zghP2r3K+H9Veo zmdaZC01s/tz3O3spOr35x++7ks9xxQwa/K9jj8Z0e/Lz/a+P7X8rvLL/z6qRn+OTf6/z2PD sj6toyYubXfWBUlqiqUed8thMdr09FD+092Mnsm2P6eZz1ghaB3U0n5IdT//ZufuXNk1uU5r v3cvexegckN+x/LzJ6z52ITOnK5SYinOSDTUYi4qTgQADGxzQH0DAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrALMWRmVeSWpSXmKPExsVy+t/xu7rcRuLJBnOfc1l8ufaF2WLlt98s Ft8+nWF2YPb4s2gzi0ffllWMAUxRejZF+aUlqQoZ+cUltkrRhhZGeoaWFnpGJpZ6hsbmsVZG pkr6djYpqTmZZalF+nYJehldu/6yF7wSrZg/5TBrA+NvgS5GTg4JAROJW89OMnUxcnEICSxl lHh7ZysTREJKYunSRYwQtrDEn2tdbBBFrUwS31asAytiE9CVePnhEZgtImAucXHdLbAGZgFt iXV3vwM1cHAIC1RJPOrlBzFZBFQlFj7OA6ngFbCSWPd3NgvEeE2J2RPamSHighInZz6BinNL rJt1iRViorxE89bZzBMY+WchKZuFJLWAkWkVo0hqaXFuem6xoV5xYm5xaV66XnJ+7iZGYNBu O/Zz8w7Gea8+6h1iZOJgPMQowcGsJMKbskMkWYg3JbGyKrUoP76oNCe1+BCjKdCpE5mlRJPz gXGTVxJvaGZgamhiZmlgamlmrCTO61nQkSgkkJ5YkpqdmlqQWgTTx8TBKdXAZORv2Re+kYPh SW/FRKFDLocZxWcXGhVd7tmhaHtEUOKb9Ez+XxfWKS53XC67roohMeKo3YbAm0e38lluOPZ8 /mXt1Son3EpZXrC8eycXx+uhILL7y8XFNhVFO/ovetu0Ho+SuRz/4Q//jQ377TPVd9/6Or+y 6+GNQxePFe5a9EfI3HAHS9leuztT5/2b0+VyMHKG6KLsiFzR72rvIgqdeMyUH8oYXYvbuMJt ncLvufv9L/hxT6sTDgkvYZrWumIZw8noi/Nt9davcV7I1zcnoLhzyt3yL1f/O0eFflGbG8w7 w/wvx/fclKJ0hWCPL0anqg0yVwWyukzsOhKx+/WkfkG+gwe3f5cWeGJlZ7jdUomlOCPRUIu5 qDgRAFxT/jPjAgAA X-CMS-MailID: 20220906114203eucas1p19479cd611dfe86f8e6ebc8cb8d989dbf X-Msg-Generator: CA X-RootMTR: 20220906114203eucas1p19479cd611dfe86f8e6ebc8cb8d989dbf X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220906114203eucas1p19479cd611dfe86f8e6ebc8cb8d989dbf References: Subject: [FFmpeg-devel] [PATCH v12 3/9] avformat/evc_muxer: Added muxer to handle writing EVC encoded data into file or output bytestream X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Dawid Kozinski Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: WvjFjjM035Z6 - 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 684bad0eb4..99553e9dfa 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 Tue Sep 6 11:43:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawid Kozinski X-Patchwork-Id: 37704 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp3202858pzh; Tue, 6 Sep 2022 04:43:33 -0700 (PDT) X-Google-Smtp-Source: AA6agR7G2UbU6lPJBhmeO8igMg2Np5IlMdwgAG5IOF0tt/+IlT1w6CyX8EAeaPPuQOaS4KWZtRWt X-Received: by 2002:a05:6402:84c:b0:44e:d797:6df9 with SMTP id b12-20020a056402084c00b0044ed7976df9mr2030512edz.186.1662464612872; Tue, 06 Sep 2022 04:43:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662464612; cv=none; d=google.com; s=arc-20160816; b=vMFOnA+wlACZ0r2ZZr1ZLn5ebLnrdjDlcceNixnpAHEa47vvcMouOckJ5vbGJvZw7Y TDgsaUQLEzxSxdoIxhwJXxuaoeNoKHI2CjcrAnO4EO1W/FbvYuDl0xS4EwpAywlFX1W8 +BJOZloTmcnSzshrw0vOA8CUSCUW7iRayPa8EqepBGxL7NGM5SIRvAtLUEp6BW/wiTT5 Bepl7ZK1B2kD9qyXN0XpxN+t3S1iykTUsdpcwYsNhYdZhLhzg6mW8Sc8TcSDwaZ0J22x CRMiGz2UfcEmlLQTtEz4Wc3Yywg81vZOVHjN9SjrjUARu1wDPTsPJiUuyTbS6nXB1bxN f7+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:cms-type:mime-version :message-id:date:to:from:dkim-signature:dkim-filter:delivered-to; bh=UgLcfGPDDYCloqiKTbnErctE6kJm6OCSPQz33Wa0VBM=; b=ABhgQ1WgH1cMS3HVsiBQFK36YKNzu1umiksMfJ+bGD4jM1E2m9pNjfiVq1wzO4LFIT Ac6mOG89QOgBZz+DKv/2mDvB/izIhC3GkxRtqd3BP7OTrJL5687bFwD04u9WIqUni8I3 aI+bp8J66zbg1HgJuN3hW+liOFnfx2oJUWzuH7XGpy6R+5v1ePfrXYE2L0JXpX+snffK Bqi/vjQMY5OGadGg8G0cQxPofEprkQmXv7MYFyBFETJhHwuM1GLx9+yjrWwAY6d/Eor9 3zm6QsLlqpLabizKXuqWytPXigW49FVfpGPAzTqNj8b/W33BB09icOzPrJekcxUvUTA/ v8gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=snbYTHQD; 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 b20-20020a056402351400b0044ecd80f257si1685540edd.603.2022.09.06.04.43.29; Tue, 06 Sep 2022 04:43:32 -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=snbYTHQD; 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 748A268BB1A; Tue, 6 Sep 2022 14:43:27 +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 482FF68BAD8 for ; Tue, 6 Sep 2022 14:43:21 +0300 (EEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220906114310euoutp01b4c9101bb55ed98ddf51f78b5b314adb~SQry9oKnR2931529315euoutp01b for ; Tue, 6 Sep 2022 11:43:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220906114310euoutp01b4c9101bb55ed98ddf51f78b5b314adb~SQry9oKnR2931529315euoutp01b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662464590; bh=ltZitOY8so7UQLAst8+MabcAZsztRK7PMaR72p9Z1UU=; h=From:To:Cc:Subject:Date:References:From; b=snbYTHQDHHfcqJrUs9PAQWY17yW2DqYVeIbbcKBZ9+pcymHbw+XKVjt3FjqEdlth1 6WsaKTez86uOAqNRKlMufyk36EM7413wQGHmFIeG6TzzoU5eq6Z/cz4cAguQ9NHOLI MNSeaVXclG0ksCSqyUzU5LSh/jWhJEjhrROlTJDM= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220906114310eucas1p1f1b466551f90d2e165f88b687e5569aa~SQryxInr62772027720eucas1p1g; Tue, 6 Sep 2022 11:43:10 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 34.E6.29727.E4237136; Tue, 6 Sep 2022 12:43:10 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220906114310eucas1p2aa699c5b353ec9e62d47a7fc71dd8855~SQryfiKkP1867018670eucas1p2H; Tue, 6 Sep 2022 11:43:10 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220906114310eusmtrp1184646fdc17d2e018ba6719cad6d36d3~SQryZw39l1546715467eusmtrp1n; Tue, 6 Sep 2022 11:43:10 +0000 (GMT) X-AuditID: cbfec7f2-7932da800001741f-ba-6317324e1be8 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id FF.99.07473.E4237136; Tue, 6 Sep 2022 12:43:10 +0100 (BST) Received: from AMDN3260.EU.corp.samsungelectronics.net (unknown [106.210.132.171]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220906114309eusmtip19a721d6e37eab68578a5d0052c48e55d~SQrx9V6vF2663926639eusmtip1Q; Tue, 6 Sep 2022 11:43:09 +0000 (GMT) From: Dawid Kozinski To: d.frankiewic@samsung.com, ffmpeg-devel@ffmpeg.org Date: Tue, 6 Sep 2022 13:43:02 +0200 Message-Id: <20220906114302.216-1-d.kozinski@samsung.com> X-Mailer: git-send-email 2.24.0.windows.2 MIME-Version: 1.0 X-Unsent: 1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNIsWRmVeSWpSXmKPExsWy7djPc7p+RuLJBofeKlt8ufaF2WLlt98s Ft8+nWF2YPb4s2gzi0ffllWMAUxRXDYpqTmZZalF+nYJXBlLH05nKZijVTFjxVX2BsaP8l2M nBwSAiYSXf/mMHcxcnEICaxglPi25DkLhPOFUaLxPIzzmVFiwZczjDAtS/s3sIDYQgLLGSUu bFOBKGpnkjh3/RsrSIJNQFfi5YdHTCC2iICpxMnmvWwgNrOAtsS6u9/BbGGBBIlTrYfAbBYB VYl9n6eB1fMKWEp87XjOCrFMU2L2hHZmiLigxMmZT1gg4twS62ZdYoWYKS/RvHU22A8SAj/Z Jf7vfMoOUeQi8Wh5I9TVwhKvjm+BistInJ7cAzSIA8guljjU7wBh1kgc+pEOUWEt8bbxOCNI mBnohPW79CHCjhIfXj2BauSTuPFWEOIAPolJ26YzQ4R5JTrahCBMFYm+TjGIRimJp8vmMEPY HhJ3Vt5mn8CoOAvJV7OQfDILYe0CRuZVjOKppcW56anFhnmp5XrFibnFpXnpesn5uZsYgenh 9L/jn3Ywzn31Ue8QIxMH4yFGCQ5mJRHelB0iyUK8KYmVValF+fFFpTmpxYcYpTlYlMR5kzM3 JAoJpCeWpGanphakFsFkmTg4pRqY8r9Pm9x9OvrqBNcjYtzPu1muKkozSDSe61kSmvQof5qI /8xPkicYwi7O5N/bl3+9qHt74bJv0x7Pn7nleoqGm4hx46EdDk47LRN1PDvXaHL9ecTruORt 2+oio92bD+768D1UK1f8xeXq5yznG0IlBRZpTBe5dsphVZjR2mlCTWoqGilSfZuELHlU8iXk F1r3iKpvZG46kB1odIzPI7Llg1jGntj9EziPSQZoPWeYeSWOa9cCc+Ufv9+/Ose8V5U9iPNF ZSnncgYTr61RhT//PpS8d2eKq/Au+bUX7/qL7Pj5wC5t5lXFPxOnBt11ncsuKP/b49CRm8sS Fy/9f+dzzTZNGfXc+0dmp5YceDMrR4mlOCPRUIu5qDgRACT+Jax+AwAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrELMWRmVeSWpSXmKPExsVy+t/xu7p+RuLJBvOXc1t8ufaF2WLlt98s Ft8+nWF2YPb4s2gzi0ffllWMAUxRejZF+aUlqQoZ+cUltkrRhhZGeoaWFnpGJpZ6hsbmsVZG pkr6djYpqTmZZalF+nYJehlLH05nKZijVTFjxVX2BsaP8l2MnBwSAiYSS/s3sHQxcnEICSxl lPh+4AoTREJKYunSRYwQtrDEn2tdbBBFrUwS805sBCtiE9CVePnhEZgtImAucXHdLbAGZgFt iXV3v7OB2MICcRJXTzxgB7FZBFQl9n2eBlbPK2Ap8bXjOSvEAk2J2RPamSHighInZz5hgYhz S6ybdYkVYqa8RPPW2cwTGPlnISmbhSS1gJFpFaNIamlxbnpusaFecWJucWleul5yfu4mRmDg bjv2c/MOxnmvPuodYmTiYDzEKMHBrCTCm7JDJFmINyWxsiq1KD++qDQntfgQoynQrROZpUST 84Gxk1cSb2hmYGpoYmZpYGppZqwkzutZ0JEoJJCeWJKanZpakFoE08fEwSnVwLTZ7GvW2vDd HhceGy66t2XD4uOx2/Sj3s6+UyJqrPxx/9YLVZqy91LWXDaqrQ1XTt0mLCIiqLFj3WY2tj79 7fLbBQOvmLKoRDNKr3k5vz64TWVHwVx+xbBXS/+ZZOSf7GvmvSrJ9eTRKelTHhMeTrDhNeBi Sz9ivj9yo3pMguFy++jARconvZ+lbIt5EbDp+OcGpmfMETkt8m9XScxUcDnlfXFm+mWVSNHS O4skHl7bnSDAmHb2iTSP6KzqA1I/n4rP9Pt2flvsv54VKltdu+duin1o+K8m6+Sfje21AhNv 3nf+uZf18LOaqOnCD2pK50R+y/S02ve0Mjv4T1GaTW97nXrR52ksHqLzy45/d1RiKc5INNRi LipOBABCCLh75QIAAA== X-CMS-MailID: 20220906114310eucas1p2aa699c5b353ec9e62d47a7fc71dd8855 X-Msg-Generator: CA X-RootMTR: 20220906114310eucas1p2aa699c5b353ec9e62d47a7fc71dd8855 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220906114310eucas1p2aa699c5b353ec9e62d47a7fc71dd8855 References: Subject: [FFmpeg-devel] [PATCH v12 4/9] avformat/evc_demuxer: Added demuxer to handle reading EVC video files X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Dawid Kozinski Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: IRivmNQp3aG9 - Provided AVInputFormat structure describing EVC input format (ff_evc_demuxer) Signed-off-by: Dawid Kozinski --- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/evcdec.c | 124 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 126 insertions(+) create mode 100644 libavformat/evcdec.c diff --git a/libavformat/Makefile b/libavformat/Makefile index 99553e9dfa..09debd8897 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..ffb7449c4d --- /dev/null +++ b/libavformat/evcdec.c @@ -0,0 +1,124 @@ +/* + * RAW EVC video demuxer + * + * Copyright (c) 2021 Dawid Kozinski + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavcodec/get_bits.h" +#include "libavcodec/golomb.h" +#include "libavcodec/internal.h" +#include "libavcodec/evc.h" + +#include "rawdec.h" +#include "avformat.h" + +typedef struct EVCParserContext { + int got_sps; + int got_pps; + int got_idr; + int got_nonidr; +} EVCParserContext; + +static int get_nalu_type(const uint8_t *bits, int bits_size) +{ + int unit_type_plus1 = 0; + + if(bits_size >= EVC_NAL_HEADER_SIZE) { + unsigned char *p = (unsigned char *)bits; + // forbidden_zero_bit + if ((p[0] & 0x80) != 0) { // Cannot get bitstream information. Malformed bitstream. + return -1; + } + + // nal_unit_type + unit_type_plus1 = (p[0] >> 1) & 0x3F; + } + + return unit_type_plus1 - 1; +} + +static uint32_t read_nal_unit_length(const uint8_t *bits, int bits_size) +{ + uint32_t nalu_len = 0; + + if(bits_size >= EVC_NAL_UNIT_LENGTH_BYTE) { + + int t = 0; + unsigned char *p = (unsigned char *)bits; + + for(int i=0; ibuf; + int bytes_to_read = p->buf_size; + + while(bytes_to_read > EVC_NAL_UNIT_LENGTH_BYTE) { + + nalu_size = read_nal_unit_length(bits, EVC_NAL_UNIT_LENGTH_BYTE); + if(nalu_size == 0) break; + + bits += EVC_NAL_UNIT_LENGTH_BYTE; + bytes_to_read -= EVC_NAL_UNIT_LENGTH_BYTE; + + if(bytes_to_read < nalu_size) break; + + nalu_type = get_nalu_type(bits, bytes_to_read); + + bits += nalu_size; + bytes_to_read -= nalu_size; + + if (nalu_type == EVC_SPS_NUT) + ev->got_sps++; + else if (nalu_type == EVC_PPS_NUT) + ev->got_pps++; + else if (nalu_type == EVC_IDR_NUT ) + ev->got_idr++; + else if (nalu_type == EVC_NOIDR_NUT) + ev->got_nonidr++; + } + + return 0; +} + +static int evc_probe(const AVProbeData *p) +{ + EVCParserContext ev = {0}; + int ret = parse_nal_units(p, &ev); + + if (ret == 0 && ev.got_sps && ev.got_pps && (ev.got_idr || ev.got_nonidr > 3)) + return AVPROBE_SCORE_EXTENSION + 1; // 1 more than .mpg + + return 0; +} + +FF_DEF_RAWVIDEO_DEMUXER(evc, "raw EVC video", evc_probe, "evc", AV_CODEC_ID_EVC) From patchwork Tue Sep 6 11:44:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawid Kozinski X-Patchwork-Id: 37705 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp3203321pzh; Tue, 6 Sep 2022 04:44:43 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Rob7uTay6YYfAXYrv5EkO7CNvXav3XiDPwxojs/q/8tpFpf1BPlLtlNygPU66g1+j5gFU X-Received: by 2002:a17:907:b0c:b0:73d:dc7f:4b8 with SMTP id h12-20020a1709070b0c00b0073ddc7f04b8mr38692483ejl.183.1662464683247; Tue, 06 Sep 2022 04:44:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662464683; cv=none; d=google.com; s=arc-20160816; b=J3eD5VQQvwvNe4vFLq6KVHnaE5VQvGTHeKekxKvFd4AHFT0UiKAB3m5fUdcjVRWGDI b+4rRF2NAOZrZufWASteZU7ih1Ri6WHHV1XC45F8Oxv65eu1dPTmInKOMkEeKFmazQqm MP/edwqlklURwnuNJK4G2MftoRQe31Nl8NVzeoSctUJ6hSqol3p9n411O8Nv/ahtB2Nc yIXkl8cd1w8RMjWPVTPN+O3L/FNOAptNbh+9SWZEIvYg9+t+JTs6+CF8XrKpDhOaSG7I sFQ8N8ozYidqqi8g2+UxEQIht8k5xKinfNa6z40dAQ3EZh/HJ62b4GPlepRTiPgX5sUF v0JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:cms-type:mime-version :message-id:date:to:from:dkim-signature:dkim-filter:delivered-to; bh=l5nzQzbCI5hKSo2L4LsmCjWx4wryVEzeFjEcy+VQUaw=; b=toSrZOYSjNInAHKPQ9uR/SvxnXRyPE8smP06cFoUz3j8eE7madWozyk6BwxIVB/U8x rJHjdhX1G8xvVKuAUAKc69xgB0Ib+TrEnNINio3qmsEOWWSCTg10DGuulnUm0SPGFW0u 7IP5mSehJuX8PXwc5zS+201eXCboXVcuSGyYkXyje7NsUaaovJ7Z8p5QlHU3RZTfBUdW TZSy8JULWCq2lJ+0sM782kQEfKR1Uo6WAqrDIdfPteQ3fAfP4EzBh/0WLgPmXyK9h7V0 ed4+DGF0K18OyktPV2yU7Hdb1PDcSK92Se0tHFeABo+3M9oY7KBfx7KUx951nIn1N/I+ Lu4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=jlUQXY31; 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 w11-20020a056402268b00b00446b907d8d2si10545033edd.7.2022.09.06.04.44.42; Tue, 06 Sep 2022 04:44:43 -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=jlUQXY31; 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 9BFB868BB1E; Tue, 6 Sep 2022 14:44:40 +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 7B25468BA9F for ; Tue, 6 Sep 2022 14:44:34 +0300 (EEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220906114424euoutp014ab4006ed5c67e838c144991e2571dc1~SQs3J3_SY3130431304euoutp01v for ; Tue, 6 Sep 2022 11:44:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220906114424euoutp014ab4006ed5c67e838c144991e2571dc1~SQs3J3_SY3130431304euoutp01v DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662464664; bh=9W1Qhr798ByEylakJhKTFSo8VnS0oGtR7XcVQzJdMRk=; h=From:To:Cc:Subject:Date:References:From; b=jlUQXY31NHhmn1dC/sMj7yPdw4QllauzIqzr/AYwVNV9Y3wJbuNk+PXcOlmloT//e E0CEtqi3kgaZELqdDsmhwPbXxMsYxsxboHxNmOH6wL2/tWQjSK+nsXbwm3DJvM5Cx7 w6u8+k9k2nTz6XLkKd+zLoU5rzPEWetmr27dnWIs= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220906114418eucas1p1bc25172657aa3890b7f664f2faf7138e~SQsyF0ki92506425064eucas1p1k; Tue, 6 Sep 2022 11:44:18 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 00.BB.19378.29237136; Tue, 6 Sep 2022 12:44:18 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220906114417eucas1p2a2474721928a250bdaae4f930c910f3b~SQsxbko7r1590615906eucas1p28; Tue, 6 Sep 2022 11:44:17 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220906114417eusmtrp24940be28d7dbd9a7b3a43aa16a9ec8db~SQsxay_QF0204802048eusmtrp2M; Tue, 6 Sep 2022 11:44:17 +0000 (GMT) X-AuditID: cbfec7f5-a35ff70000014bb2-8f-63173292e0f9 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 04.7C.10862.19237136; Tue, 6 Sep 2022 12:44:17 +0100 (BST) Received: from AMDN3260.EU.corp.samsungelectronics.net (unknown [106.210.132.171]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220906114416eusmtip1ead0404e5181324fe1d9123b45291492~SQsv7zM7n3094830948eusmtip1j; Tue, 6 Sep 2022 11:44:16 +0000 (GMT) From: Dawid Kozinski To: d.frankiewic@samsung.com, ffmpeg-devel@ffmpeg.org Date: Tue, 6 Sep 2022 13:44:07 +0200 Message-Id: <20220906114407.887-1-d.kozinski@samsung.com> X-Mailer: git-send-email 2.24.0.windows.2 MIME-Version: 1.0 X-Unsent: 1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNIsWRmVeSWpSXmKPExsWy7djP87qTjMSTDT51Klh8ufaF2WLlt98s Ft8+nWF2YPb4s2gzi0ffllWMAUxRXDYpqTmZZalF+nYJXBkd5wIKbn9jrDhxX7WB8dAuxi5G Tg4JAROJG129QDYXh5DACkaJVbfWQzlfGCX6T09mgXA+M0q8n3SJDaalZX4fK0RiOaPEpMe3 2CCcdiaJ+3Pes4BUsQnoSrz88IgJxBYRMJU42bwXrJtZQFti3d3vYLawQIDEqkvXwWwWAVWJ CROmg9m8ApYS7bc/M0Ns05SYPaGdGSIuKHFy5hMWiDi3xLpZl1ghZspLNG+dzQxyhITAT3aJ o5u/ABVxADkuEueuCkLUC0u8Or6FHcKWkfi/cz4TREmxxKF+BwizRuLQj3SICmuJt43HGUHC zEAXrN+lDxF2lNgwbzsrRDWfxI23ghD7+SQmbZvODBHmlehoE4IwVST6OsUgGqUkni6bA/WR h0TXtm6mCYyKs5A8NQvJI7MQ1i5gZF7FKJ5aWpybnlpsnJdarlecmFtcmpeul5yfu4kRmB5O /zv+dQfjilcf9Q4xMnEwHmKU4GBWEuFN2SGSLMSbklhZlVqUH19UmpNafIhRmoNFSZw3OXND opBAemJJanZqakFqEUyWiYNTqoEpVJZR8H9FSFm+bdjaViOpHWe8fqjw3baruXvsalzHumrO yUybJyfv5ivYrfD5WKXhb/3PB4+85LNJFLszT+TakkUvN/e2JN8vksw/7+Diu+fN7vpPX14H rAsqntodvu3n3/mJPEZHvf9b3b5yalH2y4P/jddsOlO+/N7W9KtKUxqkX0R9z/XuZeYq6+w7 z3M2J/Hs62+GoXfSmIS8lugHGX3ibWKxfOcv6COn/F/fadMfp04lHaGoy9WyG6YZJV9frCrB /vCin6iV7a2b09SmHIzQ2KxRUvxoYu21qd7T+RTvhswx9rrO+uVlJ0+V/asDQh9iil2CFQw/ eLDUqD2cw+Oi7WA4U3nP9Gtaa02VWIozEg21mIuKEwGSQDFDfgMAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrILMWRmVeSWpSXmKPExsVy+t/xu7oTjcSTDd5f1Lf4cu0Ls8XKb79Z LL59OsPswOzxZ9FmFo++LasYA5ii9GyK8ktLUhUy8otLbJWiDS2M9AwtLfSMTCz1DI3NY62M TJX07WxSUnMyy1KL9O0S9DI6zgUU3P7GWHHivmoD46FdjF2MnBwSAiYSLfP7WLsYuTiEBJYy Stw/NpEJIiElsXTpIqgiYYk/17rYIIpamSROfG9lA0mwCehKvPzwCKxBRMBc4uK6W2ANzALa Euvufgeq4eAQFvCTOLBRAiTMIqAqMWHCdLBWXgFLifbbn5kh5mtKzJ7QzgwRF5Q4OfMJC0Sc W2LdrEusECPlJZq3zmaewMg/C0nZLCSpBYxMqxhFUkuLc9Nzi430ihNzi0vz0vWS83M3MQLD dtuxn1t2MK589VHvECMTB+MhRgkOZiUR3pQdIslCvCmJlVWpRfnxRaU5qcWHGE2Bbp3ILCWa nA+MnLySeEMzA1NDEzNLA1NLM2MlcV7Pgo5EIYH0xJLU7NTUgtQimD4mDk6pBqY9T/oKdibt KHqgdjU8vLEhlNN2rbW73qt2xzT7fPt5Kw/6lr04c+5xxtMbmq+jTnfvfuTKVPnnwYQ7v78d f1nCuHKRsNlsXT2d1FkHpT2v7V4ve4VV9sTSr2UbFN8I6QnXtGVrNG3MYtu/njNyx8ZCrZl2 mr31bOf21zJkRUt96Jn+6yHf1eaEwy/O9n3d23/KYcbbuz80byvMWjt5NbuYhbzaw3jZGUdE 1zxt/i4nx9A79+7CzxwFLsu0y/kll2yp1Am19JISMHn6YMf2T4/K9kmYdFi3R0rpd7xz2som J/jO8eesBwlPnb5c2KWhti2wVkb7jX9Em+n5dc8zsx9y/1q6Sy/J78P5/EuM3UVKLMUZiYZa zEXFiQCdA+6V5AIAAA== X-CMS-MailID: 20220906114417eucas1p2a2474721928a250bdaae4f930c910f3b X-Msg-Generator: CA X-RootMTR: 20220906114417eucas1p2a2474721928a250bdaae4f930c910f3b X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220906114417eucas1p2a2474721928a250bdaae4f930c910f3b References: Subject: [FFmpeg-devel] [PATCH v12 5/9] avcodec/evc_encoder: Provided support for EVC encoder X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Dawid Kozinski Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: lh/2yOBMqZyn - 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 9e51abd0d3..0ad6f59de8 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 @@ -3400,6 +3402,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" @@ -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 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 d2eaa8f54f..9f911ae7ec 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 Tue Sep 6 11:45:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawid Kozinski X-Patchwork-Id: 37706 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp3203850pzh; Tue, 6 Sep 2022 04:45:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR57IrhbYkW55K+rI4qlwXdWLw2+JIWq3TkVgXOrP7a9SKV0IOrl5Ka1bXwjdEnMJHx2TheG X-Received: by 2002:a05:6402:415:b0:446:230d:2b82 with SMTP id q21-20020a056402041500b00446230d2b82mr47284174edv.200.1662464753154; Tue, 06 Sep 2022 04:45:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662464753; cv=none; d=google.com; s=arc-20160816; b=lLhUXhH4sklqsVgs/5vbzyMm1L5cfkUsIkXhYIDt3yXYgPylyBgPm9ou7AS6VvO2Mt Pe/NPC6p1nnqAMzf13qq0e4Vr/B+F08+aRlsfup5ZHo6z5R5UatpbvvAAM5Q/AUWGT5v DgGw6/mzuRnWjzierm2Oa3T9tiCz9opjxB77yBpIqWTqCflPcP7kut35lbwrZOD5xQd6 AnAH/Shgn2tmYNt6pUsrFK5qcdHKf50Q7UFoU1A4I5kDLuAMVMRb9sTAnCMHvPE4vEvS eJsEALSsiNrPEv42lB+064jNktNA9RPreAfVBKVeqV+9qDnVlIMgt8pmv+Rsy9K6CrdB kq7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:cms-type:mime-version :message-id:date:to:from:dkim-signature:dkim-filter:delivered-to; bh=VHH/yaDpqH2x/U4x0qtuGfKFm3T8lUHpK9Pgcv1SgrA=; b=Q3bChQzNi2B81YkNKk3X3pragE8jpbRV8Mr+GIqLRpMPp5CncsZ/wqy2WM32cXUxvn ifAtpkA02YA1Nu2fgbak6JgfuuFqJQ9a5BTGSvda1/yxg3J+mWKnM6QqtLunopXhLYbZ gHpsMPTejncnFxJLtHM+VDiRcmZg6dxtiG0MR4Dl5+J4BrLp6vPtbfWR0Qv34UkcdWQj LHh8XSJxa0/jvRRlj+KV5a+gL7LkxFAwKe1jxM0JlFyp5usc+u0FpJsWVSwBjiDYk0Tj wJI14VDQpRZtz8yUsum0HcyIN/MW/1oB5qCfPyqlFkbX+coRGXUlOjY9C6QL3wd6ba/+ Z59A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=Xhf1RkVl; 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 qc12-20020a170906d8ac00b0074853e69fbfsi8213071ejb.213.2022.09.06.04.45.52; Tue, 06 Sep 2022 04:45:53 -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=Xhf1RkVl; 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 AE7F568BB24; Tue, 6 Sep 2022 14:45:49 +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 0CBBE68B721 for ; Tue, 6 Sep 2022 14:45:42 +0300 (EEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220906114531euoutp01db0974391ea7459262e2ff2b79ef7fcb~SQt2CRfKU3129731297euoutp01J for ; Tue, 6 Sep 2022 11:45:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220906114531euoutp01db0974391ea7459262e2ff2b79ef7fcb~SQt2CRfKU3129731297euoutp01J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662464731; bh=fodhCGQYlboA3AmjZbdU1oiDDo3k3jO+0N2rd8hr9QI=; h=From:To:Cc:Subject:Date:References:From; b=Xhf1RkVleCH2xyi31c55Jme/nW1J2bnW58jTdAbjZ3hixcdbzUQ9B4o9adoSJHKKZ 0BhThoBk1glRSYXIoi2yFCZlQFFDnd4/DCLRb0POOCyFfiyz+NRf21tMFSI5DMWrRq M5OwvHN2+5IARcztF5U5p1ISsI9G9ODuz67jTYaw= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220906114526eucas1p11d2e1be1db9092ce0185423dad81c812~SQtxC1des3067830678eucas1p1U; Tue, 6 Sep 2022 11:45:26 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id D6.B3.07817.6D237136; Tue, 6 Sep 2022 12:45:26 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220906114525eucas1p2a0df962e8710d4ac9f59d7d86308de8a~SQtwcwn1c0068600686eucas1p2H; Tue, 6 Sep 2022 11:45:25 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220906114525eusmtrp19aa08a5b41cbc1be0527986c600dfa65~SQtwb8DtI1663016630eusmtrp1Z; Tue, 6 Sep 2022 11:45:25 +0000 (GMT) X-AuditID: cbfec7f4-8abff70000011e89-8b-631732d68876 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 12.F9.07473.5D237136; Tue, 6 Sep 2022 12:45:25 +0100 (BST) Received: from AMDN3260.EU.corp.samsungelectronics.net (unknown [106.210.132.171]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220906114524eusmtip24637f10b235c189a751642fb90984809~SQtvv7hak1863018630eusmtip2_; Tue, 6 Sep 2022 11:45:24 +0000 (GMT) From: Dawid Kozinski To: d.frankiewic@samsung.com, ffmpeg-devel@ffmpeg.org Date: Tue, 6 Sep 2022 13:45:14 +0200 Message-Id: <20220906114514.1317-1-d.kozinski@samsung.com> X-Mailer: git-send-email 2.24.0.windows.2 MIME-Version: 1.0 X-Unsent: 1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNIsWRmVeSWpSXmKPExsWy7djPc7rXjMSTDba957L4cu0Ls8XKb79Z LL59OsPswOzxZ9FmFo++LasYA5iiuGxSUnMyy1KL9O0SuDLePf3DXnBkEWPFvtY5rA2Mu8u6 GDk5JARMJNqbjrN1MXJxCAmsYJT4/fgdlPOFUWLxt1lQzmdGiXXXnrLBtMxd9JUFIrGcUeLI zQawhJBAO5PEiiUOIDabgK7Eyw+PmEBsEQFTiZPNe8FqmAW0Jdbd/Q5mCwsESLxvWMMCYrMI qErs3zKREcTmFbCS2HW4hx1imabE7AntzBBxQYmTM5+wQMS5JdbNusQKMVNeonnrbGaQgyQE frJLfHq/H6iIA8hxkfh6zAWiXlji1fEtUDNlJE5P7oEqKZY41O8AYdZIHPqRDlFhLfG28Tgj SJgZ6IL1u/Qhwo4S399PZYSo5pO48VYQYj+fxKRt05khwrwSHW1CEKaKRF+nGESjlMTTZXOY IWwPiUeHFzBPYFScheSpWUgemYWwdgEj8ypG8dTS4tz01GKjvNRyveLE3OLSvHS95PzcTYzA 9HD63/EvOxiXv/qod4iRiYPxEKMEB7OSCG/KDpFkId6UxMqq1KL8+KLSnNTiQ4zSHCxK4rzJ mRsShQTSE0tSs1NTC1KLYLJMHJxSDUwGtyxZN+iWWKxjEWLhq/s3L1Tr2v67k47pnvCftatQ q6Rhq7Jeob6MpMva2gTOY2pK+nnP1vhlRkxp2fLAU13qCFffjYeex8qr9oj+S+NlZ8ieZCl/ pGdxz5pW7s+c0/5qelp/mjxDhXVe1Lq3jALq24VsprXd4wnxZnp6OuDWbcvsez/ZLUyY9eTP 9i1cqa3Q9OFDt2Jkd2i95ibhrcePnVeKjL50/0VyfdGF4ojG3XW9KpO3rlwdwBp2+8JJ7oU7 /7P5Xvn7iOtqQYB6HPPTrUx8G44v3P3m4t7Gzzz102L5N83yOzgpjbNfde2emQo+y3q3dFyx 3fHkqf2+a/r9vLKngkWE3rT2rnv/f6ISS3FGoqEWc1FxIgCH1OP0fgMAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrMLMWRmVeSWpSXmKPExsVy+t/xe7pXjcSTDdraZC2+XPvCbLHy228W i2+fzjA7MHv8WbSZxaNvyyrGAKYoPZui/NKSVIWM/OISW6VoQwsjPUNLCz0jE0s9Q2PzWCsj UyV9O5uU1JzMstQifbsEvYx3T/+wFxxZxFixr3UOawPj7rIuRk4OCQETibmLvrJ0MXJxCAks ZZR4e3kjI0RCSmLp0kVQtrDEn2tdbBBFrUwSb58vZQJJsAnoSrz88AjMFhEwl7i47hZYA7OA tsS6u9/ZQGxhAT+JeXsXgdksAqoS+7dMBKvhFbCS2HW4hx1igabE7AntzBBxQYmTM5+wQMS5 JdbNusQKMVNeonnrbOYJjPyzkJTNQpJawMi0ilEktbQ4Nz232FCvODG3uDQvXS85P3cTIzB0 tx37uXkH47xXH/UOMTJxMB5ilOBgVhLhTdkhkizEm5JYWZValB9fVJqTWnyI0RTo1onMUqLJ +cDoySuJNzQzMDU0MbM0MLU0M1YS5/Us6EgUEkhPLEnNTk0tSC2C6WPi4JRqYCrUVpnrtNNr 0+VPa44dd8/aK6l+cKHw+/6DIv9u7/4RpbJp9jnOHOdpFqERnYy3lpS9XaOR9GoZo+kv/Rme Zcf4I7ll/+RN+ph+2MrMsuXW9Oakf0XatzvPMbvOPL5Uh/nTgQtu/l4X3/nIX+i8UltU+dTC SXQen/d37tTD15KNO/7IRc6dcHjTyuyV+p/27V5SnS9ad/6b0Mozi0/NT2p+q7Hg5S/bslPn Dx2tWi3ieZL5qO+xo+cFvk8Ovf48+aKstNbMevNED6Xy3pA6F6Ytcw/5813fErFyq/BimfDw w1sFXa9ffOIUmNF60FH90QHNztLg/3ffSS3K1J3EaFB80U/76JUk1w8/9PUYti1SYinOSDTU Yi4qTgQA/QBkbeYCAAA= X-CMS-MailID: 20220906114525eucas1p2a0df962e8710d4ac9f59d7d86308de8a X-Msg-Generator: CA X-RootMTR: 20220906114525eucas1p2a0df962e8710d4ac9f59d7d86308de8a X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220906114525eucas1p2a0df962e8710d4ac9f59d7d86308de8a References: Subject: [FFmpeg-devel] [PATCH v12 6/9] avcodec/evc_decoder: Provided support for EVC decoder X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Dawid Kozinski Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 0Xxir8qpPv5b - Added EVC decoder wrapper - Changes in project configuration file and libavcodec Makefile - Added documentation for xevd wrapper Signed-off-by: Dawid Kozinski --- configure | 4 + doc/decoders.texi | 24 +++ doc/general_contents.texi | 10 +- libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/libxevd.c | 423 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 462 insertions(+), 1 deletion(-) create mode 100644 libavcodec/libxevd.c diff --git a/configure b/configure index 0ad6f59de8..fc507cc42c 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 @@ -3402,6 +3404,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" @@ -6725,6 +6728,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 9f911ae7ec..79fc84e4ff 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..133d004f4b --- /dev/null +++ b/libavcodec/libxevd.c @@ -0,0 +1,423 @@ +/* + * libxevd decoder + * EVC (MPEG-5 Essential Video Coding) decoding using XEVD MPEG-5 EVC decoder library + * + * Copyright (C) 2021 Dawid Kozinski + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include + +#include + +#include "libavutil/internal.h" +#include "libavutil/common.h" +#include "libavutil/opt.h" +#include "libavutil/pixdesc.h" +#include "libavutil/pixfmt.h" +#include "libavutil/imgutils.h" +#include "libavutil/cpu.h" + +#include "avcodec.h" +#include "internal.h" +#include "packet_internal.h" +#include "codec_internal.h" +#include "profiles.h" +#include "decode.h" + +#define XEVD_PARAM_BAD_NAME -1 +#define XEVD_PARAM_BAD_VALUE -2 + +#define EVC_NAL_HEADER_SIZE 2 /* byte */ + +/** + * The structure stores all the states associated with the instance of Xeve MPEG-5 EVC decoder + */ +typedef struct XevdContext { + const AVClass *class; + + XEVD id; // XEVD instance identifier @see xevd.h + XEVD_CDSC cdsc; // decoding parameters @see xevd.h +} XevdContext; + +/** + * The function populates the XEVD_CDSC structure. + * XEVD_CDSC contains all decoder parameters that should be initialized before its use. + * + * @param[in] avctx codec context + * @param[out] cdsc contains all decoder parameters that should be initialized before its use + * + */ +static void get_conf(AVCodecContext *avctx, XEVD_CDSC *cdsc) +{ + int cpu_count = av_cpu_count(); + + /* clear XEVS_CDSC structure */ + memset(cdsc, 0, sizeof(XEVD_CDSC)); + + /* init XEVD_CDSC */ + if (avctx->thread_count <= 0) + cdsc->threads = (cpu_count < XEVD_MAX_TASK_CNT) ? cpu_count : XEVD_MAX_TASK_CNT; + else if (avctx->thread_count > XEVD_MAX_TASK_CNT) + cdsc->threads = XEVD_MAX_TASK_CNT; + else + cdsc->threads = avctx->thread_count; +} + +/** + * Read NAL unit length + * @param bs input data (bitstream) + * @return the length of NAL unit on success, 0 value on failure + */ +static uint32_t read_nal_unit_length(const uint8_t *bs, int bs_size, AVCodecContext *avctx) +{ + uint32_t len = 0; + XEVD_INFO info; + int ret; + + if (bs_size == XEVD_NAL_UNIT_LENGTH_BYTE) { + ret = xevd_info((void *)bs, XEVD_NAL_UNIT_LENGTH_BYTE, 1, &info); + if (XEVD_FAILED(ret)) { + av_log(avctx, AV_LOG_ERROR, "Cannot get bitstream information\n"); + return 0; + } + len = info.nalu_len; + if (len == 0) { + av_log(avctx, AV_LOG_ERROR, "Invalid bitstream size! [%d]\n", bs_size); + return 0; + } + } + + return len; +} + +/** + * @param[in] xectx the structure that stores all the state associated with the instance of Xeve MPEG-5 EVC decoder + * @param[out] avctx codec context + * @return 0 on success, negative value on failure + */ +static int export_stream_params(const XevdContext *xectx, AVCodecContext *avctx) +{ + int ret; + int size; + int color_space; + + avctx->pix_fmt = AV_PIX_FMT_YUV420P10; + + size = 4; + ret = xevd_config(xectx->id, XEVD_CFG_GET_CODED_WIDTH, &avctx->coded_width, &size); + if (XEVD_FAILED(ret)) { + av_log(avctx, AV_LOG_ERROR, "Failed to get coded_width\n"); + return AVERROR_EXTERNAL; + } + + ret = xevd_config(xectx->id, XEVD_CFG_GET_CODED_HEIGHT, &avctx->coded_height, &size); + if (XEVD_FAILED(ret)) { + av_log(avctx, AV_LOG_ERROR, "Failed to get coded_height\n"); + return AVERROR_EXTERNAL; + } + + ret = xevd_config(xectx->id, XEVD_CFG_GET_WIDTH, &avctx->width, &size); + if (XEVD_FAILED(ret)) { + av_log(avctx, AV_LOG_ERROR, "Failed to get width\n"); + return AVERROR_EXTERNAL; + } + + ret = xevd_config(xectx->id, XEVD_CFG_GET_HEIGHT, &avctx->height, &size); + if (XEVD_FAILED(ret)) { + av_log(avctx, AV_LOG_ERROR, "Failed to get height\n"); + return AVERROR_EXTERNAL; + } + + ret = xevd_config(xectx->id, XEVD_CFG_GET_COLOR_SPACE, &color_space, &size); + if (XEVD_FAILED(ret)) { + av_log(avctx, AV_LOG_ERROR, "Failed to get color_space\n"); + return AVERROR_EXTERNAL; + } + switch(color_space) { + case XEVD_CS_YCBCR400_10LE: + avctx->pix_fmt = AV_PIX_FMT_GRAY10LE; + break; + case XEVD_CS_YCBCR420_10LE: + avctx->pix_fmt = AV_PIX_FMT_YUV420P10LE; + break; + case XEVD_CS_YCBCR422_10LE: + avctx->pix_fmt = AV_PIX_FMT_YUV422P10LE; + break; + case XEVD_CS_YCBCR444_10LE: + avctx->pix_fmt = AV_PIX_FMT_YUV444P10LE; + break; + default: + av_log(avctx, AV_LOG_ERROR, "Unknown color space\n"); + avctx->pix_fmt = AV_PIX_FMT_NONE; + return AVERROR_INVALIDDATA; + } + + // the function returns sps->num_reorder_pics + ret = xevd_config(xectx->id, XEVD_CFG_GET_MAX_CODING_DELAY, &avctx->max_b_frames, &size); + if (XEVD_FAILED(ret)) { + av_log(avctx, AV_LOG_ERROR, "Failed to get max_coding_delay\n"); + return AVERROR_EXTERNAL; + } + + avctx->has_b_frames = (avctx->max_b_frames) ? 1 : 0; + + avctx->color_primaries = AVCOL_PRI_UNSPECIFIED; + avctx->color_trc = AVCOL_TRC_UNSPECIFIED; + avctx->colorspace = AVCOL_SPC_UNSPECIFIED; + + return 0; +} + +/** + * @brief Copy image in imgb to frame. + * + * @param avctx codec context + * @param[in] imgb + * @param[out] frame + * @return 0 on success, negative value on failure + */ +static int libxevd_image_copy(struct AVCodecContext *avctx, XEVD_IMGB *imgb, struct AVFrame *frame) +{ + int ret; + if (imgb->cs != XEVD_CS_YCBCR420_10LE) { + av_log(avctx, AV_LOG_ERROR, "Not supported pixel format: %s\n", av_get_pix_fmt_name(avctx->pix_fmt)); + return AVERROR_INVALIDDATA; + } + + if (imgb->w[0] != avctx->width || imgb->h[0] != avctx->height) { // stream resolution changed + if (ff_set_dimensions(avctx, imgb->w[0], imgb->h[0]) < 0) { + av_log(avctx, AV_LOG_ERROR, "Cannot set new dimension\n"); + return AVERROR_INVALIDDATA; + } + } + + if (ret = ff_get_buffer(avctx, frame, 0) < 0) { + return ret; + } + + av_image_copy(frame->data, frame->linesize, (const uint8_t **)imgb->a, + imgb->s, avctx->pix_fmt, + imgb->w[0], imgb->h[0]); + + return 0; +} + +/** + * Initialize decoder + * Create a decoder instance and allocate all the needed resources + * + * @param avctx codec context + * @return 0 on success, negative error code on failure + */ +static av_cold int libxevd_init(AVCodecContext *avctx) +{ + XevdContext *xectx = avctx->priv_data; + XEVD_CDSC *cdsc = &(xectx->cdsc); + + /* read configurations and set values for created descriptor (XEVD_CDSC) */ + get_conf(avctx, cdsc); + + /* create decoder */ + xectx->id = xevd_create(&(xectx->cdsc), NULL); + if (xectx->id == NULL) { + av_log(avctx, AV_LOG_ERROR, "Cannot create XEVD encoder\n"); + return AVERROR_EXTERNAL; + } + + return 0; +} + +/** + * Decode picture + * + * @param avctx codec context + * @param[out] frame decoded frame + * @param[out] got_frame_ptr decoder sets to 0 or 1 to indicate that a + * non-empty frame or subtitle was returned in + * outdata. + * @param[in] avpkt AVPacket containing encoded data to be decoded + * + * @return amount of bytes read from the packet on success, negative error + * code on failure + */ +static int libxevd_decode(struct AVCodecContext *avctx, struct AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt) +{ + XevdContext *xectx = NULL; + XEVD_IMGB *imgb = NULL; + XEVD_STAT stat; + XEVD_BITB bitb; + int xevd_ret, nalu_size, bs_read_pos; + int ret = 0; + + xectx = avctx->priv_data; + + if (avpkt->size > 0) { + bs_read_pos = 0; + imgb = NULL; + while(avpkt->size > (bs_read_pos + XEVD_NAL_UNIT_LENGTH_BYTE)) { + memset(&stat, 0, sizeof(XEVD_STAT)); + memset(&bitb, 0, sizeof(XEVD_BITB)); + + nalu_size = read_nal_unit_length(avpkt->data + bs_read_pos, XEVD_NAL_UNIT_LENGTH_BYTE, avctx); + if (nalu_size == 0) { + av_log(avctx, AV_LOG_ERROR, "Invalid bitstream\n"); + ret = AVERROR_INVALIDDATA; + goto ERR; + } + bs_read_pos += XEVD_NAL_UNIT_LENGTH_BYTE; + + bitb.addr = avpkt->data + bs_read_pos; + bitb.ssize = nalu_size; + + /* main decoding block */ + xevd_ret = xevd_decode(xectx->id, &bitb, &stat); + if (XEVD_FAILED(xevd_ret)) { + av_log(avctx, AV_LOG_ERROR, "Failed to decode bitstream\n"); + ret = AVERROR_EXTERNAL; + goto ERR; + } + + bs_read_pos += nalu_size; + + if (stat.nalu_type == XEVD_NUT_SPS) { // EVC stream parameters changed + if ((ret = export_stream_params(xectx, avctx)) != 0) + goto ERR; + } + + if (stat.read != nalu_size) + av_log(avctx, AV_LOG_INFO, "Different reading of bitstream (in:%d, read:%d)\n,", nalu_size, stat.read); + if (stat.fnum >= 0) { + // already has a decoded image + if (imgb) { + // xevd_pull uses pool of objects of type XEVD_IMGB. + // The pool size is equal MAX_PB_SIZE (26), so release object when it is no more needed + imgb->release(imgb); + imgb = NULL; + } + xevd_ret = xevd_pull(xectx->id, &imgb); + if (XEVD_FAILED(xevd_ret)) { + av_log(avctx, AV_LOG_ERROR, "Failed to pull the decoded image (xevd error code: %d, frame#=%d)\n", xevd_ret, stat.fnum); + ret = AVERROR_EXTERNAL; + goto ERR; + } else if (xevd_ret == XEVD_OK_FRM_DELAYED) { + if (imgb) { + // xevd_pull uses pool of objects of type XEVD_IMGB. + // The pool size is equal MAX_PB_SIZE (26), so release object when it is no more needed + imgb->release(imgb); + imgb = NULL; + } + } + if (imgb) { + int ret = libxevd_image_copy(avctx, imgb, frame); + if(ret < 0) { + goto ERR; + } + + frame->pts = avpkt->pts; + *got_frame_ptr = 1; + + // xevd_pull uses pool of objects of type XEVD_IMGB. + // The pool size is equal MAX_PB_SIZE (26), so release object when it is no more needed + imgb->release(imgb); + imgb = NULL; + } else + *got_frame_ptr = 0; + } + } + } else { // bumping + xevd_ret = xevd_pull(xectx->id, &(imgb)); + if (xevd_ret == XEVD_ERR_UNEXPECTED) { // bumping process completed + *got_frame_ptr = 0; + return 0; + } else if (XEVD_FAILED(xevd_ret)) { + av_log(avctx, AV_LOG_ERROR, "Failed to pull the decoded image (xevd error code: %d)\n", xevd_ret); + ret = AVERROR_EXTERNAL; + goto ERR; + } + if (imgb) { + int ret = libxevd_image_copy(avctx, imgb, frame); + if(ret < 0) { + goto ERR; + } + + frame->pts = avpkt->pts; + *got_frame_ptr = 1; + + // xevd_pull uses pool of objects of type XEVD_IMGB. + // The pool size is equal MAX_PB_SIZE (26), so release object when it is no more needed + imgb->release(imgb); + imgb = NULL; + } else + *got_frame_ptr = 0; + } + + return avpkt->size; + +ERR: + if (imgb) { + imgb->release(imgb); + imgb = NULL; + } + *got_frame_ptr = 0; + + return ret; +} + +/** + * Destroy decoder + * + * @param avctx codec context + * @return 0 on success + */ +static av_cold int libxevd_close(AVCodecContext *avctx) +{ + XevdContext *xectx = avctx->priv_data; + if (xectx->id) { + xevd_delete(xectx->id); + xectx->id = NULL; + } + + return 0; +} + +#define OFFSET(x) offsetof(XevdContext, x) +#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM + +static const AVClass libxevd_class = { + .class_name = "libxevd", + .item_name = av_default_item_name, + .version = LIBAVUTIL_VERSION_INT, +}; + +const FFCodec ff_libxevd_decoder = { + .p.name = "evc", + .p.long_name = NULL_IF_CONFIG_SMALL("EVC / MPEG-5 Essential Video Coding (EVC)"), + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_EVC, + .init = libxevd_init, + FF_CODEC_DECODE_CB(libxevd_decode), + .close = libxevd_close, + .priv_data_size = sizeof(XevdContext), + .p.priv_class = &libxevd_class, + .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_DR1, + .p.profiles = NULL_IF_CONFIG_SMALL(ff_evc_profiles), + .p.wrapper_name = "libxevd", + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_NOT_INIT_THREADSAFE, +}; From patchwork Tue Sep 6 11:46:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawid Kozinski X-Patchwork-Id: 37707 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp3204389pzh; Tue, 6 Sep 2022 04:47:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR41vJjz21d4bBmZowztDGEdyoS/Bzy7JZ1dCtTe5UFShu1Q+tpFNcx5+pnXBW9/r0Pocbfm X-Received: by 2002:a17:906:eecb:b0:73c:5c85:142b with SMTP id wu11-20020a170906eecb00b0073c5c85142bmr38770804ejb.433.1662464820268; Tue, 06 Sep 2022 04:47:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662464820; cv=none; d=google.com; s=arc-20160816; b=C6wwPJun9B2Fo57yJx4+8xlfqx817gG8K8LqVONmdl6A1y4s+as5zvvp8WmO8VwDtQ 2Rsi/slr9AwQ2Vg8LoHXqyTOBeZI7FpAVDomBP8Skz7n+8J2Qje4GNbRgni3g5UUUjfO h1RebXAgI2vLxvA5K4i371iF48R/zAB3KPzniBamfKKFz9SH8tK3tKjb2Bqa9k9pm1vq GaTGZ2Jc96mexYhL8AnWJUD1X6PM8/cx9pBuVNiTLCqDmQyIlZGERyPa1ce7hoQuXKxi Bqy6yhAJzlh/0P9BvSq2/PooCVtkSTy1fj8zOcSW7/2CAP4rQO2rPK+GxGhVLmB460Es J5oA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:cms-type:mime-version :message-id:date:to:from:dkim-signature:dkim-filter:delivered-to; bh=YtDqKeCNCkQnu6ksBeQbZJFGTGm1gvOyaq8ijN2YNEA=; b=Rq/TMtY4Qvq0YAPbaqW/LhOpJFAM1h6VL+q8MCTfHrCU3WEG9x4qLFZeUjxcEpBb0Z sj4zRekw8e4X6DA3kZF2UbDFlTIewPJYDId1/JK/oe8hGkJz+R04PFNaZaKKfuAm+39V oEVQGRz9OTa7aTYoIROyVBhkpdLhC39odkejDyt3Lfgymfa4Xjdeguka47D9bL23OpXL pajBeSZbtvKLcj3qEW5EncsqjPODhq4igZP++8GnLgK4IhzSHvqB6moTNkrcju5dnl2v vCHciQ05s2mihEj2xIlEiicupBD/G7C7lGgaC8dygZevJpmA6fZXOpP5eboJtMK8gnNg eedg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=J9L6l+Ai; 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 cw16-20020a170906479000b00734bbe8d2casi9702626ejc.608.2022.09.06.04.46.59; Tue, 06 Sep 2022 04:47:00 -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=J9L6l+Ai; 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 CD58568BAFD; Tue, 6 Sep 2022 14:46:57 +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 EC8DA68BAFD for ; Tue, 6 Sep 2022 14:46:51 +0300 (EEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220906114640euoutp02df78a906e1fc66feb1e0c8c59ea90a1e~SQu2c3Ote0797107971euoutp02a for ; Tue, 6 Sep 2022 11:46:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220906114640euoutp02df78a906e1fc66feb1e0c8c59ea90a1e~SQu2c3Ote0797107971euoutp02a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662464800; bh=se8e1F3teg9fGi4p20qqrCiJi5MEm0HOe/ZBXn+fhMA=; h=From:To:Cc:Subject:Date:References:From; b=J9L6l+Aiv/e9sSso+cHVnC0+PZCPqiSIKsSE+P41tZp7OyTBAW1OsT6EYjLASz8BB aRUlnYIZR4IhFE6KdB9AIg1N9aP+9RrhY6fR77LXe72WBHFSZwEUiaL1s6XcIcxf+S LmA6Iw4dyRs2UV04x+/nkpCnfMogqs/8goFhs+WU= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220906114630eucas1p22064a00f8a01cfae21ae54dfde0132a0~SQutOnXzu0477904779eucas1p2W; Tue, 6 Sep 2022 11:46:30 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id B6.87.29727.61337136; Tue, 6 Sep 2022 12:46:30 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220906114630eucas1p17f2dcf958fdf11f804986f1fac028d54~SQus2zdbd1736717367eucas1p1g; Tue, 6 Sep 2022 11:46:30 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220906114630eusmtrp2f16f178c8bb09c6026d3195ec564b31e~SQus2I9G40345503455eusmtrp2c; Tue, 6 Sep 2022 11:46:30 +0000 (GMT) X-AuditID: cbfec7f2-21dff7000001741f-6a-631733165e29 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id C6.2A.07473.61337136; Tue, 6 Sep 2022 12:46:30 +0100 (BST) Received: from AMDN3260.EU.corp.samsungelectronics.net (unknown [106.210.132.171]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220906114629eusmtip1b36f37753dffc56b94f592ceb04ee0e6~SQusI82uR3214032140eusmtip1L; Tue, 6 Sep 2022 11:46:29 +0000 (GMT) From: Dawid Kozinski To: d.frankiewic@samsung.com, ffmpeg-devel@ffmpeg.org Date: Tue, 6 Sep 2022 13:46:21 +0200 Message-Id: <20220906114621.891-1-d.kozinski@samsung.com> X-Mailer: git-send-email 2.24.0.windows.2 MIME-Version: 1.0 X-Unsent: 1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDIsWRmVeSWpSXmKPExsWy7djPc7pixuLJBpt/61l8ufaF2WLlt98s Ft8+nWF2YPb4s2gzi0ffllWMAUxRXDYpqTmZZalF+nYJXBmLFx9gKri4m7Hi3J73LA2MfzoY uxg5OSQETCTOXlvDDGILCaxglFh6XrKLkQvI/sIocelVIyuE85lR4tnHPSwwHef+HWOESCxn lNiy7S07hNPOJPH5wypWkCo2AV2Jlx8eMYHYIgKmEieb97KB2MwC2hLr7n4Hs4UFYiXOvelg B7FZBFQlvlw/CmbzClhKvOg9CXWfpsTsCe3MEHFBiZMzn0BdwS2xbtYlVoiZ8hLNW2czgxwh IfCTXeJO82GgQRxAjovEi63aEPXCEq+Ob2GHsGUk/u+czwRRUixxqN8BwqyROPQjHaLCWuJt 43FGkDAz0AXrd+lDhB0lFu2ZzwhRzSdx460gxH4+iUnbpjNDhHklOtqEIEwVib5OMYhGKYmn y+YwQ9geEv3H/7NOYFScheSpWUgemYWwdgEj8ypG8dTS4tz01GLDvNRyveLE3OLSvHS95Pzc TYzABHH63/FPOxjnvvqod4iRiYPxEKMEB7OSCG/KDpFkId6UxMqq1KL8+KLSnNTiQ4zSHCxK 4rzJmRsShQTSE0tSs1NTC1KLYLJMHJxSDUyqd+4nMbm9nv9nNrdhSezKyd/3GTjGF76b9nB6 V1bh1TJDtheO+pcfbHtur26dULhghfzPvgW2sTJ1EXN+fiqfuibOUtgu4PL96e6toev5+1dw dQq/fSkiEvnuYopm5aQLtWvnzFG+wtEheY99wZpkf6uXDhLHWO+qbzlyXmBTf/WLS7IPbuRZ zujkclfb+OOvmqvzmf+BGhF3L01Yf87V2Ha3c3Kc5N/0p6fO61pk3Z+a61jhmbH1db74+m+e VpyVdzUSeDO23WlK03/u+PS2t3oz+6Uruty/xGf8ENX7Xd5hEDPZ8+dG6wS76IP/OUt41Jle 5dc9jVhnbaG2Vq73v7xdxad9NybELD/zOEyJpTgj0VCLuag4EQAxj0ACfwMAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrMLMWRmVeSWpSXmKPExsVy+t/xu7pixuLJBofuill8ufaF2WLlt98s Ft8+nWF2YPb4s2gzi0ffllWMAUxRejZF+aUlqQoZ+cUltkrRhhZGeoaWFnpGJpZ6hsbmsVZG pkr6djYpqTmZZalF+nYJehmLFx9gKri4m7Hi3J73LA2MfzoYuxg5OSQETCTO/TsGZHNxCAks ZZRY1bmSHSIhJbF06SKoImGJP9e62CCKWpkkbqxcwQqSYBPQlXj54RETiC0iYC5xcd0tsAZm AW2JdXe/AzVwcAgLREvMfqEAEmYRUJX4cv0o2HxeAUuJF70noeZrSsye0M4MEReUODnzCQtE nFti3axLrBAj5SWat85mnsDIPwtJ2SwkqQWMTKsYRVJLi3PTc4sN9YoTc4tL89L1kvNzNzEC Q3fbsZ+bdzDOe/VR7xAjEwfjIUYJDmYlEd6UHSLJQrwpiZVVqUX58UWlOanFhxhNgW6dyCwl mpwPjJ68knhDMwNTQxMzSwNTSzNjJXFez4KORCGB9MSS1OzU1ILUIpg+Jg5OqQamSRa6hRvu mvQYKxffaetcsPPuCWUL3/t3HpgsqFk5K/jfp0OuQovrD/fUeM3+FX5MreSazLI77Uf3yjx5 9tvta+Yrlr+fNnBdXtBYb7RC7YnAvVRJn4f9cnUWFwPm73H6VCPtEcF8sOGa/tsnny/dfyi1 RJj/5x6N2TJnE4WSFTT3vnWVcWOI5vI4ybj0kieb3pPsCf8fHghKeqOo7ZFvMLNwnbuNL5Na +c4vpSUtHTJhOdZM37s6J1xXST1mK1FyRYhb3FOoavXMuf/evkpZu8uxbT/X2TDLSwyPVe9n 6Z6oDOJc2RvLH++ZJhb09CS7uY1+sE1hcO+mHWyXUsPLg97VlaxetvfQm7a3dzWVWIozEg21 mIuKEwHDhjrP5gIAAA== X-CMS-MailID: 20220906114630eucas1p17f2dcf958fdf11f804986f1fac028d54 X-Msg-Generator: CA X-RootMTR: 20220906114630eucas1p17f2dcf958fdf11f804986f1fac028d54 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220906114630eucas1p17f2dcf958fdf11f804986f1fac028d54 References: Subject: [FFmpeg-devel] [PATCH v12 7/9] avformat/mov_muxer: Extended MOV muxer to handle EVC video content X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Dawid Kozinski Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: c50z0r3Gc2H/ - Changes in mov_write_video_tag function to handle EVC elementary stream - Provided structure EVCDecoderConfigurationRecord that specifies the decoder configuration information for ISO/IEC 23094-1 video content Signed-off-by: Dawid Kozinski --- libavformat/Makefile | 2 +- libavformat/evc.c | 455 ++++++++++++++++++++++++++++++++++++++++ libavformat/evc.h | 44 ++++ libavformat/isom_tags.c | 2 + libavformat/movenc.c | 35 +++- 5 files changed, 536 insertions(+), 2 deletions(-) create mode 100644 libavformat/evc.c create mode 100644 libavformat/evc.h diff --git a/libavformat/Makefile b/libavformat/Makefile index 09debd8897..58a237735c 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..72c2759924 --- /dev/null +++ b/libavformat/evc.c @@ -0,0 +1,455 @@ +/* + * EVC helper functions for muxers + * Copyright (c) 2022 Dawid Kozinski + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/intreadwrite.h" +#include "libavcodec/get_bits.h" +#include "libavcodec/golomb.h" +#include "libavcodec/evc.h" +#include "avformat.h" +#include "avio.h" +#include "evc.h" +#include "avio_internal.h" + +// The length field that indicates the length in bytes of the following NAL unit is configured to be of 4 bytes +#define EVC_NAL_UNIT_LENGTH_BYTE (4) /* byte */ +#define EVC_NAL_HEADER_SIZE (2) /* byte */ + +// @see ISO/IEC 14496-15:2021 Coding of audio-visual objects - Part 15: section 12.3.3.1 +enum { + SPS_INDEX, + PPS_INDEX, + APS_INDEX, + SEI_INDEX, + NB_ARRAYS +}; + +// rpl structure +typedef struct RefPicListStruct { + int poc; + int tid; + int ref_pic_num; + int ref_pic_active_num; + int ref_pics[EVC_MAX_NUM_REF_PICS]; + char pic_type; + +} RefPicListStruct; + +// The sturcture reflects SPS RBSP(raw byte sequence payload) layout +// @see ISO_IEC_23094-1 section 7.3.2.1 +// +// The following descriptors specify the parsing process of each element +// u(n) - unsigned integer using n bits +// ue(v) - unsigned integer 0-th order Exp_Golomb-coded syntax element with the left bit first +typedef struct EVCSPS { + int sps_seq_parameter_set_id; // ue(v) + int profile_idc; // u(8) + int level_idc; // u(8) + int toolset_idc_h; // u(32) + int toolset_idc_l; // u(32) + int chroma_format_idc; // ue(v) + int pic_width_in_luma_samples; // ue(v) + int pic_height_in_luma_samples; // ue(v) + int bit_depth_luma_minus8; // ue(v) + int bit_depth_chroma_minus8; // ue(v) + + // @note + // Currently the structure does not reflect the entire SPS RBSP layout. + // It contains only the fields that are necessary to read from the NAL unit all the values + // necessary for the correct initialization of EVCDecoderConfigurationRecord + + // @note + // If necessary, add the missing fields to the structure to reflect + // the contents of the entire NAL unit of the SPS type + +} EVCSPS; + +// @see ISO/IEC 14496-15:2021 Coding of audio-visual objects - Part 15: section 12.3.3.3 +typedef struct EVCNALUnitArray { + uint8_t array_completeness; // when equal to 1 indicates that all NAL units of the given type are in the following array + uint8_t NAL_unit_type; // indicates the type of the NAL units in the following array + uint16_t numNalus; // indicates the number of NAL units of the indicated type + uint16_t *nalUnitLength; // indicates the length in bytes of the NAL unit + uint8_t **nalUnit; // contains an SPS, PPS, APS or a SEI NAL unit, as specified in ISO/IEC 23094-1 +} EVCNALUnitArray; + +/** + * @brief Specifies the decoder configuration information for ISO/IEC 23094-1 video content. + * @see ISO/IEC 14496-15:2021 Coding of audio-visual objects - Part 15: section 12.3.3.2 + * Carriage of network abstraction layer (NAL) unit structured video in the ISO base media file format + */ +typedef struct EVCDecoderConfigurationRecord { + uint8_t configurationVersion; // 8 bits + uint8_t profile_idc; // 8 bits + uint8_t level_idc; // 8 bits + uint32_t toolset_idc_h; // 32 bits + uint32_t toolset_idc_l; // 32 bits + uint8_t chroma_format_idc; // 2 bits + uint8_t bit_depth_luma_minus8; // 3 bits + uint8_t bit_depth_chroma_minus8; // 3 bits + uint16_t pic_width_in_luma_samples; // 16 bits + uint16_t pic_height_in_luma_samples; // 16 bits + uint8_t reserved; // 6 bits '000000'b + uint8_t lengthSizeMinusOne; // 2 bits + uint8_t num_of_arrays; // 8 bits + EVCNALUnitArray arrays[NB_ARRAYS]; +} EVCDecoderConfigurationRecord; + +typedef struct NALU { + int offset; + uint32_t size; +} NALU; + +typedef struct NALUList { + NALU *nalus; + unsigned nalus_array_size; + unsigned nb_nalus; ///< valid entries in nalus +} NALUList; + +static int get_nalu_type(const uint8_t *bits, int bits_size) +{ + int unit_type_plus1 = 0; + + if (bits_size >= EVC_NAL_HEADER_SIZE) { + unsigned char *p = (unsigned char *)bits; + // forbidden_zero_bit + if ((p[0] & 0x80) != 0) + return -1; + + // nal_unit_type + unit_type_plus1 = (p[0] >> 1) & 0x3F; + } + + return unit_type_plus1 - 1; +} + +static uint32_t read_nal_unit_length(const uint8_t *bits, int bits_size) +{ + uint32_t nalu_len = 0; + + if (bits_size >= EVC_NAL_UNIT_LENGTH_BYTE) { + + int t = 0; + for (int i = 0; i < EVC_NAL_UNIT_LENGTH_BYTE; i++) + t = (t << 8) | bits[i]; + + nalu_len = t; + if (nalu_len == 0) + return 0; + } + + return nalu_len; +} + +// @see ISO_IEC_23094-1 (7.3.2.1 SPS RBSP syntax) +static int evcc_parse_sps(const uint8_t *bs, int bs_size, EVCDecoderConfigurationRecord *evcc) +{ + GetBitContext gb; + int sps_seq_parameter_set_id; + EVCSPS sps; + + if (init_get_bits8(&gb, bs, bs_size) < 0) + return 0; + + sps.sps_seq_parameter_set_id = get_ue_golomb(&gb); + + if (sps_seq_parameter_set_id >= EVC_MAX_SPS_COUNT) + return 0; + + // the Baseline profile is indicated by profile_idc eqal to 0 + // the Main profile is indicated by profile_idc eqal to 1 + sps.profile_idc = get_bits(&gb, 8); + + sps.level_idc = get_bits(&gb, 8); + + sps.toolset_idc_h = get_bits(&gb, 32); + sps.toolset_idc_l = get_bits(&gb, 32); + + // 0 - monochrome + // 1 - 4:2:0 + // 2 - 4:2:2 + // 3 - 4:4:4 + sps.chroma_format_idc = get_ue_golomb(&gb); + + sps.pic_width_in_luma_samples = get_ue_golomb(&gb); + sps.pic_height_in_luma_samples = get_ue_golomb(&gb); + + sps.bit_depth_luma_minus8 = get_ue_golomb(&gb); + sps.bit_depth_chroma_minus8 = get_ue_golomb(&gb); + + evcc->profile_idc = sps.profile_idc; + evcc->level_idc = sps.level_idc; + evcc->toolset_idc_h = sps.toolset_idc_h; + evcc->toolset_idc_l = sps.toolset_idc_l; + evcc->chroma_format_idc = sps.chroma_format_idc; + evcc->bit_depth_luma_minus8 = sps.bit_depth_luma_minus8; + evcc->bit_depth_chroma_minus8 = sps.bit_depth_chroma_minus8; + evcc->pic_width_in_luma_samples = sps.pic_width_in_luma_samples; + evcc->pic_height_in_luma_samples = sps.pic_height_in_luma_samples; + + return 0; +} + +// @see ISO/IEC 14496-15:2021 Coding of audio-visual objects - Part 15: section 12.3.3.3 +static int evcc_array_add_nal_unit(const uint8_t *nal_buf, uint32_t nal_size, + uint8_t nal_type, int ps_array_completeness, + EVCNALUnitArray *array) +{ + int ret; + uint16_t numNalus = array->numNalus; + + ret = av_reallocp_array(&array->nalUnit, numNalus + 1, sizeof(uint8_t *)); + if (ret < 0) + return ret; + + ret = av_reallocp_array(&array->nalUnitLength, numNalus + 1, sizeof(uint16_t)); + if (ret < 0) + return ret; + + array->nalUnit [numNalus] = (uint8_t*)nal_buf; + array->nalUnitLength[numNalus] = nal_size; + array->NAL_unit_type = nal_type; + array->numNalus++; + + /* + * When the sample entry name is 'evc1', the default and mandatory value of + * array_completeness is 1 for arrays of all types of parameter sets, and 0 + * for all other arrays. + */ + if (nal_type == EVC_SPS_NUT || nal_type == EVC_PPS_NUT || nal_type == EVC_APS_NUT) + array->array_completeness = ps_array_completeness; + + return 0; +} + +static void evcc_init(EVCDecoderConfigurationRecord *evcc) +{ + memset(evcc, 0, sizeof(EVCDecoderConfigurationRecord)); + evcc->configurationVersion = 1; + evcc->lengthSizeMinusOne = 3; // 4 bytes +} + +static void evcc_close(EVCDecoderConfigurationRecord *evcc) +{ + for (unsigned i = 0; i < FF_ARRAY_ELEMS(evcc->arrays); i++) { + EVCNALUnitArray *const array = &evcc->arrays[i]; + array->numNalus = 0; + av_freep(&array->nalUnit); + av_freep(&array->nalUnitLength); + } +} + +static int evcc_write(AVIOContext *pb, EVCDecoderConfigurationRecord *evcc) +{ + uint16_t sps_count; + + av_log(NULL, AV_LOG_TRACE, "configurationVersion: %"PRIu8"\n", + evcc->configurationVersion); + av_log(NULL, AV_LOG_TRACE, "profile_idc: %"PRIu8"\n", + evcc->profile_idc); + av_log(NULL, AV_LOG_TRACE, "level_idc: %"PRIu8"\n", + evcc->level_idc); + av_log(NULL, AV_LOG_TRACE, "toolset_idc_h: %"PRIu32"\n", + evcc->toolset_idc_h); + av_log(NULL, AV_LOG_TRACE, "toolset_idc_l: %"PRIu32"\n", + evcc->toolset_idc_l); + av_log(NULL, AV_LOG_TRACE, "chroma_format_idc: %"PRIu8"\n", + evcc->chroma_format_idc); + av_log(NULL, AV_LOG_TRACE, "bit_depth_luma_minus8: %"PRIu8"\n", + evcc->bit_depth_luma_minus8); + av_log(NULL, AV_LOG_TRACE, "bit_depth_chroma_minus8: %"PRIu8"\n", + evcc->bit_depth_chroma_minus8); + av_log(NULL, AV_LOG_TRACE, "pic_width_in_luma_samples: %"PRIu16"\n", + evcc->pic_width_in_luma_samples); + av_log(NULL, AV_LOG_TRACE, "pic_height_in_luma_samples: %"PRIu16"\n", + evcc->pic_height_in_luma_samples); + av_log(NULL, AV_LOG_TRACE, "lengthSizeMinusOne: %"PRIu8"\n", + evcc->lengthSizeMinusOne); + av_log(NULL, AV_LOG_TRACE, "num_of_arrays: %"PRIu8"\n", + evcc->num_of_arrays); + for (unsigned i = 0; i < FF_ARRAY_ELEMS(evcc->arrays); i++) { + const EVCNALUnitArray *const array = &evcc->arrays[i]; + + if(array->numNalus == 0) + continue; + + av_log(NULL, AV_LOG_TRACE, "array_completeness[%"PRIu8"]: %"PRIu8"\n", + i, array->array_completeness); + av_log(NULL, AV_LOG_TRACE, "NAL_unit_type[%"PRIu8"]: %"PRIu8"\n", + i, array->NAL_unit_type); + av_log(NULL, AV_LOG_TRACE, "numNalus[%"PRIu8"]: %"PRIu16"\n", + i, array->numNalus); + for ( unsigned j = 0; j < array->numNalus; j++) + av_log(NULL, AV_LOG_TRACE, + "nalUnitLength[%"PRIu8"][%"PRIu16"]: %"PRIu16"\n", + i, j, array->nalUnitLength[j]); + } + + /* + * We need at least one SPS. + */ + sps_count = evcc->arrays[SPS_INDEX].numNalus; + if (!sps_count || sps_count > EVC_MAX_SPS_COUNT) + return AVERROR_INVALIDDATA; + + if (!sps_count || sps_count > EVC_MAX_SPS_COUNT) + return AVERROR_INVALIDDATA; + + /* unsigned int(8) configurationVersion = 1; */ + avio_w8(pb, evcc->configurationVersion); + + /* unsigned int(8) profile_idc */ + avio_w8(pb, evcc->profile_idc); + + /* unsigned int(8) profile_idc */ + avio_w8(pb, evcc->level_idc); + + /* unsigned int(32) toolset_idc_h */ + avio_wb32(pb, evcc->toolset_idc_h); + + /* unsigned int(32) toolset_idc_l */ + avio_wb32(pb, evcc->toolset_idc_l); + + /* + * unsigned int(2) chroma_format_idc; + * unsigned int(3) bit_depth_luma_minus8; + * unsigned int(3) bit_depth_chroma_minus8; + */ + avio_w8(pb, evcc->chroma_format_idc << 6 | + evcc->bit_depth_luma_minus8 << 3 | + evcc->bit_depth_chroma_minus8); + + /* unsigned int(16) pic_width_in_luma_samples; */ + avio_wb16(pb, evcc->pic_width_in_luma_samples); + + /* unsigned int(16) pic_width_in_luma_samples; */ + avio_wb16(pb, evcc->pic_height_in_luma_samples); + + /* + * bit(6) reserved = '111111'b; + * unsigned int(2) chromaFormat; + */ + avio_w8(pb, evcc->lengthSizeMinusOne | 0xfc); + + /* unsigned int(8) numOfArrays; */ + avio_w8(pb, evcc->num_of_arrays); + + for (unsigned i = 0; i < FF_ARRAY_ELEMS(evcc->arrays); i++) { + const EVCNALUnitArray *const array = &evcc->arrays[i]; + + if (!array->numNalus) + continue; + + /* + * bit(1) array_completeness; + * unsigned int(1) reserved = 0; + * unsigned int(6) NAL_unit_type; + */ + avio_w8(pb, array->array_completeness << 7 | + array->NAL_unit_type & 0x3f); + + /* unsigned int(16) numNalus; */ + avio_wb16(pb, array->numNalus); + + for (unsigned j = 0; j < array->numNalus; j++) { + /* unsigned int(16) nalUnitLength; */ + avio_wb16(pb, array->nalUnitLength[j]); + + /* bit(8*nalUnitLength) nalUnit; */ + avio_write(pb, array->nalUnit[j], + array->nalUnitLength[j]); + } + } + + return 0; +} + +int ff_isom_write_evcc(AVIOContext *pb, const uint8_t *data, + int size, int ps_array_completeness) +{ + EVCDecoderConfigurationRecord evcc; + int nalu_type; + size_t nalu_size; + int bytes_to_read = size; + unsigned array_index; + + int ret = 0; + + if (size < 8) { + /* We can't write a valid evcC from the provided data */ + return AVERROR_INVALIDDATA; + } else if (*data == 1) { + /* Data is already evcC-formatted */ + avio_write(pb, data, size); + return 0; + } + + evcc_init(&evcc); + + while (bytes_to_read > EVC_NAL_UNIT_LENGTH_BYTE) { + nalu_size = read_nal_unit_length(data, EVC_NAL_UNIT_LENGTH_BYTE); + if (nalu_size == 0) break; + + data += EVC_NAL_UNIT_LENGTH_BYTE; + bytes_to_read -= EVC_NAL_UNIT_LENGTH_BYTE; + + if (bytes_to_read < nalu_size) break; + + nalu_type = get_nalu_type(data, bytes_to_read); + + switch (nalu_type) { + case EVC_SPS_NUT: + array_index = SPS_INDEX; + break; + case EVC_PPS_NUT: + array_index = PPS_INDEX; + break; + case EVC_APS_NUT: + array_index = APS_INDEX; + break; + case EVC_SEI_NUT: + array_index = SEI_INDEX; + break; + default: + break; + } + + ret = evcc_array_add_nal_unit(data, nalu_size, nalu_type, ps_array_completeness, &(evcc.arrays[array_index])); + if (ret < 0) + goto end; + if (evcc.arrays[array_index].numNalus == 1) + evcc.num_of_arrays++; + + if(nalu_type == EVC_SPS_NUT) { + ret = evcc_parse_sps(data, nalu_size, &evcc); + if (ret < 0) + goto end; + } + + data += nalu_size; + bytes_to_read -= nalu_size; + } + + ret = evcc_write(pb, &evcc); + +end: + evcc_close(&evcc); + return ret; +} diff --git a/libavformat/evc.h b/libavformat/evc.h new file mode 100644 index 0000000000..db56275fd8 --- /dev/null +++ b/libavformat/evc.h @@ -0,0 +1,44 @@ +/* + * EVC helper functions for muxers + * Copyright (c) 2022 Dawid Kozinski + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFORMAT_EVC_H +#define AVFORMAT_EVC_H + +#include +#include "libavutil/rational.h" +#include "avio.h" + + + +/** + * Writes EVC sample metadata to the provided AVIOContext. + * + * @param pb pointer to the AVIOContext where the evc sample metadata shall be written + * @param buf input data buffer + * @param size size in bytes of the input data buffer + * @param ps_array_completeness @see ISO/IEC 14496-15:2021 Coding of audio-visual objects - Part 15: section 12.3.3.3 + * + * @return 0 in case of success, a negative error code in case of failure + */ +int ff_isom_write_evcc(AVIOContext *pb, const uint8_t *data, + int size, int ps_array_completeness); + +#endif // AVFORMAT_EVC_H diff --git a/libavformat/isom_tags.c b/libavformat/isom_tags.c index 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 Tue Sep 6 11:47:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawid Kozinski X-Patchwork-Id: 37708 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp3204896pzh; Tue, 6 Sep 2022 04:48:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR6HQryCjg7mHMtAApUUeyYLdf7QvAdtczxkyvUjDMwTaMoC91amPLOEdBPBVgPhbkI/G+bx X-Received: by 2002:a17:906:8a4b:b0:770:26a9:a98 with SMTP id gx11-20020a1709068a4b00b0077026a90a98mr22803ejc.184.1662464879865; Tue, 06 Sep 2022 04:47:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662464879; cv=none; d=google.com; s=arc-20160816; b=S3HSJLfxGEv8DsqO1xRHulMebPP0He0wMNrR2eAYJvc5YLGezEfiNjgs+0F622KjJv 7s2qCppuGbB0Zm4QlX/S7PLGIB0agT8Jd8IJkFkixvXsT7/aJAYeGOQYUPSCj/yK7mc+ vHPawZ8hjnNvKl46LykmbltdfbQPGSNO3SB0YNhEzqi0PS7vzzxP//AaQKvf9XNcm5QZ h3NSBf6wYIjl4fLzw0vWqJU4LiK/p9aPvFwBxp1QY3qVfM/J6/RaTfXuqdqQxwAQ3U1W fZP2vJktnWNz95xd+pCxm5uUXczZmS5yiIlABgdip469fAP0rfSOuSoBGX0nlRTIwxEG Vofw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:cms-type:mime-version :message-id:date:to:from:dkim-signature:dkim-filter:delivered-to; bh=LugvVuzgzbXQbP5XJ5ZD6cWe15aQez1NPnEZdwCat9g=; b=Pkx1YXRCWPxhEz65qk6K4fX5rCNYfny9uGTccopW7iJQ4fjgAxyA7Y1zAsBoouglfz JXSBjkqzd97BChvKghSYFGYLzyDdnURrpPgnS3DyaXn/bArEMOAVwsebWPbiondXr+TA W3o6dLcbd+gTK8xE5pzbtmvJPSh2YM89I4mkUpvDHxH6l8jSiIP6ArTL8GCgbpo4jDDN xVpP6ifI42Geyu6xp6wjY9jO9sX3q8/Rr8Dle9YHM4xnEC1boaMR5eLibH61nksP3H86 oSAFKIhABH3nfZWtXJLw8OLvfTHCg4XgH/+30wKk8wseb+1RrrCX2dxCAUgD+1TZrIY2 mVOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=I6xYKsZ8; 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 qf36-20020a1709077f2400b007414081b2ebsi10271352ejc.148.2022.09.06.04.47.59; Tue, 06 Sep 2022 04:47:59 -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=I6xYKsZ8; 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 D7CCF68BB34; Tue, 6 Sep 2022 14:47:56 +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 BB8CE68BB30 for ; Tue, 6 Sep 2022 14:47:49 +0300 (EEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220906114739euoutp02ca8a69bab3db95045731ff36645c2a30~SQvs-x2O70989609896euoutp02F for ; Tue, 6 Sep 2022 11:47:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220906114739euoutp02ca8a69bab3db95045731ff36645c2a30~SQvs-x2O70989609896euoutp02F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662464859; bh=6rpIhgwvCJMvSsrA0w+n4+YcT+cPGrctkCHUlurww3c=; h=From:To:Cc:Subject:Date:References:From; b=I6xYKsZ8LiP4svsG45U/kdngAG0T3CCggp8Xtur1YkGqJNXqewiOIzr6e+PUi167/ F/p/FQ68zNDhtfugthM+ufynOu/H8kMNHg2i21ZX91IDglhnF9MdIZWnZzSUBX4djc izQ6CbnZG1E9rW3hgKma8Fmy8wFJbA7YNOJI7nqQ= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220906114734eucas1p12a2410171e6079f7132ec878b89c0449~SQvoE59MZ1313613136eucas1p1N; Tue, 6 Sep 2022 11:47:34 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id F4.14.07817.55337136; Tue, 6 Sep 2022 12:47:33 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220906114733eucas1p1729170ff6e7c90f447653fef737134b0~SQvnbLOd02584525845eucas1p1G; Tue, 6 Sep 2022 11:47:33 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220906114733eusmtrp2e7da6e014db92c35f658306ac64fd194~SQvnalrjH0394903949eusmtrp2G; Tue, 6 Sep 2022 11:47:33 +0000 (GMT) X-AuditID: cbfec7f4-8abff70000011e89-26-6317335568ed Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 4B.EC.10862.55337136; Tue, 6 Sep 2022 12:47:33 +0100 (BST) Received: from AMDN3260.EU.corp.samsungelectronics.net (unknown [106.210.132.171]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220906114732eusmtip28dd62fc244265f007bf9b6ad20aa324a~SQvnDyPcU1875218752eusmtip2C; Tue, 6 Sep 2022 11:47:32 +0000 (GMT) From: Dawid Kozinski To: d.frankiewic@samsung.com, ffmpeg-devel@ffmpeg.org Date: Tue, 6 Sep 2022 13:47:26 +0200 Message-Id: <20220906114726.282-1-d.kozinski@samsung.com> X-Mailer: git-send-email 2.24.0.windows.2 MIME-Version: 1.0 X-Unsent: 1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDIsWRmVeSWpSXmKPExsWy7djP87qhxuLJBqsPWFh8ufaF2WLlt98s Ft8+nWF2YPb4s2gzi0ffllWMAUxRXDYpqTmZZalF+nYJXBltt56xFUzjq9h04x57A+Mrri5G Tg4JAROJRdOPsXUxcnEICaxglGg+ep4ZwvnCKHH59U0WCOczo8Ssm+0sMC1350yGSixnlHg4 dT07hNPOJHF74ismkCo2AV2Jlx8egdkiAqYSJ5v3soHYzALaEuvufgezhQUSJT5dOwM2lUVA VeL37jtgNq+ApcTGj39ZIbZpSsye0M4MEReUODnzCdQV3BLrZl1ihZgpL9G8dTbY3RICH9kl 9k1dywRR5CKx5vMqRghbWOLV8S3sELaMxP+d84FqOIDsYolD/Q4QZo3EoR/pEBXWEm8bjzOC hJmBTli/Sx8i7Cix7XgjVCOfxI23ghAH8ElM2jadGSLMK9HRJgRhqkj0dYpBNEpJPF02hxnC 9pD4eOEi+wRGxVlIvpqF5JNZCGsXMDKvYhRPLS3OTU8tNspLLdcrTswtLs1L10vOz93ECEwQ p/8d/7KDcfmrj3qHGJk4GA8xSnAwK4nwpuwQSRbiTUmsrEotyo8vKs1JLT7EKM3BoiTOm5y5 IVFIID2xJDU7NbUgtQgmy8TBKdXAtGnmkfCT7ccPLzrdFxvsMPf/0xT27vmvYt7/enJce9s0 /8AWR6GjCyV4W2epi3ou6C/2uJ/R7JRSU2gtcv7YVIt05t74zuozYjyLDFbIVK6R982yunWt /BeH13pey0/tk6ze1r7qibS+HeY+NXejeUvmbNe8PRZL3YOXsLtfE8x7LnDUJa4uuUBmk0Wk 6FlpvhNffz9mSD6TcO/HoWU1/+f+S0iWnRciq7fE/e6yG5FbxCdxt5ZULeWadXfF7uevpOak f7oR93vig34/vZ3hQr5ZX7i4ZX791Lx3bYL36pO5R84tCv/i9CeheP5Kwxu+Syw2T/vl8v/H Ks0950VXRAX2vZW6Ien22VHjbR4jhxJLcUaioRZzUXEiAAptkwt/AwAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrALMWRmVeSWpSXmKPExsVy+t/xe7qhxuLJBqfnCFp8ufaF2WLlt98s Ft8+nWF2YPb4s2gzi0ffllWMAUxRejZF+aUlqQoZ+cUltkrRhhZGeoaWFnpGJpZ6hsbmsVZG pkr6djYpqTmZZalF+nYJehltt56xFUzjq9h04x57A+Mrri5GTg4JAROJu3Mms4DYQgJLGSV6 XqlDxKUkli5dxAhhC0v8udbFBlHTyiTx73gCiM0moCvx8sMjJhBbRMBc4uK6W2D1zALaEuvu fgerFxaIl9jUPQ3MZhFQlfi9+w7YLl4BS4mNH/+yQszXlJg9oZ0ZIi4ocXLmExaIOLfEulmX WCFmyks0b53NPIGRfxaSsllIUgsYmVYxiqSWFuem5xYb6RUn5haX5qXrJefnbmIEBu22Yz+3 7GBc+eqj3iFGJg7GQ4wSHMxKIrwpO0SShXhTEiurUovy44tKc1KLDzGaAt06kVlKNDkfGDd5 JfGGZgamhiZmlgamlmbGSuK8ngUdiUIC6YklqdmpqQWpRTB9TBycUg1MvcsO9V27opE8xbp0 y+qJ/8WZ/zoJ/nO2XZFY+zgluPWt6O4XKkG8tkv3zMpcP6fl5Pb9i/l5thmH8Bu/nu3NmvBu n5LWidA/ovO+Pj60R9ZEawVPiOaqbWpKDHdUmtt5t5qvzBSeKfQsb7V3l0dBw9f1X/+ft9bd +1eHq0B7Xfi2ej+3xWW1FnNCCiMvdL9j8dWqajuZ+iPJpKFjt3rD2mtvFd3ZX+dt3jQ9yumD 6+tj98O6TFJ/NUgk1KU5cc7jOhu0K/nFtgUBcZJLy5gW8VhPb2q2W/Oy04D54N/w3Ycr6soF jcWdtXZPjdcRKn37fE4wJ+OWlL0HXq5NEOS/dfB7l73bL5+YnK2ZBYVKLMUZiYZazEXFiQCK W0kV4wIAAA== X-CMS-MailID: 20220906114733eucas1p1729170ff6e7c90f447653fef737134b0 X-Msg-Generator: CA X-RootMTR: 20220906114733eucas1p1729170ff6e7c90f447653fef737134b0 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220906114733eucas1p1729170ff6e7c90f447653fef737134b0 References: Subject: [FFmpeg-devel] [PATCH v12 8/9] avformat/mov_demuxer: Extended MOV demuxer to handle EVC video content X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Dawid Kozinski Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 0FwtDjt5hOdG - Added evc extension to the list of extensions for ff_mov_demuxer Signed-off-by: Dawid Kozinski --- libavformat/demux.c | 1 + libavformat/mov.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/demux.c b/libavformat/demux.c index 1620716716..05d5f343ae 100644 --- a/libavformat/demux.c +++ b/libavformat/demux.c @@ -119,6 +119,7 @@ static int set_codec_from_probe_data(AVFormatContext *s, AVStream *st, { "mp3", AV_CODEC_ID_MP3, AVMEDIA_TYPE_AUDIO }, { "mpegvideo", AV_CODEC_ID_MPEG2VIDEO, AVMEDIA_TYPE_VIDEO }, { "truehd", AV_CODEC_ID_TRUEHD, AVMEDIA_TYPE_AUDIO }, + { "evc", AV_CODEC_ID_EVC, AVMEDIA_TYPE_VIDEO }, { 0 } }; int score; diff --git a/libavformat/mov.c b/libavformat/mov.c index a1bc627991..33ce3b9b07 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2506,6 +2506,7 @@ static int mov_finalize_stsd_codec(MOVContext *c, AVIOContext *pb, case AV_CODEC_ID_VP9: sti->need_parsing = AVSTREAM_PARSE_FULL; break; + case AV_CODEC_ID_EVC: case AV_CODEC_ID_AV1: /* field_order detection of H264 requires parsing */ case AV_CODEC_ID_H264: @@ -9133,7 +9134,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 Tue Sep 6 11:48:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dawid Kozinski X-Patchwork-Id: 37709 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp3205324pzh; Tue, 6 Sep 2022 04:48:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR5OgwcYasIM99Dr4aYZSvIDIF5E54yKe2M7bsCwBcT4ZQxhTKIKOpeFW00E0trHypW7HZfo X-Received: by 2002:a17:907:1dc8:b0:741:61eb:9fba with SMTP id og8-20020a1709071dc800b0074161eb9fbamr32087018ejc.665.1662464935212; Tue, 06 Sep 2022 04:48:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662464935; cv=none; d=google.com; s=arc-20160816; b=i2Ss407tzXpbJbG2jAqBEGI9hkZeKgPlxgC7+BeTqY6zzFtpSR77vA3erPLjnSnM5z qQvJV3OsqY+1ni/QonFsGdb97bDkRxT3B/WYqf+9j14rII1JNxwLtOombmrl4UGUGh+L rPj10QRDZ3Vqj3UdQTUwOKEynhxxeLGPblwn9iFcEqpJoXf3ATdhWI7DjK40DdFLaf7r RutjUGkqzSVnno5jvkw/aAcELdH9KiR59PibTMYfaGhxFCfb+pv7UYS7BrpnN9ojhRsg jjOnLo3CPG13/DRbp6EvYrPyBjopCdkTGr7qCIYB3+MjvA/J5tRkz6T44wiuUzqUOqoy RB7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:cms-type:mime-version :message-id:date:to:from:dkim-signature:dkim-filter:delivered-to; bh=5pkNnbtOy+5h3VZRflfHo/cF2VN2jLdPXQU35MTbSdA=; b=veQ4mGsUYXTxlHO7wEFkTkXSE7XtTWZVltm/WsuO7AjLSQ0fsG0jvtS89d3RW7keME 8hNcqGrLlshjYiE57YP4PqkknS3oemYYOfwCkGC+Ni/pNIKGZ8yahOREVM4WoO/C0ykP Y7g00NAiT1B15VlrmlJvgKE8GvIl99sfUHnalxo/gfVwUTh8UXlhiPTENE5iGDLmo2DM Xa2SExcs3/r1HSq9Ivb1jGwBSVPDpiJ4FjFgv9rB2KUEGBnHEnY+CsKx322SCDcaqOSg ooUI2PPK4D6SXftdzEr6Wh/a/1CQfXg/Px+U7o5+POUt4wOqrFWYT/aFAG6VoVkWl7ZL wSqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=ZPN+N76M; 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 t27-20020a170906179b00b0072b4b8a0ce7si8088517eje.946.2022.09.06.04.48.54; Tue, 06 Sep 2022 04:48:55 -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=ZPN+N76M; 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 EAF8968BB23; Tue, 6 Sep 2022 14:48:52 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C26D068BB2B for ; Tue, 6 Sep 2022 14:48:50 +0300 (EEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220906114840euoutp02a6a4d36f6ced6a1920079ab1c7e2075d~SQwlxOtjZ1315113151euoutp02L for ; Tue, 6 Sep 2022 11:48:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220906114840euoutp02a6a4d36f6ced6a1920079ab1c7e2075d~SQwlxOtjZ1315113151euoutp02L DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662464920; bh=VECuKZmUuhcuG6C3fMXJxFlvDAXm/c18HJVIVtoFehs=; h=From:To:Cc:Subject:Date:References:From; b=ZPN+N76M0mWXXA/9dRKawisy+rK4+TC3XdlsNUh4SNGywbQaSd/+ilqxOg4p5pNMd zsKuaUfgBNtK+N32vPh+k8UiV//BddBmqKSOlGirxGn9I5YShhgAHyvqx/bi7xxfe0 kVACN0mYRqvo5AbC8k9irpVR3pOkAxR8J35P7pQ8= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220906114840eucas1p1d8b30698fc99ee486849ff68b68e2645~SQwliRZog2612526125eucas1p15; Tue, 6 Sep 2022 11:48:40 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 73.44.07817.79337136; Tue, 6 Sep 2022 12:48:39 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220906114839eucas1p17fd2546092eea2e7b5edfd4ccd4693e7~SQwlACpK-2606426064eucas1p14; Tue, 6 Sep 2022 11:48:39 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220906114839eusmtrp236dfd9e181acf8b5730770ea4130e07a~SQwk-ZscQ0503205032eusmtrp2D; Tue, 6 Sep 2022 11:48:39 +0000 (GMT) X-AuditID: cbfec7f4-8abff70000011e89-fc-63173397e820 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 3A.7A.07473.79337136; Tue, 6 Sep 2022 12:48:39 +0100 (BST) Received: from AMDN3260.EU.corp.samsungelectronics.net (unknown [106.210.132.171]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220906114839eusmtip218666699ba2e115b976c2f94de552fde~SQwknQcpf1874018740eusmtip2N; Tue, 6 Sep 2022 11:48:38 +0000 (GMT) From: Dawid Kozinski To: d.frankiewic@samsung.com, ffmpeg-devel@ffmpeg.org Date: Tue, 6 Sep 2022 13:48:30 +0200 Message-Id: <20220906114830.226-1-d.kozinski@samsung.com> X-Mailer: git-send-email 2.24.0.windows.2 MIME-Version: 1.0 X-Unsent: 1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDIsWRmVeSWpSXmKPExsWy7djP87rTjcWTDVbusbL4cu0Ls8XKb79Z LL59OsPswOzxZ9FmFo++LasYA5iiuGxSUnMyy1KL9O0SuDJeHz/OUnCBr2Lh8cVMDYzXOboY OTkkBEwk/q1dydrFyMUhJLCCUeLirePsEM4XRonLk5cxQTifGSWm7PnIBNPS3fqaESKxnFHi 9Lo1bBBOO5PE13mrWEGq2AR0JV5+eATWISJgKnGyeS8biM0soC2x7u53MFtYIEhi1qFNYPUs AqoSExuPgdm8ApYSK29NZIbYpikxe0I7M0RcUOLkzCcsEHFuiXWzLrFCzJSXaN46mxnkCAmB n+wS0/reQhW5SFy78gjqbGGJV8e3sEPYMhL/d84HinMA2cUSh/odIMwaiUM/0iEqrCXeNh5n BAkzA52wfpc+RNhRYvLS36wQ1XwSN94KQhzAJzFp23RmiDCvREebEISpItHXKQbRKCXxdNkc qJc8JKYcncw+gVFxFpKvZiH5ZBbC2gWMzKsYxVNLi3PTU4uN8lLL9YoTc4tL89L1kvNzNzEC E8Tpf8e/7GBc/uqj3iFGJg7GQ4wSHMxKIrwpO0SShXhTEiurUovy44tKc1KLDzFKc7AoifMm Z25IFBJITyxJzU5NLUgtgskycXBKNTDFRZ9R6V9yXeeT5525imfCvXSiNsh1ufGdVXP7evf7 Tifxr59cTipUavUvbd0nvbs/n+Hr/0cdHU/bP+Y8Fjyw/wPP24rqTz5e+9atj9py+k2FnHDT c+UdPyuXLG5r4jT8uNnZYvXCxM51Mj7/N+ksWb5UlKso0vH8yvDuTS+5HBe3GIZO+bp7684s hRcl75aIBL8W9rJ4yK94U9bJeo3XsdZpJ0/IRzKqdh3L+bVBaIb9vPVbZcyu98qb7i9bPlE+ aPdfKb5PpS7nc94oONgXum8OnhV1YtUrj2tRTRWPL6ddct3968/iVbkmv1MnrLszo+/jo51r Vs9z+L2+/M7FSXW7ml5znfvafl5y8rHQdCWW4oxEQy3mouJEAIOKPDJ/AwAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrELMWRmVeSWpSXmKPExsVy+t/xe7rTjcWTDT53ilt8ufaF2WLlt98s Ft8+nWF2YPb4s2gzi0ffllWMAUxRejZF+aUlqQoZ+cUltkrRhhZGeoaWFnpGJpZ6hsbmsVZG pkr6djYpqTmZZalF+nYJehmvjx9nKbjAV7Hw+GKmBsbrHF2MnBwSAiYS3a2vGbsYuTiEBJYy Siy6fZgZIiElsXTpIkYIW1jiz7UuNoiiViaJ/7t6wRJsAroSLz88YgKxRQTMJS6uuwUWZxbQ llh39zsbiC0sECDxq+snO4jNIqAqMbHxGCuIzStgKbHy1kSoZZoSsye0M0PEBSVOznzCAhHn llg36xIrxEx5ieats5knMPLPQlI2C0lqASPTKkaR1NLi3PTcYkO94sTc4tK8dL3k/NxNjMDA 3Xbs5+YdjPNefdQ7xMjEwXiIUYKDWUmEN2WHSLIQb0piZVVqUX58UWlOavEhRlOgWycyS4km 5wNjJ68k3tDMwNTQxMzSwNTSzFhJnNezoCNRSCA9sSQ1OzW1ILUIpo+Jg1Oqgan8LpfdZOPY tSp+cx5GG9l7zBGLiUkzM/b/GP1r2/yg1xOqHBtKk2bandXyVT1zMUFU9ciFe5ntDw48iD51 yeLMBbG+Ht3mPXxv/U+FGaWeljJbq2dd5Fj8e6XVgj86H2WSLk4z3HVqXad4bfzWkK2/P9qY m/3ddMdV0b3QSmrC9AlGJ9ZcCrd4vHDWNN835gYfTugvPr7w0ptMt4mnbiXPK/ixcsfn+Lue zVMZtnTq8e71sLrZysYYWDGxyOxWIsORpPkndvtpvU/K28ErbSDkuC3hNNtWJ9ETv2OEz22M qGnTyK1RWDkrPGCjm/e+dfuC9xqafr0v7z1rhdVF5rg51QuW6nZEstw9JfFTeZMSS3FGoqEW c1FxIgD5Zadq5QIAAA== X-CMS-MailID: 20220906114839eucas1p17fd2546092eea2e7b5edfd4ccd4693e7 X-Msg-Generator: CA X-RootMTR: 20220906114839eucas1p17fd2546092eea2e7b5edfd4ccd4693e7 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220906114839eucas1p17fd2546092eea2e7b5edfd4ccd4693e7 References: Subject: [FFmpeg-devel] [PATCH v12 9/9] avcodec/evc: Changes in Changelog and MAINTAINERS files X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Dawid Kozinski Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: rg+eObvkqMv7 - Changelog update - MAINTAINERS update Signed-off-by: Dawid Kozinski --- Changelog | 3 ++- MAINTAINERS | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index f34e8e5d42..f60d014f2f 100644 --- a/Changelog +++ b/Changelog @@ -38,6 +38,8 @@ version 5.1: - remap_opencl filter - added chromakey_cuda filter - added bilateral_cuda filter +- eXtra-fast Essential Video Encoder (XEVE) +- eXtra-fast Essential Video Decoder (XEVD) version 5.0: @@ -85,7 +87,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