From patchwork Thu Sep 12 00:59:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 51528 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:14c:b0:48e:c0f8:d0de with SMTP id h12csp633918vqi; Wed, 11 Sep 2024 17:59:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVbbFTtgC6fl+msEQjEBzh69iPyeuBnuXJUqXOI3YNnp0x9c4YTB8kgj58NOYQJ0RjbYWNp4aPzKAEK8s+hU8JY@gmail.com X-Google-Smtp-Source: AGHT+IGnGvDoj2729yBJT6BdARpD6HBZafxsGxxWbzq9Swu5u+PtA83LbK495lnr4zvIix4QF0I9 X-Received: by 2002:a17:907:a585:b0:a90:349b:9ef with SMTP id a640c23a62f3a-a90349b3147mr3650766b.18.1726102787197; Wed, 11 Sep 2024 17:59:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726102787; cv=none; d=google.com; s=arc-20240605; b=Yj33vavOf0gBE+1xP5LkHTTpUIc2nbyOgHMWNvARjk0cxtkCj6N78wDLlIARzfnThL 0vZ71gw4dJmMSi8FLQyaH7HIiRNc3T3F3wfQ8KcZTLDw/bZNzy+2GKzWXzgmYhkF8G64 mFI33vjR2jyMKchc4kFOod1pqf2XX9khfyujI2033lKpGknJwZrQqCiQm3c7pOqmCV58 zbcohr0mW5dGLyV6YMwhKde8kp9YZC5l2fi25Wb4aazmObxSVqx+eBmRFLDiCbvrffOj 5vCiBPlBIDCTwvgwIAzlsV05WjupvcC/Cm/ucYSg9/+JOFzU5bX3MiiX+/buebyPY0JJ 37SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=jAKtUXwrp574NYh6ARUpMzkFJXMRGZNWjnHY/IwaTLI=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=dbz72CATrYTmLCDmKpXlPrFAbcNZ3jyDyi6vh0ViJ25XtIW9vY9KBnQWMcCqy4f2uR XX93OLQtX07UcoDpsipOydFAEfpcXWb4TMce15z1FKHTafTegeuzrabagzDvj9b7uTZ8 KPymmTyzMXXvA3Hk2kL+aCWB/FvIci3oP3EyI6qAThAY0vhRFi4JNUz+QCXHEROnMKR8 NK8OAWIYt9KzjwhQ2t7He5yumb8gHNeWtoUHXHTXNh2AHqdkCPi6v8Mr5QSNhgtMyOWc j/ZBeTywiMxpJ2nfZCbuwK6Wc/FiQYx5aMNUlx0y4M5zV5OWaDjhLjsjvZik+EC3JGw7 rHhg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=PmXcpfMo; 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=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a8d259528b5si753299866b.232.2024.09.11.17.59.46; Wed, 11 Sep 2024 17:59:47 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=PmXcpfMo; 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=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7222D68CEDE; Thu, 12 Sep 2024 03:59:43 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9889D68CB66 for ; Thu, 12 Sep 2024 03:59:36 +0300 (EEST) Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-718e3c98b5aso252127b3a.0 for ; Wed, 11 Sep 2024 17:59:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726102774; x=1726707574; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=sdELFWRu6AM1hRIbV9aZI1psQDZ88SBWt44pCyq3pGA=; b=PmXcpfMoMMKcE8v5F//IFENQASv84VJuiUGcYng1j8N8X5Zl5WefResi3qZs41cgJE GnwUxwOSQYAU6FM20pKosrfo+2H1TrjM3e59XJa4P5Xf2JbyRhA+g8Bnnjz4dUuOajfL MXGlz80mseDjYbxg4s7x2Mzqidf5P8oc4wZwjd8OZ/tO0LiaUcsuP12z+jGsxAhKJzge j9cWiFmbUpDkN/jKg9j4axx+jxTJhZn8FQfvVkNxsgdpFLvUCb8tUusrEpuOf7MScSOG k3lssPyHgq364c+TAis8koVcn/mYbUnjm5cf/rIG2KXxGDcv6NrE3N9ERiC1MIufo/BT suug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726102774; x=1726707574; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sdELFWRu6AM1hRIbV9aZI1psQDZ88SBWt44pCyq3pGA=; b=p8nZ/swSqZuURtCto2ElKKPIlf2zk+UwM5/IEby0va7K8F2FXx5gCZjrOY/2mOpFPI Am8eDGBIQzJWXl00BaCPdXQmAfGcWD3NUU7esbwOa1rJaM67BV1NnGDgW78Igixe376U NArlJQQ8/nb4T1/UJ3+9DxEtrloehXbIaxARu1Gp1w16DGwSZbMKvRRVvFpJGk3OOz2h /kCG2f903KfAxEBXmBxt1gkeZHUgqV7XuyDYOcXVYi8UTg3PEADjhOcmXkgtuTBAhK2S Hc1qo8PWtbIjRx1khwrej8dQxZM5HmvM+ke/+vn4G9QEidn0wOseAxfUnP1Obne2u6Yn JY0A== X-Gm-Message-State: AOJu0YyrTNak9wLB0qr1ceQGfXmCtW9sz233e5JOgFN5xeuR9hQ7b27n Dvo7erf6XQePrIGeMFwPmKgHeqI/xJOVYuYTIkvIxvIVNQDn/W5HPgu6GA== X-Received: by 2002:a05:6a00:2401:b0:718:dd53:70db with SMTP id d2e1a72fcca58-7192606c438mr1811094b3a.11.1726102773426; Wed, 11 Sep 2024 17:59:33 -0700 (PDT) Received: from localhost.localdomain ([181.92.233.116]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71908fc8210sm3557769b3a.36.2024.09.11.17.59.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 17:59:32 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 11 Sep 2024 21:59:15 -0300 Message-ID: <20240912005925.10151-1-jamrial@gmail.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/10 v4] avutil/frame: add an LCEVC enhancement data payload side data type X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: GsPZ2s97GOhL Signed-off-by: James Almer --- No changes since last version doc/APIchanges | 3 +++ libavutil/frame.c | 1 + libavutil/frame.h | 6 ++++++ libavutil/version.h | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 830a38cd69..5d7b5ab91c 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07 API changes, most recent first: +2024-09-08 - xxxxxxxxxx - lavu 59.37.100 - frame.h + Add AV_FRAME_DATA_LCEVC. + 2024-09-xx - xxxxxxxxxx - lavc 61.13.100 - avcodec.h Add avcodec_get_supported_config() and enum AVCodecConfig; deprecate AVCodec.pix_fmts, AVCodec.sample_fmts, AVCodec.supported_framerates, diff --git a/libavutil/frame.c b/libavutil/frame.c index 5cbfc6a48b..2758f90e27 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -46,6 +46,7 @@ static const AVSideDataDescriptor sd_props[] = { [AV_FRAME_DATA_DETECTION_BBOXES] = { "Bounding boxes for object detection and classification" }, [AV_FRAME_DATA_DOVI_RPU_BUFFER] = { "Dolby Vision RPU Data" }, [AV_FRAME_DATA_DOVI_METADATA] = { "Dolby Vision Metadata" }, + [AV_FRAME_DATA_LCEVC] = { "LCEVC NAL data" }, [AV_FRAME_DATA_STEREO3D] = { "Stereo 3D", AV_SIDE_DATA_PROP_GLOBAL }, [AV_FRAME_DATA_REPLAYGAIN] = { "AVReplayGain", AV_SIDE_DATA_PROP_GLOBAL }, [AV_FRAME_DATA_DISPLAYMATRIX] = { "3x3 displaymatrix", AV_SIDE_DATA_PROP_GLOBAL }, diff --git a/libavutil/frame.h b/libavutil/frame.h index 60bb966f8b..5e0d8ae648 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -228,6 +228,12 @@ enum AVFrameSideDataType { * encoding. */ AV_FRAME_DATA_VIDEO_HINT, + + /** + * Raw LCEVC payload data, as a uint8_t array, with NAL emulation + * bytes intact. + */ + AV_FRAME_DATA_LCEVC, }; enum AVActiveFormatDescription { diff --git a/libavutil/version.h b/libavutil/version.h index 25a6f5531b..7900379c12 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 59 -#define LIBAVUTIL_VERSION_MINOR 36 +#define LIBAVUTIL_VERSION_MINOR 37 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ From patchwork Thu Sep 12 00:59:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 51549 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:14c:b0:48e:c0f8:d0de with SMTP id h12csp921313vqi; Thu, 12 Sep 2024 06:24:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVfgeZoaSmqtJoW7DzLCQeSoRacjibvvILq7Q0IZTRc37P5/j8KuPLcbqVlGOjxLFLv6pLkYeUgdXQZc70oDNYv@gmail.com X-Google-Smtp-Source: AGHT+IE89MqgpnEGCdJuX7DUX8Wy5wlpafIOuAGyo/f4+whIz+Qc5vthjl0N8mPfMYEE1VyvpJYl X-Received: by 2002:a17:907:1c29:b0:a8a:926a:d000 with SMTP id a640c23a62f3a-a90294355e9mr135682566b.5.1726147451153; Thu, 12 Sep 2024 06:24:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726147451; cv=none; d=google.com; s=arc-20240605; b=EPSsWdsPCwhu+n8HlQd9WKzwKtQuyewOewAVLzuLjY/XJs8WpGch8O9Szf5SP2m+F4 e48l1DD8hgxS15OTXG8E0E+27HJoxzEQQ/O0vRZCj5YdBfwTS7QcJdmiI7dPgCl7U0ts 4OQve4DZbgL2+ITYb2roF6MmMXDxUbOYLlq3EQnn21zYgemmXuIxniAVV2Zu2qUFsqs1 C5CY9olSD2p8oSvmsYplFdZLgYscjGdQdvkZhXggc262CsiYvGWcogYvJq3EdknIshlg gTZRVn6PEjYhd4C5CpnPKBV8tPmfojwaYUPjaG0m5AHAyG5zp75S++OSQ/FZ86/C0TOx Wekg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=JxlbM003sLdW+0fS/op6HaV8M8ZmeoCLcR7EdOq3A64=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=LS68UzqpXCt8IbJaSKruK9sJAKkaL7FiW55qsE/BHxKd+Wds7Z81BT9ns0SHoC77re s/LyIrlysIcMb88VMSOtsuDr7tlf4kn69XAhCS/NO6lf3n2sI5pZeyKB3KF+Lt9IywB7 PbpS9viHhm3Y/98NxVEp/Atf6UNjvD4LoyN7Nl+LpsVZNsnV5XpdBN7fHhpVxcuL2r9A 3/bNw7lZ89dCT/pD92BTBPDiKx9eSaFC1ZeLHfsNeUoCh4e3SWcduFD6n3lyipxXGrv4 lRNPQQxr3QkbVkuJm7HlqSOkJ+GfokkXZXVbXMnL961naXsLi0pE+NjXq5RFGwGJKZDh 9VPA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=P5KVtbQ4; 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=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a8d25d547c4si905457966b.723.2024.09.12.06.24.09; Thu, 12 Sep 2024 06:24:11 -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=@gmail.com header.s=20230601 header.b=P5KVtbQ4; 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=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9CA4F68D3AE; Thu, 12 Sep 2024 03:59:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2962268D3AE for ; Thu, 12 Sep 2024 03:59:38 +0300 (EEST) Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-717911ef035so252505b3a.3 for ; Wed, 11 Sep 2024 17:59:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726102775; x=1726707575; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=6ZbGgFlVAo1BXbR5i+47qKdETSfM4rtNy9SkKSRZ+WU=; b=P5KVtbQ4V2Gg6DKrIxTEGz54J2qLwro6UdhOwE1Fm/uXOlxmTzMYbSWR6vyzx/YEF6 EQD2NUuTeMBHpOTBGPpw8BxuZYuukfn057nS768pE6uY+uvU/x0AAuWX7XT+LacAClo4 l/AoLyFMWfs9JQ2/5AgDFQkKwUadqg4WlSsxHRVxPpxgJINIgHhodYGDy1cSREBSjwkf g1dcm/NQX0VWcGFidEnZl3QmBa/2fBJhpa1NAqTg8blKH9sp2vv8Cv5SbTGGQYg5mQQk /rJzT89B33RPpB9z4qNSlcm1I8Yc3pzwZ7Vl2bfGrBxnwgGuzC+KDAYXyX7Z26TE017C YNsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726102775; x=1726707575; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6ZbGgFlVAo1BXbR5i+47qKdETSfM4rtNy9SkKSRZ+WU=; b=iLtELWimdnDmurh97hjc1jBkmUnVCzYYzA8lN8teF0mbE5e5zWBYNhXq+y6L4LM7en gctmqovvfB8uimgxh1SSV6YhxiaKi7PszcCKa0WzkPq+KbTUfahq0prDi3VwXbhARk3O luQ9dOV9CNo3IuucvMGJ40qdahA+eqpKzOlLfTXU978hbQAJKKTHG0H16oHkW7ttcBaU iHuu5bzf96UczzUIErq39s8fLxyaeiPno41wzcl1GHxkoIErp6RWn4phtAQpcwRRsWHH iTh5POCxHVgHCwYVYsXTYTsTo4fPNXveu3to1ioco+iPqSE7RMe5rL7eejfXwwbGAkZ8 59Pw== X-Gm-Message-State: AOJu0Yy//15TOdy4s+kDpCqyuVCOzKwXigHageqraQsxjUGxvI5WG4GY HQhgx0rTdVAkn7i1A2sPbz6rTId03pLuBDN9/Y3KIjAK6wED64eCQjBiTA== X-Received: by 2002:aa7:88c6:0:b0:70d:3354:a190 with SMTP id d2e1a72fcca58-719261f8db2mr1663394b3a.27.1726102775375; Wed, 11 Sep 2024 17:59:35 -0700 (PDT) Received: from localhost.localdomain ([181.92.233.116]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71908fc8210sm3557769b3a.36.2024.09.11.17.59.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 17:59:34 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 11 Sep 2024 21:59:16 -0300 Message-ID: <20240912005925.10151-2-jamrial@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912005925.10151-1-jamrial@gmail.com> References: <20240912005925.10151-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/10 v4] avcodec/h2645_sei: export raw LCEVC metadata X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: GX+NTDC9SR/I Signed-off-by: James Almer --- No changes since last version. libavcodec/h2645_sei.c | 34 ++++++++++++++++++++++++++++++++++ libavcodec/h2645_sei.h | 5 +++++ libavcodec/itut35.h | 2 ++ 3 files changed, 41 insertions(+) diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c index 7c83747cd0..c46a563308 100644 --- a/libavcodec/h2645_sei.c +++ b/libavcodec/h2645_sei.c @@ -99,6 +99,20 @@ static int decode_registered_user_data_dynamic_hdr_vivid(HEVCSEIDynamicHDRVivid } #endif +static int decode_registered_user_data_lcevc(HEVCSEILCEVC *s, + GetByteContext *gb) +{ + int size = bytestream2_get_bytes_left(gb); + + av_buffer_unref(&s->info); + s->info = av_buffer_alloc(size); + if (!s->info) + return AVERROR(ENOMEM); + + bytestream2_get_bufferu(gb, s->info->data, size); + return 0; +} + static int decode_registered_user_data_afd(H2645SEIAFD *h, GetByteContext *gb) { int flag; @@ -142,6 +156,7 @@ static int decode_registered_user_data(H2645SEI *h, GetByteContext *gb, } if (country_code != ITU_T_T35_COUNTRY_CODE_US && + country_code != ITU_T_T35_COUNTRY_CODE_UK && country_code != ITU_T_T35_COUNTRY_CODE_CN) { av_log(logctx, AV_LOG_VERBOSE, "Unsupported User Data Registered ITU-T T35 SEI message (country_code = %d)\n", @@ -173,6 +188,13 @@ static int decode_registered_user_data(H2645SEI *h, GetByteContext *gb, } break; } + case ITU_T_T35_PROVIDER_CODE_LCEVC: { + if (bytestream2_get_bytes_left(gb) < 2) + return AVERROR_INVALIDDATA; + + bytestream2_skipu(gb, 1); // user_data_type_code + return decode_registered_user_data_lcevc(&h->lcevc, gb); + } #if CONFIG_HEVC_SEI case ITU_T_T35_PROVIDER_CODE_CUVA: { const uint16_t cuva_provider_oriented_code = 0x0005; @@ -501,6 +523,10 @@ int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI *src) av_buffer_unref(&dst->unregistered.buf_ref[i]); dst->unregistered.nb_buf_ref = 0; + ret = av_buffer_replace(&dst->lcevc.info, src->lcevc.info); + if (ret < 0) + return ret; + if (src->unregistered.nb_buf_ref) { ret = av_reallocp_array(&dst->unregistered.buf_ref, src->unregistered.nb_buf_ref, @@ -778,6 +804,13 @@ int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei, } } + if (sei->lcevc.info) { + HEVCSEILCEVC *lcevc = &sei->lcevc; + ret = ff_frame_new_side_data_from_buf(avctx, frame, AV_FRAME_DATA_LCEVC, &lcevc->info); + if (ret < 0) + return ret; + } + if (sei->film_grain_characteristics.present) { H2645SEIFilmGrainCharacteristics *fgc = &sei->film_grain_characteristics; AVFilmGrainParams *fgp = av_film_grain_params_create_side_data(frame); @@ -875,6 +908,7 @@ void ff_h2645_sei_reset(H2645SEI *s) av_freep(&s->unregistered.buf_ref); av_buffer_unref(&s->dynamic_hdr_plus.info); av_buffer_unref(&s->dynamic_hdr_vivid.info); + av_buffer_unref(&s->lcevc.info); s->ambient_viewing_environment.present = 0; s->mastering_display.present = 0; diff --git a/libavcodec/h2645_sei.h b/libavcodec/h2645_sei.h index 488dbcad7e..598f78b585 100644 --- a/libavcodec/h2645_sei.h +++ b/libavcodec/h2645_sei.h @@ -50,6 +50,10 @@ typedef struct HEVCSEIDynamicHDRVivid { AVBufferRef *info; } HEVCSEIDynamicHDRVivid; +typedef struct HEVCSEILCEVC { + AVBufferRef *info; +} HEVCSEILCEVC; + typedef struct H2645SEIUnregistered { AVBufferRef **buf_ref; unsigned nb_buf_ref; @@ -126,6 +130,7 @@ typedef struct H2645SEI { H2645SEIAFD afd; HEVCSEIDynamicHDRPlus dynamic_hdr_plus; //< HEVC only HEVCSEIDynamicHDRVivid dynamic_hdr_vivid; //< HEVC only + HEVCSEILCEVC lcevc; H2645SEIUnregistered unregistered; H2645SEIFramePacking frame_packing; H2645SEIDisplayOrientation display_orientation; diff --git a/libavcodec/itut35.h b/libavcodec/itut35.h index ffa7024981..a75ef37929 100644 --- a/libavcodec/itut35.h +++ b/libavcodec/itut35.h @@ -20,11 +20,13 @@ #define AVCODEC_ITUT35_H #define ITU_T_T35_COUNTRY_CODE_CN 0x26 +#define ITU_T_T35_COUNTRY_CODE_UK 0xB4 #define ITU_T_T35_COUNTRY_CODE_US 0xB5 #define ITU_T_T35_PROVIDER_CODE_ATSC 0x31 #define ITU_T_T35_PROVIDER_CODE_CUVA 0x04 #define ITU_T_T35_PROVIDER_CODE_DOLBY 0x3B +#define ITU_T_T35_PROVIDER_CODE_LCEVC 0x50 #define ITU_T_T35_PROVIDER_CODE_SMTPE 0x3C #endif /* AVCODEC_ITUT35_H */ From patchwork Thu Sep 12 00:59:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 51548 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:14c:b0:48e:c0f8:d0de with SMTP id h12csp841130vqi; Thu, 12 Sep 2024 04:04:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUZbkgOR+lVoKiquEfu6IqLKliF8yzpkBaDRk9Zd1sAyUkGPiOjaf+uVhNfjLqYgXYbI1z9GLngcslsG+nmTEWd@gmail.com X-Google-Smtp-Source: AGHT+IG4HTmGdVSjF4pmL4kgZaVjMOlSrqzlTgC1ogQDYrz3wy9SxIVVS8R+RNbNs3zP1VuzQj6H X-Received: by 2002:a05:6512:1384:b0:535:6a05:f9e3 with SMTP id 2adb3069b0e04-53678fa9edfmr1357593e87.7.1726139056988; Thu, 12 Sep 2024 04:04:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726139056; cv=none; d=google.com; s=arc-20240605; b=EQRjRgnoiq65MSeP5r1fBtaKTH/rraKwaBdAEHw29ilVjTsfrbjux+m6cl+AZ8lplQ Q06xDPcVcGp4AWkj8Wn/YwiaZb23Cni+Ra4skEGfzPIDwAnhhLyf5erPl4xyyUCmvMSQ g4HuJ7aMnf7H/GvW6Q8RG+k0nTJBTZoJfVGQlxsVDLFHG1IzS7DOyU8r8vgz+qwBpj6U O//EnlW8nsZ5Pon1Z6BA1H6Jm9y7TxjzPjeiRU+/pUkiXXGsTV8yL7LMAWF0KBhCfYOW oGqus4px93q5G25mS5Pz6ajbrMiVlAfqFED0y9IFKypJUGjgVOG3zjn4d9Y+SJE1Z6HY aZiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=aNDb8X4OvRloVWb4uQkLg7DVkjaB3OPZrHEVsxHb5OQ=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=bXYUt+yWswzP9PI9P/dtzoEJQokwx61y0jYgtPf+sqJwmR3wws5Y+Ujr35UktN7KCS M/FAQgpBlfGl85C5a/0K0r56RRJxbVZXD6i82gvyE1+6X8xAIspMg6qIr6oVBOD4o9+0 96UVCISIXrcLnxkm9SvJljY+8aVEZH59zP6LigEmhSUzPosu92hRJMvyXc4LRZ050adZ Z1xI1P70r8JepWGfggvwz8ziv+HEW2Mwgaq2mqadv+8iQnd1S9wBFjk95EIjB0P34eWN HsoUMZ/4Z7kObjuXT6GI+vVkpCsLbMPZQEtP5nru1SFWpc+qQVOXOQtSABuYG35KblwY HCOA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=nLTYyl3v; 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=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 2adb3069b0e04-5365f9067b8si3567772e87.537.2024.09.12.04.04.15; Thu, 12 Sep 2024 04:04:16 -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=@gmail.com header.s=20230601 header.b=nLTYyl3v; 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=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EFAD568D778; Thu, 12 Sep 2024 03:59:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 76AA968D3AE for ; Thu, 12 Sep 2024 03:59:39 +0300 (EEST) Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-718f28f77f4so334779b3a.1 for ; Wed, 11 Sep 2024 17:59:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726102777; x=1726707577; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=KKD9m52++go+L6Yeh+VpT6s6mD07RiRZY6IeOcAZT4o=; b=nLTYyl3v4mU8OYPENIrwongT9Up+wDDvl2gD0VKLIiIzo7gAMWJLP1kQZYJYhxAzQG CSowXFhZ2Ehu+49B/VzI3vc9Tm5zYypp4gWgqg+haOBjlmTh/bSxKcDJdNoLdQLLT1RZ jlAi/jmutYkS2xDA5cH1nFbj6Izh1Kv4KJbClQ8pfxVIjTiWfn+jz1g+WIESefG2WPOP uLbfGgZYRISjCS6+moEMdWunp5/FKI9V/rVma/jkFZDOFVUemRnbsKLPPVHhrIEcPsFv 1QI6xN9Pzu7WjlI7yb7t/FZBKJXZ1QenF1UIXcw7Jc4nBO3LyhmEZHegBpzOSSh3yq9d Kd/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726102777; x=1726707577; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KKD9m52++go+L6Yeh+VpT6s6mD07RiRZY6IeOcAZT4o=; b=ulkWrYTLWu0LaZyVP7ROchsHgHUj46UfZE+QzcW9Xip3Ntg/FM9gHVp8BVwY7IaIL1 u2Rpor5DTjUY4CcoLO8+5kqSzgdKKR10jcuiIkGWWtijEdBNlDtmFVCecBUQTxIJ4Dvk hqIhFsLOHIACKRNEbGQPaBz+P1h0tSHS3jpUcDRqLdw81Xuo+TNboHqTnBRvU5YKa6AH D3pdqwKF5TqFxMUGAIGgyxS6ehd9hoSbMH00QEphzP0KsninamhKvB4O+iEQ5Ci5PkZ5 1MeSyTSvn6dKnMoq5Ida2ly2ZuJs9SItrszulmY2OQtx1qmi515h0batPkANFB60lgNx 1ioQ== X-Gm-Message-State: AOJu0YwLrjpFOSIZDgyxefWIbmGx4OfQYbx0ViA0ZKjO1pII4CqLWF/A yA8CTq/Jjcc0trhY/HrKc8OXDHLDFIAgVcf8oNzPUPsvN0St6yT1t4zQsQ== X-Received: by 2002:a05:6a21:e96:b0:1cf:440a:d445 with SMTP id adf61e73a8af0-1cf75f2a627mr1312366637.21.1726102777074; Wed, 11 Sep 2024 17:59:37 -0700 (PDT) Received: from localhost.localdomain ([181.92.233.116]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71908fc8210sm3557769b3a.36.2024.09.11.17.59.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 17:59:36 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 11 Sep 2024 21:59:17 -0300 Message-ID: <20240912005925.10151-3-jamrial@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912005925.10151-1-jamrial@gmail.com> References: <20240912005925.10151-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/10] avcodec: add an export_side_data flag to export picture enhancement layers X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: L4VitNZ3G/Gy Signed-off-by: James Almer --- doc/APIchanges | 3 +++ libavcodec/avcodec.h | 6 ++++++ libavcodec/options_table.h | 1 + libavcodec/version.h | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 5d7b5ab91c..f937be87cc 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07 API changes, most recent first: +2024-09-08 - xxxxxxxxxx - lavc 61.14.100 - avcodec.h + Adds a new flag AV_CODEC_EXPORT_DATA_ENHANCEMENTS for export_side_data. + 2024-09-08 - xxxxxxxxxx - lavu 59.37.100 - frame.h Add AV_FRAME_DATA_LCEVC. diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 376e130f7d..77ca8dee1f 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -419,6 +419,12 @@ typedef struct RcOverride{ */ #define AV_CODEC_EXPORT_DATA_FILM_GRAIN (1 << 3) +/** + * Decoding only. + * Do not apply picture enhancement layers, export them instead. + */ +#define AV_CODEC_EXPORT_DATA_ENHANCEMENTS (1 << 4) + /** * The decoder will keep a reference to the frame and may reuse it later. */ diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index 33f1bce887..47da41b0ad 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -93,6 +93,7 @@ static const AVOption avcodec_options[] = { {"prft", "export Producer Reference Time through packet side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_PRFT}, INT_MIN, INT_MAX, A|V|S|E, .unit = "export_side_data"}, {"venc_params", "export video encoding parameters through frame side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS}, INT_MIN, INT_MAX, V|D, .unit = "export_side_data"}, {"film_grain", "export film grain parameters through frame side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_FILM_GRAIN}, INT_MIN, INT_MAX, V|D, .unit = "export_side_data"}, +{"enhancements", "export picture enhancement metadata through frame side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_ENHANCEMENTS}, INT_MIN, INT_MAX, V|D, .unit = "export_side_data"}, {"time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, 0, INT_MAX}, {"g", "set the group of picture (GOP) size", OFFSET(gop_size), AV_OPT_TYPE_INT, {.i64 = 12 }, INT_MIN, INT_MAX, V|E}, {"ar", "set audio sampling rate (in Hz)", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, A|D|E}, diff --git a/libavcodec/version.h b/libavcodec/version.h index 755c90bbc1..7531c6c42a 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 13 +#define LIBAVCODEC_VERSION_MINOR 14 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ From patchwork Thu Sep 12 00:59:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 51531 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:14c:b0:48e:c0f8:d0de with SMTP id h12csp684949vqi; Wed, 11 Sep 2024 21:04:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCViV3c/oIwCp4CJR0iHXhqvQvA3ZqFdRFBvPKKiyPfHVlGtg1e1BugOqH2ccwKeAq5u24t5Y8yrD8XN6JUrPMiU@gmail.com X-Google-Smtp-Source: AGHT+IG7ixIyy+cKGWSp3oJtBsDYp/AsBNSj/cltZgcaeffJkfYZuIi7x34T3EKUR6CGdy0VBcIN X-Received: by 2002:a05:6512:2395:b0:52f:413:30de with SMTP id 2adb3069b0e04-53678fe6cb6mr190138e87.7.1726113853601; Wed, 11 Sep 2024 21:04:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726113853; cv=none; d=google.com; s=arc-20240605; b=i1QsfEU/wExURzP7WBQZwbv76a4BQYwO3Vqp2R97dvLGa5E9VgespZ9CDooFc//7+z eJEx/YDmiuSfhNw/tjT5CXkewrEYLPi5vri3KafhLBBOIa2IdgjHwjIESSLxKetv0GDE gDF4FNZe+7bn5KWv0ICCwOvgYmxbv1xe4Ba2pmdCvBF+7uxZHKxNM1KzlKx7VT8tuygj 2l77c0JbqDzF448izLx/Ra6z4FtwJWeJu5RLf1ygedjSxFlR4uPPrVKV5GdvMruob13M M2lPoHhvcJ58qb+lA2o3v7G1FhII0mYOhPDKDWol7im3pXyKK1c4leV3jl+jYhtuCQC9 Vr5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=mBU8L0CP+ZT78w92GYOwJhyvnsLIf7S4hUn1KFP538w=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=C+oMIx+zmFXOwBOy2wGHXQGytLObYLA/df0+QDpr7zsFk79T3ff0+8LGqxqxyYfszm 0uPCF/7gbWmxHPZQL4CySNpydMJPlYXfxnGqhll3vqN5EFt+9TZDmptkDFX7Q31Y2xJP lnHaPIAdzNhVwQewpImDQRHGAvZ422FU359Bm/h3y2YqMswE1p3XWMgWYDb0tsUeWgLg fhkwYa+fKEYjeoRlJrsuuxXqXPbArLUG6FRnXO5K1Mc0UUhQxvRPybTgb3jOlaqGNswU xW9hG5pB+9eTZKG6djWd/CoWRCdSzQzOqoiYuflkhumkIXW7zpvcqbwWBJJNzddZ4e8I 0wNQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=ccQrVhBD; 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=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 2adb3069b0e04-5365f906014si3526385e87.467.2024.09.11.21.04.12; Wed, 11 Sep 2024 21:04:13 -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=@gmail.com header.s=20230601 header.b=ccQrVhBD; 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=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5323F68D668; Thu, 12 Sep 2024 03:59:48 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6218168D7A9 for ; Thu, 12 Sep 2024 03:59:41 +0300 (EEST) Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-717911ef035so252528b3a.3 for ; Wed, 11 Sep 2024 17:59:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726102779; x=1726707579; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=+8Qs/+K86n3yS+SaMPQY/tPh/Muaq1iGHBSfrOigT6g=; b=ccQrVhBDqt3KXMhNEwwTqlShU50151ZfN7HUT2zgltDVSBZI49Jdf9zhkLs5sXayiK Y8s2f3B55hsUQ7f/2Qe98Mq8jWElgxk7UbHE8mfdKeHvl2VR7BKTSRt7+Y0ih2FblRhi 7M5aIjO2d8RzLmnYZD4qTkcBCN4LTgzfpBKn7e0LMyg2glWnw3aKGt2owjRqpFrICB9n 6+HQjL31fwh6Y26j9yrggv7+n8LS4lqqS+0b2Tpl7uuw5pvRNK0Yn+ytQ+WRMwCpH8In L6FfBxfGpAHdW5LZ9hPtCHEvHpb+BirO8xZBqzETbuoyHKcBgeFRn/uk/7ko/KPvk8r2 Fnjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726102779; x=1726707579; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+8Qs/+K86n3yS+SaMPQY/tPh/Muaq1iGHBSfrOigT6g=; b=L5F7qBb4bjkmz5Q/aN1OHZe5EFOhkoPbPRpEqry6DOAydKnnDjTE10glxXx72x51Ua k6ixRMhnyGgw8ql5B08bjS9CZgkHzacSCXockkko8ddbrDLiZidSzT2pQ4GSCdE8h/Y5 WxVAH2/VRyObK/Jp4EVoBWubAf1nR1PXcq550FmGvPSBiEQcf5H9WLJH0NuSHs41vS+5 rC4JbdmOFW8pPRDW9KHgUEQtKgFDsxO3aYt5D+q6KMCKu0L3hf/ITP6l6tmhn06WIJTk Uv+cW9mANeKfidte7BccYOYvpmTfh4TU3kn6rajczzIi7WCM+xenHt2Y7HXdj8Eu5zmV JKWQ== X-Gm-Message-State: AOJu0YyywNcWTL7BMPWrGjZo+Vtrgn3BY3jyxn/HxS1yKKPXTM9/WGhO C4tnzvsFhjFZ4YJs5+ppfCmR1nL4lrvAqCsSC6omlOu/EKp3VNCdzFhKwg== X-Received: by 2002:a05:6a00:1253:b0:714:2482:ab3c with SMTP id d2e1a72fcca58-7192606bb00mr1860933b3a.7.1726102778503; Wed, 11 Sep 2024 17:59:38 -0700 (PDT) Received: from localhost.localdomain ([181.92.233.116]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71908fc8210sm3557769b3a.36.2024.09.11.17.59.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 17:59:38 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 11 Sep 2024 21:59:18 -0300 Message-ID: <20240912005925.10151-4-jamrial@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912005925.10151-1-jamrial@gmail.com> References: <20240912005925.10151-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/10 v2] avcodec/codec_id: add an LCEVC codec id for raw LCEVC data X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: eq4xF2rzFL/C Signed-off-by: James Almer --- No changes since last version. doc/APIchanges | 3 +++ libavcodec/codec_desc.c | 6 ++++++ libavcodec/codec_id.h | 1 + 3 files changed, 10 insertions(+) diff --git a/doc/APIchanges b/doc/APIchanges index f937be87cc..9d7480e5ee 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07 API changes, most recent first: +2024-09-08 - xxxxxxxxxx - lavc 61.14.100 - avcodec.h + Add AV_CODEC_ID_LCEVC. + 2024-09-08 - xxxxxxxxxx - lavc 61.14.100 - avcodec.h Adds a new flag AV_CODEC_EXPORT_DATA_ENHANCEMENTS for export_side_data. diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index a28ef68061..03dea5751a 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -3696,6 +3696,12 @@ static const AVCodecDescriptor codec_descriptors[] = { .name = "smpte_2038", .long_name = NULL_IF_CONFIG_SMALL("SMPTE ST 2038 VANC in MPEG-2 TS"), }, + { + .id = AV_CODEC_ID_LCEVC, + .type = AVMEDIA_TYPE_DATA, + .name = "lcevc", + .long_name = NULL_IF_CONFIG_SMALL("LCEVC (Low Complexity Enhancement Video Coding) / MPEG-5 LCEVC / MPEG-5 part 2"), + }, { .id = AV_CODEC_ID_MPEG2TS, .type = AVMEDIA_TYPE_DATA, diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h index 0ab1e34a61..0a8d3bed1e 100644 --- a/libavcodec/codec_id.h +++ b/libavcodec/codec_id.h @@ -589,6 +589,7 @@ enum AVCodecID { AV_CODEC_ID_TIMED_ID3, AV_CODEC_ID_BIN_DATA, AV_CODEC_ID_SMPTE_2038, + AV_CODEC_ID_LCEVC, AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it From patchwork Thu Sep 12 00:59:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 51532 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:14c:b0:48e:c0f8:d0de with SMTP id h12csp684953vqi; Wed, 11 Sep 2024 21:04:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV9+vLYXZq87PJxXumsHCsfZxMYwRPln98+Wq1ky+31Az0hCEMFNUfIHCrdwMEHdGlEohE1mdtBWrJub3bKQB8X@gmail.com X-Google-Smtp-Source: AGHT+IGUcnL+JOX9Y3C1vDzjXO7wEdaQTmmY29zj3IRQOjtbgVKnpr0uOJsbqhRjDl4AlWI0evjN X-Received: by 2002:a5d:6743:0:b0:371:6fba:d555 with SMTP id ffacd0b85a97d-378c2cf40bamr728282f8f.18.1726113854246; Wed, 11 Sep 2024 21:04:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726113854; cv=none; d=google.com; s=arc-20240605; b=WHmi0CwIOUOEZJb5EmarLJpI4L7BqHtAM6ovNE9utfkJ5WUU47RsNCrngbl9vc3DrI Sup/5sz1501H0DljpMPeLmSDaiwFNFEcXt1gDBiix87sa6BO3/OJxovSQGNtu0lCAtw9 cd4sZFYWzN0LIQ20k6LKDocFmhwDGPI31rbhF9OLYOCJUNY9cSQ94+8W7Xs3rReE8f18 FNQMAhGDTK0yXk+5Dr+3yeI/67MXgDMIeuYwQ0D/iyjP9syiIGDo8mHz+JEyAth2ibtu YA8PnB5QjRFRRbed7m2sIiUvjNAQsC71lgWmnjpI4+NWfANFXbGeE9zQUMxPRjrp4pzi iemA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=Z8N4PSzIS4OU3Au+6TpmoPhgf4IrJ6muKhCea17DU1o=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=Vi+DZiyZwwQNqR6BKDl0tNEc6h2dhVAUNPT4xpyZJ6iwYAzUWtdhXlz3vyn4KK5rJA Z6VlVfcYpZ+2y1r0H/7F26FDhZbLowV9XcJSo5H3tsV1UMTLM9diMQ7JfJNOhjgyVB6v lTgIg5nYB7srLYmeAvHvfVwVY1Kv+N6NL/kct5c7PlcX6Dyz0SzkOMrQgQg/LMpxlnVN t5pKyoru303+MX9prbmHF/ypmG3gk1SPD1KKhd4FzKn6Qeg2fhbuzAmPjoiwe/KwfJLy P3pjvyXRURnuFk60E3ajiF2lp5BfP+vekA5aXFJzb31ElTe8/jkU2k36XyuoLeEqo7YV aWAg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=XTi72sbe; 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=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a8d2585ecdbsi259837666b.201.2024.09.11.21.04.13; Wed, 11 Sep 2024 21:04:14 -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=@gmail.com header.s=20230601 header.b=XTi72sbe; 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=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8D1E268D842; Thu, 12 Sep 2024 03:59:49 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1CB2E68D7D8 for ; Thu, 12 Sep 2024 03:59:43 +0300 (EEST) Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-7d82b0ebd51so192900a12.2 for ; Wed, 11 Sep 2024 17:59:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726102781; x=1726707581; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=GjewA5gHMmltCXgdFUNIEmIUePl0aBneI+XD9A9cQmM=; b=XTi72sbeDT50PnASwfkxDB46x1XfGpiaqdvzX7pEWiDmocfeGRqcPuwy6XuX4uvMA2 1y36qKUDChTpL5WgF3XlX/1Ia3DevW5SsD2UsspeOgr0Bad6hfL8lfvpBb8tO8CoAjNq I9D88nFYMhmBEwIesZ3Vz+OrcF6Fmj5EPjGYtFSj+7ace2JhAzQr+LLnX0HcnTP/NEpb YEWdg4RKhHki+5X9dhs145O5HxEZuYVNM60BjWEzUB1R11A2dPMqLfLhkGTk6zR8RLH8 nO9WSLrhg+BrcTjcfRhup8OO6TgANpPk7n+BBZa/L6UZ1Vfx2/6t2LNZv5AH4kHe1ua+ IPdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726102781; x=1726707581; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GjewA5gHMmltCXgdFUNIEmIUePl0aBneI+XD9A9cQmM=; b=maSKBcjTcANFqAtJauG3Jx32hKCDZhukaLk9wI45E1BozgSnOs8P+UbJJY8LIknias AgWAQMiPACvq2XH2ujwUwiQCU4KZJwut5G4aVRcoSK/uYeV5TtMmgWPEoz0PzufsFUrW 3YD+OXbDXRp4wz592nfeSZ5nbvjHMa5RR3Lp1HryYNH9X3F72KhRyGu+6r3NxwkQscQA kkrmkvkQ46U6+3z45ufcTJNsgy/CEPphXeuuiElLmEiHEC6uAULfde4NQjDyCCcIpZko EvhzKYbAL8r8B5YTMC//yMjhv3QIQlHYrJb0H68gQS25SMspkSm2UXhB1yONw8MQt9NU JVtA== X-Gm-Message-State: AOJu0YxoQLOiqSIYd/MAYDUScaZ5HsizoCKX4ay+GvS7R/o5sM3E7dOt 6JzS1CLbN+C+UGJ2y1yKIX6ZJQle2mhP8FxDUqCa7LS45AuBFFE4JW+JpA== X-Received: by 2002:a05:6300:404c:b0:1cf:1db2:da13 with SMTP id adf61e73a8af0-1cf75ea2425mr1512750637.1.1726102780431; Wed, 11 Sep 2024 17:59:40 -0700 (PDT) Received: from localhost.localdomain ([181.92.233.116]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71908fc8210sm3557769b3a.36.2024.09.11.17.59.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 17:59:39 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 11 Sep 2024 21:59:19 -0300 Message-ID: <20240912005925.10151-5-jamrial@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912005925.10151-1-jamrial@gmail.com> References: <20240912005925.10151-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/10 v2] avformat: add an LCEVC stream group X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: vSwLrWGE/Q9N Signed-off-by: James Almer --- Added some documentation and an index field to easily find the enhancement layer stream. doc/APIchanges | 5 +++++ libavformat/avformat.c | 5 +++++ libavformat/avformat.h | 27 +++++++++++++++++++++++++++ libavformat/dump.c | 27 +++++++++++++++++++++++++++ libavformat/options.c | 29 ++++++++++++++++++++++++++++- libavformat/version.h | 4 ++-- 6 files changed, 94 insertions(+), 3 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 9d7480e5ee..c151041da1 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,11 @@ The last version increases of all libraries were on 2024-03-07 API changes, most recent first: +2024-09-08 - xxxxxxxxxx - lavf 61.5.100 - avformat.h + Add AVStreamGroupLCEVC + Add AV_STREAM_GROUP_PARAMS_LCEVC + Add AVStreamGroup.params.lcevc + 2024-09-08 - xxxxxxxxxx - lavc 61.14.100 - avcodec.h Add AV_CODEC_ID_LCEVC. diff --git a/libavformat/avformat.c b/libavformat/avformat.c index b4f20502fb..06dcde0565 100644 --- a/libavformat/avformat.c +++ b/libavformat/avformat.c @@ -104,6 +104,10 @@ void ff_free_stream_group(AVStreamGroup **pstg) av_freep(&stg->params.tile_grid->offsets); av_freep(&stg->params.tile_grid); break; + case AV_STREAM_GROUP_PARAMS_LCEVC: + av_opt_free(stg->params.lcevc); + av_freep(&stg->params.lcevc); + break; default: break; } @@ -327,6 +331,7 @@ const char *avformat_stream_group_name(enum AVStreamGroupParamsType type) case AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT: return "IAMF Audio Element"; case AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION: return "IAMF Mix Presentation"; case AV_STREAM_GROUP_PARAMS_TILE_GRID: return "Tile Grid"; + case AV_STREAM_GROUP_PARAMS_LCEVC: return "LCEVC (Split video and enhancement)"; } return NULL; } diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 4a3fb00529..56c1c80289 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1084,11 +1084,37 @@ typedef struct AVStreamGroupTileGrid { int height; } AVStreamGroupTileGrid; +/** + * AVStreamGroupLCEVC is meant to define the relation between video streams + * and a data stream containing LCEVC enhancement layer NALUs. + * + * No more than one stream of @ref AVCodecParameters.codec_type "codec_type" + * AVMEDIA_TYPE_DATA shall be present, and it must be of + * @ref AVCodecParameters.codec_id "codec_id" AV_CODEC_ID_LCEVC. + */ +typedef struct AVStreamGroupLCEVC { + const AVClass *av_class; + + /** + * Index of the LCEVC data stream in AVStreamGroup. + */ + unsigned int lcevc_index; + /** + * Width of the final stream for presentation. + */ + int width; + /** + * Height of the final image for presentation. + */ + int height; +} AVStreamGroupLCEVC; + enum AVStreamGroupParamsType { AV_STREAM_GROUP_PARAMS_NONE, AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT, AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION, AV_STREAM_GROUP_PARAMS_TILE_GRID, + AV_STREAM_GROUP_PARAMS_LCEVC, }; struct AVIAMFAudioElement; @@ -1130,6 +1156,7 @@ typedef struct AVStreamGroup { struct AVIAMFAudioElement *iamf_audio_element; struct AVIAMFMixPresentation *iamf_mix_presentation; struct AVStreamGroupTileGrid *tile_grid; + struct AVStreamGroupLCEVC *lcevc; } params; /** diff --git a/libavformat/dump.c b/libavformat/dump.c index 5e1f367742..f20c2c4953 100644 --- a/libavformat/dump.c +++ b/libavformat/dump.c @@ -789,6 +789,33 @@ static void dump_stream_group(const AVFormatContext *ic, uint8_t *printed, } break; } + case AV_STREAM_GROUP_PARAMS_LCEVC: { + const AVStreamGroupLCEVC *lcevc = stg->params.lcevc; + AVCodecContext *avctx = avcodec_alloc_context3(NULL); + const char *ptr = NULL; + av_log(NULL, AV_LOG_INFO, " LCEVC:"); + if (avctx && stg->nb_streams && !avcodec_parameters_to_context(avctx, stg->streams[0]->codecpar)) { + avctx->width = lcevc->width; + avctx->height = lcevc->height; + avctx->coded_width = lcevc->width; + avctx->coded_height = lcevc->height; + if (ic->dump_separator) + av_opt_set(avctx, "dump_separator", ic->dump_separator, 0); + buf[0] = 0; + avcodec_string(buf, sizeof(buf), avctx, is_output); + ptr = av_stristr(buf, " "); + } + avcodec_free_context(&avctx); + if (ptr) + av_log(NULL, AV_LOG_INFO, "%s", ptr); + av_log(NULL, AV_LOG_INFO, "\n"); + for (int i = 0; i < stg->nb_streams; i++) { + const AVStream *st = stg->streams[i]; + dump_stream_format(ic, st->index, i, index, is_output, AV_LOG_VERBOSE); + printed[st->index] = 1; + } + break; + } default: break; } diff --git a/libavformat/options.c b/libavformat/options.c index 485265df52..039f1eea42 100644 --- a/libavformat/options.c +++ b/libavformat/options.c @@ -348,7 +348,6 @@ static const AVOption tile_grid_options[] = { { "vertical_offset", NULL, OFFSET(vertical_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS }, { NULL }, }; -#undef FLAGS #undef OFFSET static const AVClass tile_grid_class = { @@ -357,6 +356,20 @@ static const AVClass tile_grid_class = { .option = tile_grid_options, }; +#define OFFSET(x) offsetof(AVStreamGroupLCEVC, x) +static const AVOption lcevc_options[] = { + { "video_size", "size of video after LCEVC enhancement has been applied", OFFSET(width), + AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, INT_MAX, FLAGS }, + { NULL }, +}; +#undef OFFSET + +static const AVClass lcevc_class = { + .class_name = "AVStreamGroupLCEVC", + .version = LIBAVUTIL_VERSION_INT, + .option = lcevc_options, +}; + static void *stream_group_child_next(void *obj, void *prev) { AVStreamGroup *stg = obj; @@ -368,6 +381,8 @@ static void *stream_group_child_next(void *obj, void *prev) return stg->params.iamf_mix_presentation; case AV_STREAM_GROUP_PARAMS_TILE_GRID: return stg->params.tile_grid; + case AV_STREAM_GROUP_PARAMS_LCEVC: + return stg->params.lcevc; default: break; } @@ -375,6 +390,8 @@ static void *stream_group_child_next(void *obj, void *prev) return NULL; } +#undef FLAGS + static const AVClass *stream_group_child_iterate(void **opaque) { uintptr_t i = (uintptr_t)*opaque; @@ -393,6 +410,9 @@ static const AVClass *stream_group_child_iterate(void **opaque) case AV_STREAM_GROUP_PARAMS_TILE_GRID: ret = &tile_grid_class; break; + case AV_STREAM_GROUP_PARAMS_LCEVC: + ret = &lcevc_class; + break; default: break; } @@ -462,6 +482,13 @@ AVStreamGroup *avformat_stream_group_create(AVFormatContext *s, stg->params.tile_grid->av_class = &tile_grid_class; av_opt_set_defaults(stg->params.tile_grid); break; + case AV_STREAM_GROUP_PARAMS_LCEVC: + stg->params.lcevc = av_mallocz(sizeof(*stg->params.lcevc)); + if (!stg->params.lcevc) + goto fail; + stg->params.lcevc->av_class = &lcevc_class; + av_opt_set_defaults(stg->params.lcevc); + break; default: goto fail; } diff --git a/libavformat/version.h b/libavformat/version.h index 384cbd49cc..4bde82abb4 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -31,8 +31,8 @@ #include "version_major.h" -#define LIBAVFORMAT_VERSION_MINOR 5 -#define LIBAVFORMAT_VERSION_MICRO 101 +#define LIBAVFORMAT_VERSION_MINOR 6 +#define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ From patchwork Thu Sep 12 00:59:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 51539 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:14c:b0:48e:c0f8:d0de with SMTP id h12csp722417vqi; Wed, 11 Sep 2024 23:24:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVNxKGYIUWCWs7vtd9cCpmMCiWnbRMJfXPnknulhZmEcWgvvPDXUGl0lPH/XQwnq+egW5YQaoesEoOXNYmW8KvJ@gmail.com X-Google-Smtp-Source: AGHT+IFzPoXD0YxzvZlc+hM8pDd6U4jROWCNSmQGpubpM5Mivmc2CX6UI6IWmeZWvT4i5pu8OwKQ X-Received: by 2002:a2e:b8c7:0:b0:2ef:2b6e:f8c2 with SMTP id 38308e7fff4ca-2f787dbb4a8mr2232881fa.6.1726122252728; Wed, 11 Sep 2024 23:24:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726122252; cv=none; d=google.com; s=arc-20240605; b=MoUabN+tcQIIKPGLyNqtQYPmRjHQT49L8cgBDdwXi6VbwxGjsm7hsp33dqQdjO4dAD XVcjPby45A8jzAtQVZpX/zgFgNCMeTJ7vut9aiHI/xSKicV4/WgTA79bG6o2ry1MuQkL Weqm9rsvamJNzS2Vms1KQLb+sAgBaVKxtZOTZaJoFXP7qSqASsuXi40mv85zfRAq4wBt gM7MQRaGMpvUaDtfv3eyCFjoMKF7Pp/UO9/rWX8PpXnvPFGPssajYmbWCvUrcpGKhiZk RlHNp87t1AlV6Sr+Hjx4hmN4d/v7uQztrySRezbdCy4lTdzUCKZa2QI9uUPdgfyK3MIX P9Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=xThw6JgxwnV0UwRBipiOPDH28QGRmd+RastRR+WEnf0=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=Sfsx9RJmQp39jBbk9G1yGMZUtVfukEnLsC+wQmZmzqu/9K0FRpwsZhvIPvpcJ2ORiu bn6VuAKug8TZckv5RB6dFRsm/g0tzuVRDRZP8yNOYU5r5PUWb0CexzP6J7n6lKS0MB4k TU3m6d8yE7hqS82/ZxzeKbm6X/wPupuBTZ7C2y2WHxAZULPtrW9Im+itdQPFX74CBENB dLcAzul/gJq3JFyIEsEUW7U7ive4KxKrFN4IcXjcfd77IoA28iwDGA/s2HXuhrE0ZlpW xnCPgaAbYsavGniwAmVgRUKLXACm5KhsHQI41ww+77Gw3C44wxJuVKPRwRT19TM4m5lY L9qw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=TvQbc6O3; 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=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 38308e7fff4ca-2f75c0b8a72si32192611fa.620.2024.09.11.23.24.12; Wed, 11 Sep 2024 23:24:12 -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=@gmail.com header.s=20230601 header.b=TvQbc6O3; 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=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D7BEB68D90B; Thu, 12 Sep 2024 03:59:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DFED368D858 for ; Thu, 12 Sep 2024 03:59:44 +0300 (EEST) Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2054e22ce3fso4720565ad.2 for ; Wed, 11 Sep 2024 17:59:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726102782; x=1726707582; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=iLHwaGWg2SNhNa58PCg0KdEjijUshkgW+/KAPVLqHrY=; b=TvQbc6O3jYMMEgjR52dCiMODQfk8+DYRk4fJlIeLcq9Kquxp62r3bMeY/9Fpc1zhpE 2FWpF/6CkHYaTYn9tEkP/DG+oBm/XodAGlpLZJRzL2eDVs1ytkhwspLO3xTan4H/cLhD 2ZbKYl/3CWbBWT9kzaaPAYBYAI5vFspUnkONKQmRs70h/Kv8kwOp3HhlL5LAmcejIe9U I5Bj/8e5kqCO8tn4QiS6r143O6YJcnOpO1geCMQO488TeUIARRzzlkq5zEwUVbLTg49u ztjEsOKOsnDpUyGm3HI2kw7rhyR6j1vTitKHGIVgKWnzdkQqkris6Lm/2hhJcOceSyOJ SJ+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726102782; x=1726707582; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iLHwaGWg2SNhNa58PCg0KdEjijUshkgW+/KAPVLqHrY=; b=umGArB45zpM6evfGOwKsu1V7rof8TrVMr+50bstPWmlEx87vmHiNQmS2flQ3WWRkIs NLIhbsRMK/RPF8TwRuLuZTeFeaTO+4J+or8nhi93v40HuOS+XTcrgsStiSQqxqCrxNZa +VI5OPCYs9gi5spe5cVozZ6uRY8E5OVrrLJjWnveX043Ypbq6cVfNQcoCJHpj5K4aAkA kUI+zizTj0CsDBfLHrWiFLu7A+1Xs1Iy8wS12T23IHrm1zvfJnftdxf7YcGxorH2LlHj 7/iUvHfyiVTYnOgyqydYl8d9ynXYSpOuIjto4+SmdJrZKmCJhVw6XdgVHF5vwAtS5Dse EvLw== X-Gm-Message-State: AOJu0YxN9Rh9tPt3qSnyn0DnJcP41yqNy4d4Nm03X4X4I26HWu043NxQ nLPcWhDr+HwQh8Yoq1NtYWuFr8Y9H5hv8j1bQzXbmOlOT6VRcsoSLzDHlw== X-Received: by 2002:a05:6a20:d486:b0:1c8:a5ba:d2ba with SMTP id adf61e73a8af0-1cf75f2a657mr1403912637.22.1726102782007; Wed, 11 Sep 2024 17:59:42 -0700 (PDT) Received: from localhost.localdomain ([181.92.233.116]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71908fc8210sm3557769b3a.36.2024.09.11.17.59.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 17:59:41 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 11 Sep 2024 21:59:20 -0300 Message-ID: <20240912005925.10151-6-jamrial@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912005925.10151-1-jamrial@gmail.com> References: <20240912005925.10151-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 06/10 v2] avformat/mov: support for LCEVC tracks X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: F+GfxqazRGRN Co-authored-by: V-Nova Team Signed-off-by: James Almer --- libavformat/isom.h | 3 ++ libavformat/isom_tags.c | 2 + libavformat/mov.c | 86 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) diff --git a/libavformat/isom.h b/libavformat/isom.h index 15e9466e41..4723397048 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -212,6 +212,8 @@ typedef struct MOVStreamContext { unsigned drefs_count; MOVDref *drefs; int dref_id; + unsigned tref_flags; + int tref_id; int timecode_track; int width; ///< tkhd width int height; ///< tkhd height @@ -408,6 +410,7 @@ void ff_mp4_parse_es_descr(AVIOContext *pb, int *es_id); #define MOV_SAMPLE_DEPENDENCY_YES 0x1 #define MOV_SAMPLE_DEPENDENCY_NO 0x2 +#define MOV_TREF_FLAG_ENHANCEMENT 0x1 #define TAG_IS_AVCI(tag) \ ((tag) == MKTAG('a', 'i', '5', 'p') || \ diff --git a/libavformat/isom_tags.c b/libavformat/isom_tags.c index 058f0f2a59..5dd72d570e 100644 --- a/libavformat/isom_tags.c +++ b/libavformat/isom_tags.c @@ -290,6 +290,8 @@ const AVCodecTag ff_codec_movvideo_tags[] = { { AV_CODEC_ID_CFHD, MKTAG('C', 'F', 'H', 'D') }, + { AV_CODEC_ID_LCEVC, MKTAG('l', 'v', 'c', '1') }, /* LCEVC raw payload */ + { AV_CODEC_ID_NONE, 0 }, }; diff --git a/libavformat/mov.c b/libavformat/mov.c index d57c4f150b..e42f40e212 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2434,6 +2434,30 @@ static int mov_read_dvc1(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } +static int mov_read_sbas(MOVContext* c, AVIOContext* pb, MOVAtom atom) +{ + AVStream* st; + MOVStreamContext* sc; + + if (c->fc->nb_streams < 1) + return 0; + + /* For SBAS this should be fine - though beware if someone implements a + * tref atom processor that doesn't drop down to default then this may + * be lost. */ + if (atom.size > 4) { + av_log(c->fc, AV_LOG_ERROR, "Only a single tref of type sbas is supported\n"); + return AVERROR_PATCHWELCOME; + } + + st = c->fc->streams[c->fc->nb_streams - 1]; + sc = st->priv_data; + sc->tref_id = avio_rb32(pb); + sc->tref_flags |= MOV_TREF_FLAG_ENHANCEMENT; + + return 0; +} + /** * An strf atom is a BITMAPINFOHEADER struct. This struct is 40 bytes itself, * but can have extradata appended at the end after the 40 bytes belonging @@ -4995,6 +5019,8 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom) st->codecpar->codec_type = AVMEDIA_TYPE_DATA; sc->ffindex = st->index; c->trak_index = st->index; + sc->tref_flags = 0; + sc->tref_id = -1; sc->refcount = 1; if ((ret = mov_read_default(c, pb, atom)) < 0) @@ -9052,6 +9078,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('a','v','c','C'), mov_read_glbl }, { MKTAG('p','a','s','p'), mov_read_pasp }, { MKTAG('c','l','a','p'), mov_read_clap }, +{ MKTAG('s','b','a','s'), mov_read_sbas }, { MKTAG('s','i','d','x'), mov_read_sidx }, { MKTAG('s','t','b','l'), mov_read_default }, { MKTAG('s','t','c','o'), mov_read_stco }, @@ -9132,6 +9159,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('i','i','n','f'), mov_read_iinf }, { MKTAG('a','m','v','e'), mov_read_amve }, /* ambient viewing environment box */ { MKTAG('l','h','v','C'), mov_read_lhvc }, +{ MKTAG('l','v','c','C'), mov_read_glbl }, #if CONFIG_IAMFDEC { MKTAG('i','a','c','b'), mov_read_iacb }, #endif @@ -10029,6 +10057,21 @@ static int mov_parse_tiles(AVFormatContext *s) return 0; } +static AVStream *mov_find_reference_track(AVFormatContext *s, AVStream *st, + int first_index) +{ + MOVStreamContext *sc = st->priv_data; + + if (sc->tref_id < 0) + return NULL; + + for (int i = first_index; i < s->nb_streams; i++) + if (s->streams[i]->id == sc->tref_id) + return s->streams[i]; + + return NULL; +} + static int mov_read_header(AVFormatContext *s) { MOVContext *mov = s->priv_data; @@ -10154,6 +10197,49 @@ static int mov_read_header(AVFormatContext *s) } export_orphan_timecode(s); + /* Create LCEVC stream groups. */ + for (i = 0; i < s->nb_streams; i++) { + AVStreamGroup *stg; + AVStream *st = s->streams[i]; + AVStream *st_base; + MOVStreamContext *sc = st->priv_data; + + /* Find an enhancement stream. */ + if (!(sc->tref_flags & MOV_TREF_FLAG_ENHANCEMENT)) + continue; + + st->codecpar->codec_type = AVMEDIA_TYPE_DATA; + + stg = avformat_stream_group_create(s, AV_STREAM_GROUP_PARAMS_LCEVC, NULL); + if (!stg) + return AVERROR(ENOMEM); + + stg->id = st->id; + stg->params.lcevc->width = st->codecpar->width; + stg->params.lcevc->height = st->codecpar->height; + st->codecpar->width = 0; + st->codecpar->height = 0; + + j = 0; + while (st_base = mov_find_reference_track(s, st, j)) { + err = avformat_stream_group_add_stream(stg, st_base); + if (err < 0) + return err; + + j = st_base->index + 1; + } + if (!j) { + av_log(s, AV_LOG_ERROR, "Failed to find base stream for enhancement stream\n"); + return AVERROR_INVALIDDATA; + } + + err = avformat_stream_group_add_stream(stg, st); + if (err < 0) + return err; + + stg->params.lcevc->lcevc_index = stg->nb_streams; + } + for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; FFStream *const sti = ffstream(st); From patchwork Thu Sep 12 00:59:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 51546 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:14c:b0:48e:c0f8:d0de with SMTP id h12csp776674vqi; Thu, 12 Sep 2024 01:44:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWyeNcaxUpeoBw9i1c2UCRShqGb4WSAqwgMRcUr6917g3BrgOS36P5xpsW/nBw3W0FUkoD8tK47Jp10OcVtkOZH@gmail.com X-Google-Smtp-Source: AGHT+IG21WtwqwI0QtgATwxqQIx1dmZvp1RlcRHJ0a99wVZd199S5AcGLm4PsniveuPdBf6SR7JX X-Received: by 2002:a05:6512:1094:b0:536:5339:35b6 with SMTP id 2adb3069b0e04-5366bb48626mr2421912e87.30.1726130650618; Thu, 12 Sep 2024 01:44:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726130650; cv=none; d=google.com; s=arc-20240605; b=KfHoClxcusU1k96Ggo0O1kKto8X6wVr499rW5QUSjzcDFEV7MIhWw/MKmejXU2l3Sl nRX8yreBZHv+i6Iw0v0+7+XPNfb6B16E1Z7h2c4aBmAPtavf7UfUVD8hF+feinyCQDT3 ONY6dNSCgJet/I+QU1tW0J/6PGYoS2q64mdFWui0xgg++fY91prq5UUTgvGeha9KvGDt VNSIgIyLfymzUZODtohOG9LcJ3dTYu3e5HKCMAUYIMVlph4PTWPafPeEwUnrSwaeLyvs tENOKySjw81ERMRKB6CEiW9ba2Bf1wGir2QIfewXfCG349Zr2Si8zE3coJKSYceomUR/ wuOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=fgXke5lt4s0j4K9uoQ/Io1CnLRgOikgaOZUf0UA3f2g=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=HDFp7o7zMb68eMFK2nUD2vaNe/VEBABSDdjHDszD1tk47XE04Qq5Zlmcqk5EOTbaGn 12VOjCk98unI2hNH/H1/C5bDsyqQzse09vBwTGqqv6jceWeTp86BIh6lFa0pzIFTSfKX h1VGvXHRzeaJC8bcYynZdHlbxcEbEsmy+pijdBpHVLv0ryMnFGOw/gR4Vs0w5UAaynLq Xbyi+oanF9GJxzbsvOYZ382czjqRpqS9OGFC1en7QR+kHYK/157Bz2rW92PYIFLnBKfd 0Sp8ssSpwTqFulyNu9Y6g4mXbY/cH5cqO/y1goTfNkmuclYiJ5DtEFZdaqrW27XIKEiQ EU5A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=cdiWegfb; 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=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 2adb3069b0e04-5365f8c141esi3508606e87.299.2024.09.12.01.44.10; Thu, 12 Sep 2024 01:44:10 -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=@gmail.com header.s=20230601 header.b=cdiWegfb; 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=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2ADAF68D94F; Thu, 12 Sep 2024 03:59:55 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ACF6768D90B for ; Thu, 12 Sep 2024 03:59:46 +0300 (EEST) Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-71923d87be4so235957b3a.0 for ; Wed, 11 Sep 2024 17:59:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726102784; x=1726707584; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Pr6iIwo6ummyN37Axq3AH82Z9Y06C3TozSJ8juIkSI4=; b=cdiWegfbap7JkYzm2OfuutQpCwY0WnEQe72mn3ETjtnYW9VIEpKGuI4DX5pZ1uQzcy RFwPPN170Cyv0w9S5F0HuerncLvKAdYAwKbqV87+UQVQcDFj4BQkAWJa3K8PWgqS9y+O 4oJEN2oj2W0eUD9t5Rmfv/17N9Pv2IsGfoBWqqRLRVN1hC/c2U+Z8cgcbAH7zwcJQ9Yb 6V9xamajjp95hhCHjGsBsHCcS+buFwvCcoC+XSNZuQxesSHZwvBgspFs0RLvNfXgVeyh UAPrFIqMVGd7UJgZ9v+ahlvOuwVIUNQORdpcw+LN7KBdcevQzj2T0xG7e789KvCWHQ4w B6yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726102784; x=1726707584; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Pr6iIwo6ummyN37Axq3AH82Z9Y06C3TozSJ8juIkSI4=; b=kMDbSnCqB+Wl/U+Gt4FPjU0q90NLgSG+1520h2m7xtsd41xfv4dzAuZGaDZWAWyEhy LG54aLADFi623y9RokuuogJ37gg4YrZbqsHASvdUnXo/oB69TzIczfaRV8C4kYHxep3L g1jcS1rIFkBKg5Gvn3VUSeEClk9ZiMf0fmWyREA4KRnx8awmy2gGWkXajFh+GFTu7vXd P5KkdRxoE1oRNp4urV8gUd9nPCMWIEuSkMFAkK6Eo8A8/HlOsVgaljtOlg5uhezO0XHb RwP2ti/rvERidEq27/qh97kS83w9q6A07bJopBbXN0i5UvPgLan136XwuzoIYogKWDc4 AYvQ== X-Gm-Message-State: AOJu0Yw7wgqRQ5qabp2HnT+e36voDN+Zh/R9+L+X1C6JoOkm2mTOWX0C dzVyS2iceRXQXIr9u2szgmWjuXTtMmpXjCqQvypbZNRUM9uhFvNnR2jVbA== X-Received: by 2002:a05:6a00:92a8:b0:717:88b6:6b1e with SMTP id d2e1a72fcca58-719261d0a4dmr1380448b3a.18.1726102783853; Wed, 11 Sep 2024 17:59:43 -0700 (PDT) Received: from localhost.localdomain ([181.92.233.116]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71908fc8210sm3557769b3a.36.2024.09.11.17.59.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 17:59:43 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 11 Sep 2024 21:59:21 -0300 Message-ID: <20240912005925.10151-7-jamrial@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912005925.10151-1-jamrial@gmail.com> References: <20240912005925.10151-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/10 v2] avcodec/packet: add an LCEVC enhancement data payload side data type X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ikCf6KHvIMCB Signed-off-by: James Almer --- No changes since last version. doc/APIchanges | 3 +++ libavcodec/decode.c | 1 + libavcodec/packet.c | 1 + libavcodec/packet.h | 6 ++++++ libavcodec/version.h | 2 +- 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index c151041da1..b71ceb010c 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07 API changes, most recent first: +2024-09-08 - xxxxxxxxxx - lavc 61.15.100 - packet.h + Add AV_PKT_DATA_LCEVC. + 2024-09-08 - xxxxxxxxxx - lavf 61.5.100 - avformat.h Add AVStreamGroupLCEVC Add AV_STREAM_GROUP_PARAMS_LCEVC diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 27dba8a1f3..18ddd28690 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1434,6 +1434,7 @@ int ff_decode_frame_props_from_pkt(const AVCodecContext *avctx, { AV_PKT_DATA_DYNAMIC_HDR10_PLUS, AV_FRAME_DATA_DYNAMIC_HDR_PLUS }, { AV_PKT_DATA_S12M_TIMECODE, AV_FRAME_DATA_S12M_TIMECODE }, { AV_PKT_DATA_SKIP_SAMPLES, AV_FRAME_DATA_SKIP_SAMPLES }, + { AV_PKT_DATA_LCEVC, AV_FRAME_DATA_LCEVC }, }; frame->pts = pkt->pts; diff --git a/libavcodec/packet.c b/libavcodec/packet.c index 032f270777..381001fd65 100644 --- a/libavcodec/packet.c +++ b/libavcodec/packet.c @@ -306,6 +306,7 @@ const char *av_packet_side_data_name(enum AVPacketSideDataType type) case AV_PKT_DATA_IAMF_DEMIXING_INFO_PARAM: return "IAMF Demixing Info Parameter Data"; case AV_PKT_DATA_IAMF_RECON_GAIN_INFO_PARAM: return "IAMF Recon Gain Info Parameter Data"; case AV_PKT_DATA_FRAME_CROPPING: return "Frame Cropping"; + case AV_PKT_DATA_LCEVC: return "LCEVC NAL data"; } return NULL; } diff --git a/libavcodec/packet.h b/libavcodec/packet.h index 13667ffa36..0a28010542 100644 --- a/libavcodec/packet.h +++ b/libavcodec/packet.h @@ -339,6 +339,12 @@ enum AVPacketSideDataType { */ AV_PKT_DATA_FRAME_CROPPING, + /** + * Raw LCEVC payload data, as a uint8_t array, with NAL emulation + * bytes intact. + */ + AV_PKT_DATA_LCEVC, + /** * The number of side data types. * This is not part of the public API/ABI in the sense that it may diff --git a/libavcodec/version.h b/libavcodec/version.h index 7531c6c42a..9b8c267529 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 14 +#define LIBAVCODEC_VERSION_MINOR 15 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ From patchwork Thu Sep 12 00:59:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 51544 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:14c:b0:48e:c0f8:d0de with SMTP id h12csp776676vqi; Thu, 12 Sep 2024 01:44:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUmk/dLYooVk1TwcIlYpGQSXE/lJClzHG0JXCUVqJBZul0N1APPa7qZQrvXKvGBH3gmlrgbTewDeLFBYqLZGNTW@gmail.com X-Google-Smtp-Source: AGHT+IEvA+F/RdzkQUOvIll29fE7eUl5qJzAxEjKJRBVNd2GmVKNAUvBF8MyF0XFk/lQttYY28cm X-Received: by 2002:a05:651c:2211:b0:2ef:21b3:cdef with SMTP id 38308e7fff4ca-2f787edd67dmr12073801fa.25.1726130650566; Thu, 12 Sep 2024 01:44:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726130650; cv=none; d=google.com; s=arc-20240605; b=O3eOA0XUTk9Zg53KffXlkoW9jX29TIs3gldp+NPRvdvuSVTaSq4zKlNBMsLBPlq4Vl K8AbiEadQDdZ4aw1C5SGHEcDa6aUli4lqEewHVzbudviAtce+5mujxPvglabPF18aEmo qegW97dzJ5jLcPhdirFPG73ACi75auIwnLo+CpyXdwKNQy4a0T7ouXxE8uJ9KpLyXbUS jOBFS+OYlFyTBeUtOvU0r8JlhCZkKpULOTPEGx+eoXjbUjZNH5oU3YQmKilDloq6Q6sB cfO+RHs64MN6bGQYdtdV4PJ6WrGMjmjS7RwjqgzCEw2MoK6mBVhfUPUucJercClAQSv8 buiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=ihMVOXn34b01TttLBegcMNavMu9waHv3q+f7xshnqHA=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=PZnmJAKsbb6n8OBz3YnXjW/2vIalnkajqT0Wkn5exws2xBCUqsch84L/0xs+o2Uj2n HTKH0BVawg5ZboGifguW389iVki4GFf0HCjV94GZq2Go15nuke9kLLFuX2NSgbcqa8GF z4UwAmE5VqJ6kUjqkleD0HPijuB0PFOxBqz6rwr+7Be17ET11SGCfkXedWKIke74bNsi 1MzSysn8WqKcyCqJA4jkzQ0CC7vxu2gi7g/jd/SEAHdY1C1oFvFKtuDe1QPXaLDsGEzT 9FZvfJFPyTgz4xd2Rfva8bwVu58yEPhtUXHuYHZHBTZQEnsVXv7XaAJRzzdf1hDzCST5 cvmQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=kjvHqDaY; 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=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 38308e7fff4ca-2f75bfea454si34287481fa.157.2024.09.12.01.44.10; Thu, 12 Sep 2024 01:44:10 -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=@gmail.com header.s=20230601 header.b=kjvHqDaY; 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=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2A8A468D95B; Thu, 12 Sep 2024 03:59:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 075DF68D818 for ; Thu, 12 Sep 2024 03:59:48 +0300 (EEST) Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-718d606726cso218264b3a.3 for ; Wed, 11 Sep 2024 17:59:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726102786; x=1726707586; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=1+WMg9YO8bBbcnkXJrfpIOscDd1i3n7k3W2YLiv4FDM=; b=kjvHqDaYpnoVZNQIHIffX2CzeD+HnxHKWGBD/MyEjUuyrURPU42a7X7+Gug32umGKN N3etq7CWM/0Xcyy/6ikyhyHqdVt6uxg9/waMevDM6U0QN3EfEbhjqUXi7WQ+rkogML+v hbI45h6FvYZIyQR/SSevVsz+kqUlymBChxSzxpmj47/IT9ZjZz3VqzGN0XMaUfTV2hgo ifbVO20TxiX9/3/o6x/6G19yLGV/5ABVj4aIHPcO08UgMpWr5zF/j/oprdByQplw/nWh bOPDb9BaoUqq5T18jZB/mV8AQ76oxxiz0xHyc+S32YqM1e9ES5zSsErDYLh3icZO2t2J CW+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726102786; x=1726707586; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1+WMg9YO8bBbcnkXJrfpIOscDd1i3n7k3W2YLiv4FDM=; b=Dp22qoFm0mkISXULpc2QssGsCk5uOu4U2mMKsuYMvE70cflkb+2/yoAl3pGYIOMjSU a9bHhh/7leSHpJyLO/Cpddpgt3Di6kGKLbLUht5hPxFbv96vzv4BBdY3VxQHXir92hxq ZX2YdSVcw8+F0TVTPk583aJTZbj6R136An83yYka8sDxI+msxEL432xQo54kjeaMryV5 urnjEadYA/0Ve/nzW8VrhvRVWZA5G1A06NebaKkTqJIG8KG1itDYLr9Q4ej32+bz3t7R CUlZTueHxPCnWBaSr83xZs2FW5hm+7noQxwVwc6DzqOM4HmYA2QR8fWl4OT8aohVWAw6 nKpA== X-Gm-Message-State: AOJu0YwhmMMcUV3euW9BtOGtU7GjtbLPmNRLOQCG6VacA5phv4qFFVC5 1dc6Y3siaBZD9ITpK1GHxewhNFQC/wKTVIvWLQsE88Ac1yauXYwC0G20bg== X-Received: by 2002:a05:6a00:2d17:b0:714:2d05:60df with SMTP id d2e1a72fcca58-71926091d24mr1630972b3a.15.1726102785607; Wed, 11 Sep 2024 17:59:45 -0700 (PDT) Received: from localhost.localdomain ([181.92.233.116]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71908fc8210sm3557769b3a.36.2024.09.11.17.59.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 17:59:44 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 11 Sep 2024 21:59:22 -0300 Message-ID: <20240912005925.10151-8-jamrial@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912005925.10151-1-jamrial@gmail.com> References: <20240912005925.10151-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/10 v2] avcodec/decode: split ProgressFrame allocator into two functions X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ec1IhBLR8m2R Signed-off-by: James Almer --- No changes since last version. libavcodec/decode.c | 11 +++++++---- libavcodec/progressframe.h | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 18ddd28690..e4e92e34e4 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1725,7 +1725,7 @@ static void check_progress_consistency(const ProgressFrame *f) av_assert1(!f->progress || f->progress->f == f->f); } -static int progress_frame_get(AVCodecContext *avctx, ProgressFrame *f) +int ff_progress_frame_alloc(AVCodecContext *avctx, ProgressFrame *f) { FFRefStructPool *pool = avctx->internal->progress_frame_pool; @@ -1743,9 +1743,12 @@ int ff_progress_frame_get_buffer(AVCodecContext *avctx, ProgressFrame *f, int fl { int ret; - ret = progress_frame_get(avctx, f); - if (ret < 0) - return ret; + check_progress_consistency(f); + if (!f->f) { + ret = ff_progress_frame_alloc(avctx, f); + if (ret < 0) + return ret; + } ret = ff_thread_get_buffer(avctx, f->progress->f, flags); if (ret < 0) { diff --git a/libavcodec/progressframe.h b/libavcodec/progressframe.h index 428a461659..32a345beec 100644 --- a/libavcodec/progressframe.h +++ b/libavcodec/progressframe.h @@ -102,12 +102,24 @@ void ff_progress_frame_report(ProgressFrame *f, int progress); void ff_progress_frame_await(const ProgressFrame *f, int progress); /** - * This function sets up the ProgressFrame, i.e. gets ProgressFrame.f - * and also calls ff_thread_get_buffer() on the frame. + * This function allocates ProgressFrame.f + * May be called before ff_progress_frame_get_buffer() in the cases where the + * AVFrame needs to be accessed before the ff_thread_get_buffer() call in + * ff_progress_frame_alloc(). * * @note: This must only be called by codecs with the * FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap. */ +int ff_progress_frame_alloc(struct AVCodecContext *avctx, ProgressFrame *f); + +/** + * This function sets up the ProgressFrame, i.e. allocates ProgressFrame.f + * if needed, and also calls ff_thread_get_buffer() on the frame. + * + * @note: This must only be called by codecs with the + * FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap. + * @see ff_progress_frame_alloc + */ int ff_progress_frame_get_buffer(struct AVCodecContext *avctx, ProgressFrame *f, int flags); From patchwork Thu Sep 12 00:59:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 51540 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:14c:b0:48e:c0f8:d0de with SMTP id h12csp722429vqi; Wed, 11 Sep 2024 23:24:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW5G3+Awuh6XKZ2i/jlLiKbvyY4RRBui0A3uQjfoHaHazWQ3wMmmt7x+H4BFNy/N9F2iOMuDcPbJ8egVXHRxDSZ@gmail.com X-Google-Smtp-Source: AGHT+IEiM0xcU4MIgBIemu0uF8vHcC2QR4Klda4jODCrL8caS3/YPHYGys9ScGAPnV82PtyD3yXS X-Received: by 2002:a2e:4a19:0:b0:2f3:f8d7:d556 with SMTP id 38308e7fff4ca-2f787dc864dmr7110081fa.18.1726122253975; Wed, 11 Sep 2024 23:24:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726122253; cv=none; d=google.com; s=arc-20240605; b=I9lBSmbOfXmL7HXf2PjRqWlcwv7XEbCiGJRiBEJb/1bCom+zUn8GJKer0ziL6QrTxc eDWmuk5vRnssASv/4xsfLwAqUBfOa/tefvEXniTLJjIrf1lM1FEtyq/X+93kzsu+9yb9 XwVI3NmDJt15xLUu25++j3zTIt/Ddr63sL9QLsRbdJjGJrytJ1VPnLu1lQyyQ9aGOTkp K3dsKCshtY0PUeomlQBtvxiS7Mdmd3UwbjnAeR9qVyD2vJC5oAuLGfTjk1Fhq3fwD1e8 fPt6+IXjIwx2OEnd3SA9YFN2ICM2NZDMSPJ95xI+vwij62cdAqb/2sS9yjHyyF/hnxPM oO+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=PpAXEcUHAr0WgFmkHIpe6+vKHe5oKDGJrUBYboIayl0=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=B83xgGlC+qB92OcI2WfXijawnXXgXhEllQvQCQjwp12DjmQU2PmR3jJxFZj68+9aMq TRt+FUc/Zb8PT+DG7a/lcG8LHoY+hm0U0MQ3/1kYlCic36wzHH8QkInsKE9WLc5wF5i7 Tnmd7Vx0Fgl/q5GJRaU8a2luUmGy4Lkut3KzklCFGB41FeG/D0hWQ0JxwwvZkbHch8D2 WJBmKqcdlnl9XC55O+iZup3Buz6R2NPjfkKUDK4HT9+VfVIZp3GC8jWdDN01/wptRb3T 7IPdF95C0ouYmGujXya/XVE/F0yNjgeOzRZ/MTvTmmC/2ikAElKF+Jf7ZY71RavysLrq udhQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=fNzRI+Y5; 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=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 4fb4d7f45d1cf-5c3ebdab6fcsi8339206a12.606.2024.09.11.23.24.13; Wed, 11 Sep 2024 23:24:13 -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=@gmail.com header.s=20230601 header.b=fNzRI+Y5; 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=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4493C68D99C; Thu, 12 Sep 2024 03:59:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3945168D910 for ; Thu, 12 Sep 2024 03:59:49 +0300 (EEST) Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-7db12af2f31so418272a12.1 for ; Wed, 11 Sep 2024 17:59:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726102787; x=1726707587; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=VUdUieD16iXRDL6xUC1S3Eyy6dcKEQr6tLYRW00kpTM=; b=fNzRI+Y5rn9eUINZ4VN78zNy2pk5cgSwyPrJRNqoLmJdpH6Cu4uk/RY1XKWBl1rjZ/ FQAmrjSQ1h1ctYj03aDY+VUrXYJ7Dnb16Nb0y+LJdcUvzaQSiZLJ/jP6n0MT8lB3spO9 5cbS4iXp6lEI/kXbt3qVRU4BJkSPNTy20Cl9/avh4e/tY33eG/dWU7gWpizeAvpmh2aN HZoqYeAzZcd3IW+S9YH/3w3AVZG8+l0xHc5h4iV2n298JgT40lhwpZZ0nyDlVNnJWTXJ QVi/yAzYQ6qwQHFsZdZuTtQrY2Z330sAebIottpBgeo8FdYKLnWhok/1oHhXpeay0CZ3 54LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726102787; x=1726707587; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VUdUieD16iXRDL6xUC1S3Eyy6dcKEQr6tLYRW00kpTM=; b=CRUosNLOoyH4lha9epkW+g0jr89/wKLJdMDJhH/H26OWnYK+42SeyI95ANqY5CuMS+ MP9Y2k4MG5CCn+sMvOUv6/IVdVLhJXk93PsCqvRQwUVY0N9dk6aCrJoSnjkWvy5sG5OH 25Lklt+n4jLORnIojDgNVJlQYkEzm3iuvK5Fe9kOZLqQbkuZmhGVyV9PfDy9hcHo4LiB KClFs9dErFOvfGIzNkcC8MH6LNQyXQKH0ct/8mPNSy5beNNZhwcZ1WMK95FMCf9y+GW3 uN5nN5Ayd8Pso6mQpUh5MTeKnjCWmrjzBuYog+4HY79/CPVh0l7wCR28nvUuZfydA8Pn JOaw== X-Gm-Message-State: AOJu0Yx728edZ5lK8FT7DK1f1EMfjAX/hNOm0vjF/UQKocKvVi/SWElr h8WbIcvsTbaYDO8NGTG+ETKAafL/ZztKQnSjYg/CQkzhJf4JnxrzqWf+ZA== X-Received: by 2002:a05:6a21:a4c1:b0:1cf:314d:4ff1 with SMTP id adf61e73a8af0-1cf7616931bmr1463366637.30.1726102787105; Wed, 11 Sep 2024 17:59:47 -0700 (PDT) Received: from localhost.localdomain ([181.92.233.116]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71908fc8210sm3557769b3a.36.2024.09.11.17.59.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 17:59:46 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 11 Sep 2024 21:59:23 -0300 Message-ID: <20240912005925.10151-9-jamrial@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912005925.10151-1-jamrial@gmail.com> References: <20240912005925.10151-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 09/10] avcodec/hevc/refs: ensure LCEVC SEI payloads are exported as frame side data before get_buffer() calls X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: kd4K4uE0M2RG Signed-off-by: James Almer --- libavcodec/hevc/refs.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libavcodec/hevc/refs.c b/libavcodec/hevc/refs.c index 09d759f936..a75153c462 100644 --- a/libavcodec/hevc/refs.c +++ b/libavcodec/hevc/refs.c @@ -86,6 +86,19 @@ static HEVCFrame *alloc_frame(HEVCContext *s, HEVCLayerContext *l) if (frame->f) continue; + ret = ff_progress_frame_alloc(s->avctx, &frame->tf); + if (ret < 0) + return NULL; + + // Add LCEVC SEI metadata here, as it's needed in get_buffer() + if (s->sei.common.lcevc.info) { + HEVCSEILCEVC *lcevc = &s->sei.common.lcevc; + ret = ff_frame_new_side_data_from_buf(s->avctx, frame->tf.f, + AV_FRAME_DATA_LCEVC, &lcevc->info); + if (ret < 0) + goto fail; + } + ret = ff_progress_frame_get_buffer(s->avctx, &frame->tf, AV_GET_BUFFER_FLAG_REF); if (ret < 0) From patchwork Thu Sep 12 00:59:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 51552 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:14c:b0:48e:c0f8:d0de with SMTP id h12csp1222899vqi; Thu, 12 Sep 2024 15:44:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVYgjz9XZBT7WbQDRQoEMtuW9VcygxBNRkVbjicI+ZfWv6W2k8rEeFX5wC2rOBXu0IE6EotT5J9oeN3z0K/r0dQ@gmail.com X-Google-Smtp-Source: AGHT+IGSoDWBRHtclba/uGXg0I1sKXJUCEE2HR22QBylSPkdIHZSelwdINv4C6TPhTHNCQatEbVU X-Received: by 2002:a2e:a0cf:0:b0:2f6:62f3:9709 with SMTP id 38308e7fff4ca-2f787dd1917mr20925401fa.20.1726181054201; Thu, 12 Sep 2024 15:44:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726181054; cv=none; d=google.com; s=arc-20240605; b=eZ4POsnTsw8ceIOil1td7lzNf9y3ocjEchZrev0j/w4gGAtO0YGc+b78EDlec4QCTU 1kif5Pp7jdegHkjYqabxt4Pla7YC1YgPwgL/c6ivzj4c1YmDc73+UK/w10oC93wQgyiS rwxnhaYizsb/t/IYyOw6cg8fvzsc5pQa1zVkFqoQftVFvRClxzobiOQmakpv+d0s9XNs bUDaEQmuI7BgJpyHCgr2QyMnDAtZBO1QS6/nLmK1WdcPy0EfE8q9nz1QZkm0DpOe3Yq7 8UXdI8OZ/x+aL6Wu+ykewNGYjS3RhViQTHL5U2mh/9ZnG/c1SVKoQyl1vYN5aVvjH+td /xsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=u6CgCq4KWLlyY8txCyHHqrn2rW8bJRDJIzNzWnoS+rU=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=JaLM/qXAb+YWltdKpaecOKMucXTj0uaWwDVUk+FVRE+RUtZ/KhlTBYXcBVd2dQ7PcP IpNPRWD2fXwPnnKn4/Jv8HSnG9XJhyoNdoQQHPx9IfM7z69NdT+8b1Pc9mO7AGotcxnf jq6bIa/A6rzLqlTY449dXhseKLM1BU/5A6azxWt8zY94PfVgz2sZZlVMTRB3xiIprwoO 9Xvjzha/vkVTG7ZUQkE/K+dmg6DWKQm/mAgw+Plq43aoJEpgSGDTyWlXxXpQ9dsjUVCZ ttqpGjQb/y23JhJJkz7Or6IdY1Q0mmOe4Aq5OLXmBqWbT9cMtBvuGwFbwJnKsSDRR85s 8UHQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b="C/h9VGOY"; 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=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 4fb4d7f45d1cf-5c3ebd43215si9517009a12.29.2024.09.12.15.44.13; Thu, 12 Sep 2024 15:44:14 -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=@gmail.com header.s=20230601 header.b="C/h9VGOY"; 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=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0F77F68D8F9; Thu, 12 Sep 2024 03:59:54 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 91B0E68D8FB for ; Thu, 12 Sep 2024 03:59:51 +0300 (EEST) Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-27b88b8a24aso204481fac.1 for ; Wed, 11 Sep 2024 17:59:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726102789; x=1726707589; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=jFyEcHowfY8z0wH+lhl11/TvKsJ66LuJjX90G8HF1GU=; b=C/h9VGOY5qGDZ24cUe/4tUt4HalUD1zhFOM5BDSRBYy7Zr2pxn+KQkV4PHfSjBXKZ6 RgUmrpzzIlk93nxpJP5+HfB9iR6Fzl7PK55rb0Wu69ZCRjjpDG0dGI9reRICPyzZehPC TA95Uh28y78vexFeD76OF8GHQUvV1Y/yR/c0iF8lvI88lzOg2D8LCm5wqT3HviiutPQ2 cjRaapC92AlY1dKem+z4ePZgnuKXnp2NTGaQ2Z1tlmwY8QTHHwHnraiom6cSeZgG2YRe fdSARJeGOkMJRUP34qCov+7kg0SlstaM/Hi4OB9xLV03ZxJgnoz/FSwBUxRWfc+vrZZ/ gGFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726102789; x=1726707589; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jFyEcHowfY8z0wH+lhl11/TvKsJ66LuJjX90G8HF1GU=; b=dYsF5H/6zM/ExPNQwfLczvdyPJ3J09Bm7io/EJK9AzQ2Y1ZnuCyJVhK9TwE27WepYx Rs7wjhRqcQghliVoen6lGGMjn3W4eNsY0ev7kcCKB0Atw2UIviH3BHg77TsEWDpapQIA KHNQC+FOogS3C2d9YHFkvbYaRjBqNEb84oUO/9SIROoZGmepDpjKe+6xQsIWoSl4ORRf IKUY3wAdQCSJGi0zVzi9+A3KIhv9dhGy0mnhKhvC4gyYPIvTAFNOeOFlWMTTzIj+avZE AY7VgVpkGguVYR8+4BGoi1tILhoQsxcVA7bChRsBvgn1ZcWL9GWLZOjCcgmlUGWFRaIJ LeeA== X-Gm-Message-State: AOJu0YwBT8XcXSYjrdUUSwMyAU4u1lUap5eBxY/9xUFKJkeQK7MuqOwO nP6OQ6/8tyoh57Hv1FwhCaZg0LL/NhlO3oYShL6sEszqPVEYzoZYBLD+XQ== X-Received: by 2002:a05:6870:910f:b0:277:eb68:2878 with SMTP id 586e51a60fabf-27c3f6a6e6emr787729fac.44.1726102788664; Wed, 11 Sep 2024 17:59:48 -0700 (PDT) Received: from localhost.localdomain ([181.92.233.116]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71908fc8210sm3557769b3a.36.2024.09.11.17.59.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 17:59:48 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 11 Sep 2024 21:59:24 -0300 Message-ID: <20240912005925.10151-10-jamrial@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912005925.10151-1-jamrial@gmail.com> References: <20240912005925.10151-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/10 v4] avcodec: add LCEVC decoding support via LCEVCdec X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: PyZxBmb0fr0g Signed-off-by: James Almer --- Somewhat improved the glue, making it all internal to decode.c and no longer touching AVCodecInternal. I also tried abstracting the delayed processing API in FrameDecodeData by moving it into a standalone API, but the result was quite a bit of complexity that may only become worth applying once there's more than just a few hwaccels and LCEVC using it. I can send a PoC of it if there's interest. configure | 5 +- doc/general_contents.texi | 13 ++ libavcodec/Makefile | 1 + libavcodec/avcodec_internal.h | 4 + libavcodec/decode.c | 65 ++++++- libavcodec/lcevcdec.c | 318 ++++++++++++++++++++++++++++++++++ libavcodec/lcevcdec.h | 42 +++++ libavcodec/pthread_frame.c | 3 + 8 files changed, 449 insertions(+), 2 deletions(-) create mode 100644 libavcodec/lcevcdec.c create mode 100644 libavcodec/lcevcdec.h diff --git a/configure b/configure index d3bd46f382..db9638a1ae 100755 --- a/configure +++ b/configure @@ -225,6 +225,7 @@ External library support: --enable-libcdio enable audio CD grabbing with libcdio [no] --enable-libcodec2 enable codec2 en/decoding using libcodec2 [no] --enable-libdav1d enable AV1 decoding via libdav1d [no] + --enable-liblcevc-dec enable LCEVC decoding via liblcevc-dec [no] --enable-libdavs2 enable AVS2 decoding via libdavs2 [no] --enable-libdc1394 enable IIDC-1394 grabbing using libdc1394 and libraw1394 [no] @@ -1914,6 +1915,7 @@ EXTERNAL_LIBRARY_LIST=" libcelt libcodec2 libdav1d + liblcevc_dec libdc1394 libflite libfontconfig @@ -4027,7 +4029,7 @@ cws2fws_extralibs="zlib_extralibs" # libraries, in any order avcodec_deps="avutil" -avcodec_suggest="libm stdatomic" +avcodec_suggest="libm stdatomic liblcevc_dec" avdevice_deps="avformat avcodec avutil" avdevice_suggest="libm stdatomic" avfilter_deps="avutil" @@ -6870,6 +6872,7 @@ enabled libcelt && require libcelt celt/celt.h celt_decode -lcelt0 && enabled libcaca && require_pkg_config libcaca caca caca.h caca_create_canvas enabled libcodec2 && require libcodec2 codec2/codec2.h codec2_create -lcodec2 enabled libdav1d && require_pkg_config libdav1d "dav1d >= 0.5.0" "dav1d/dav1d.h" dav1d_version +enabled liblcevc_dec && require_pkg_config liblcevc_dec "lcevc_dec >= 2.0.0" "LCEVC/lcevc_dec.h" LCEVC_CreateDecoder enabled libdavs2 && require_pkg_config libdavs2 "davs2 >= 1.6.0" davs2.h davs2_decoder_open enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 dc1394/dc1394.h dc1394_new enabled libdrm && check_pkg_config libdrm libdrm xf86drm.h drmGetVersion diff --git a/doc/general_contents.texi b/doc/general_contents.texi index e7cf4f8239..5309db9ba8 100644 --- a/doc/general_contents.texi +++ b/doc/general_contents.texi @@ -245,6 +245,19 @@ Go to @url{https://github.com/google/liblc3/} and follow the instructions for installing the library. Then pass @code{--enable-liblc3} to configure to enable it. +@section LCEVCdec + +FFmpeg can make use of the liblcevc_dec library for LCEVC enhacement layer +decoding on supported bitstreams. + +Go to @url{https://github.com/v-novaltd/LCEVCdec} and follow the instructions +for installing the library. Then pass @code{--enable-liblcevc-dec} to configure to +enable it. + +@float NOTE +LCEVCdec is under the BSD-3-Clause-Clear License. +@end float + @section OpenH264 FFmpeg can make use of the OpenH264 library for H.264 decoding and encoding. diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 1d27e554c8..18663e332f 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -46,6 +46,7 @@ OBJS = ac3_parser.o \ get_buffer.o \ imgconvert.o \ jni.o \ + lcevcdec.o \ mathtables.o \ mediacodec.o \ mpeg12framerate.o \ diff --git a/libavcodec/avcodec_internal.h b/libavcodec/avcodec_internal.h index 31745b89b1..f4ec3595c5 100644 --- a/libavcodec/avcodec_internal.h +++ b/libavcodec/avcodec_internal.h @@ -68,6 +68,10 @@ void ff_decode_flush_buffers(struct AVCodecContext *avctx); void ff_encode_flush_buffers(struct AVCodecContext *avctx); struct AVCodecInternal *ff_decode_internal_alloc(void); +void ff_decode_internal_sync(struct AVCodecContext *dst, + const struct AVCodecContext *src); +void ff_decode_internal_uninit(struct AVCodecInternal *avci); + struct AVCodecInternal *ff_encode_internal_alloc(void); void ff_codec_close(struct AVCodecContext *avctx); diff --git a/libavcodec/decode.c b/libavcodec/decode.c index e4e92e34e4..1f9263a567 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -48,6 +48,7 @@ #include "hwaccel_internal.h" #include "hwconfig.h" #include "internal.h" +#include "lcevcdec.h" #include "packet_internal.h" #include "progressframe.h" #include "refstruct.h" @@ -89,6 +90,11 @@ typedef struct DecodeContext { * (global or attached to packets) side data over bytestream. */ uint64_t side_data_pref_mask; + + FFLCEVCContext *lcevc; + int lcevc_frame; + int width; + int height; } DecodeContext; static DecodeContext *decode_ctx(AVCodecInternal *avci) @@ -1597,6 +1603,40 @@ int ff_attach_decode_data(AVFrame *frame) return 0; } +static void update_frame_props(AVCodecContext *avctx, AVFrame *frame) +{ + AVCodecInternal *avci = avctx->internal; + DecodeContext *dc = decode_ctx(avci); + + dc->lcevc_frame = dc->lcevc && avctx->codec_type == AVMEDIA_TYPE_VIDEO && + av_frame_get_side_data(frame, AV_FRAME_DATA_LCEVC); + + if (dc->lcevc_frame) { + dc->width = frame->width; + dc->height = frame->height; + frame->width = frame->width * 2 / FFMAX(frame->sample_aspect_ratio.den, 1); + frame->height = frame->height * 2 / FFMAX(frame->sample_aspect_ratio.num, 1); + } +} + +static void attach_post_process_data(AVCodecContext *avctx, AVFrame *frame) +{ + AVCodecInternal *avci = avctx->internal; + DecodeContext *dc = decode_ctx(avci); + + if (dc->lcevc_frame) { + FrameDecodeData *fdd = (FrameDecodeData*)frame->private_ref->data; + + fdd->post_process_opaque = ff_refstruct_ref(dc->lcevc); + fdd->post_process_opaque_free = ff_lcevc_unref; + fdd->post_process = ff_lcevc_process; + + frame->width = dc->width; + frame->height = dc->height; + } + dc->lcevc_frame = 0; +} + int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) { const FFHWAccel *hwaccel = ffhwaccel(avctx->hwaccel); @@ -1640,8 +1680,10 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) ret = hwaccel->alloc_frame(avctx, frame); goto end; } - } else + } else { avctx->sw_pix_fmt = avctx->pix_fmt; + update_frame_props(avctx, frame); + } ret = avctx->get_buffer2(avctx, frame, flags); if (ret < 0) @@ -1653,6 +1695,8 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) if (ret < 0) goto fail; + attach_post_process_data(avctx, frame); + end: if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && !override_dimensions && !(ffcodec(avctx->codec)->caps_internal & FF_CODEC_CAP_EXPORTS_CROPPING)) { @@ -1953,6 +1997,12 @@ int ff_decode_preinit(AVCodecContext *avctx) if (ret < 0) return ret; + if (!(avctx->export_side_data & AV_CODEC_EXPORT_DATA_ENHANCEMENTS)) { + ret = ff_lcevc_alloc(&dc->lcevc); + if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE)) + return ret; + } + #if FF_API_DROPCHANGED if (avctx->flags & AV_CODEC_FLAG_DROPCHANGED) av_log(avctx, AV_LOG_WARNING, "The dropchanged flag is deprecated.\n"); @@ -2187,3 +2237,16 @@ AVCodecInternal *ff_decode_internal_alloc(void) { return av_mallocz(sizeof(DecodeContext)); } + +void ff_decode_internal_sync(AVCodecContext *dst, const AVCodecContext *src) +{ + ff_refstruct_replace(&decode_ctx(dst->internal)->lcevc, + decode_ctx(src->internal)->lcevc); +} + +void ff_decode_internal_uninit(AVCodecInternal *avci) +{ + DecodeContext *dc = decode_ctx(avci); + + ff_refstruct_unref(&dc->lcevc); +} diff --git a/libavcodec/lcevcdec.c b/libavcodec/lcevcdec.c new file mode 100644 index 0000000000..9dcc2c4afc --- /dev/null +++ b/libavcodec/lcevcdec.c @@ -0,0 +1,318 @@ +/* + * 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 "config_components.h" + +#include "libavutil/avassert.h" +#include "libavutil/frame.h" +#include "libavutil/imgutils.h" +#include "libavutil/log.h" +#include "libavutil/mem.h" +#include "decode.h" +#include "lcevcdec.h" + +#if CONFIG_LIBLCEVC_DEC +static LCEVC_ColorFormat map_format(int format) +{ + switch (format) { + case AV_PIX_FMT_YUV420P: + return LCEVC_I420_8; + case AV_PIX_FMT_YUV420P10: + return LCEVC_I420_10_LE; + case AV_PIX_FMT_NV12: + return LCEVC_NV12_8; + case AV_PIX_FMT_NV21: + return LCEVC_NV21_8; + case AV_PIX_FMT_GRAY8: + return LCEVC_GRAY_8; + } + + return LCEVC_ColorFormat_Unknown; +} + +static int alloc_base_frame(void *logctx, LCEVC_DecoderHandle decoder, + const AVFrame *frame, LCEVC_PictureHandle *picture) +{ + LCEVC_PictureDesc desc; + LCEVC_ColorFormat fmt = map_format(frame->format); + LCEVC_PictureLockHandle lock; + uint8_t *data[4] = { NULL }; + int linesizes[4] = { 0 }; + uint32_t planes; + LCEVC_ReturnCode res; + + res = LCEVC_DefaultPictureDesc(&desc, fmt, frame->width, frame->height); + if (res != LCEVC_Success) + return AVERROR_EXTERNAL; + + desc.cropTop = frame->crop_top; + desc.cropBottom = frame->crop_bottom; + desc.cropLeft = frame->crop_left; + desc.cropRight = frame->crop_right; + desc.sampleAspectRatioNum = frame->sample_aspect_ratio.num; + desc.sampleAspectRatioDen = frame->sample_aspect_ratio.den; + + /* Allocate LCEVC Picture */ + res = LCEVC_AllocPicture(decoder, &desc, picture); + if (res != LCEVC_Success) { + return AVERROR_EXTERNAL; + } + res = LCEVC_LockPicture(decoder, *picture, LCEVC_Access_Write, &lock); + if (res != LCEVC_Success) + return AVERROR_EXTERNAL; + + res = LCEVC_GetPicturePlaneCount(decoder, *picture, &planes); + if (res != LCEVC_Success) + return AVERROR_EXTERNAL; + + for (unsigned i = 0; i < planes; i++) { + LCEVC_PicturePlaneDesc plane; + + res = LCEVC_GetPictureLockPlaneDesc(decoder, lock, i, &plane); + if (res != LCEVC_Success) + return AVERROR_EXTERNAL; + + data[i] = plane.firstSample; + linesizes[i] = plane.rowByteStride; + } + + av_image_copy2(data, linesizes, frame->data, frame->linesize, + frame->format, frame->width, frame->height); + + res = LCEVC_UnlockPicture(decoder, lock); + if (res != LCEVC_Success) + return AVERROR_EXTERNAL; + + return 0; +} + +static int alloc_enhanced_frame(void *logctx, LCEVC_DecoderHandle decoder, + const AVFrame *frame, LCEVC_PictureHandle *picture) +{ + LCEVC_PictureDesc desc ; + LCEVC_ColorFormat fmt = map_format(frame->format); + LCEVC_PicturePlaneDesc planes[4] = { 0 }; + int width = frame->width * 2 / FFMAX(frame->sample_aspect_ratio.den, 1); + int height = frame->height * 2 / FFMAX(frame->sample_aspect_ratio.num, 1); + LCEVC_ReturnCode res; + + res = LCEVC_DefaultPictureDesc(&desc, fmt, width, height); + if (res != LCEVC_Success) + return AVERROR_EXTERNAL; + + /* Set plane description */ + for (int i = 0; i < 4; i++) { + planes[i].firstSample = frame->data[i]; + planes[i].rowByteStride = frame->linesize[i]; + } + + /* Allocate LCEVC Picture */ + res = LCEVC_AllocPictureExternal(decoder, &desc, NULL, planes, picture); + if (res != LCEVC_Success) { + return AVERROR_EXTERNAL; + } + return 0; +} + +static int lcevc_send_frame(void *logctx, FFLCEVCContext *lcevc, const AVFrame *in) +{ + const AVFrameSideData *sd = av_frame_get_side_data(in, AV_FRAME_DATA_LCEVC); + LCEVC_PictureHandle picture; + LCEVC_ReturnCode res; + int ret = 0; + + if (!sd) + return 1; + + res = LCEVC_SendDecoderEnhancementData(lcevc->decoder, in->pts, 0, sd->data, sd->size); + if (res != LCEVC_Success) + return AVERROR_EXTERNAL; + + ret = alloc_base_frame(logctx, lcevc->decoder, in, &picture); + if (ret < 0) + return ret; + + res = LCEVC_SendDecoderBase(lcevc->decoder, in->pts, 0, picture, -1, NULL); + if (res != LCEVC_Success) + return AVERROR_EXTERNAL; + + memset(&picture, 0, sizeof(picture)); + ret = alloc_enhanced_frame(logctx, lcevc->decoder, in, &picture); + if (ret < 0) + return ret; + + res = LCEVC_SendDecoderPicture(lcevc->decoder, picture); + if (res != LCEVC_Success) + return AVERROR_EXTERNAL; + + return 0; +} + +static int generate_output(void *logctx, FFLCEVCContext *lcevc, AVFrame *out) +{ + LCEVC_PictureDesc desc; + LCEVC_DecodeInformation info; + LCEVC_PictureHandle picture; + LCEVC_ReturnCode res; + + res = LCEVC_ReceiveDecoderPicture(lcevc->decoder, &picture, &info); + if (res != LCEVC_Success) + return AVERROR_EXTERNAL; + + res = LCEVC_GetPictureDesc(lcevc->decoder, picture, &desc); + if (res != LCEVC_Success) + return AVERROR_EXTERNAL; + + out->crop_top = desc.cropTop; + out->crop_bottom = desc.cropBottom; + out->crop_left = desc.cropLeft; + out->crop_right = desc.cropRight; + out->sample_aspect_ratio.num = desc.sampleAspectRatioNum; + out->sample_aspect_ratio.den = desc.sampleAspectRatioDen; + out->width = desc.width + out->crop_left + out->crop_right; + out->height = desc.height + out->crop_top + out->crop_bottom; + + res = LCEVC_FreePicture(lcevc->decoder, picture); + if (res != LCEVC_Success) + return AVERROR_EXTERNAL; + + return 0; +} + +static int lcevc_receive_frame(void *logctx, FFLCEVCContext *lcevc, AVFrame *out) +{ + LCEVC_PictureHandle picture; + LCEVC_ReturnCode res; + int ret; + + ret = generate_output(logctx, lcevc, out); + if (ret < 0) + return ret; + + while (1) { + res = LCEVC_ReceiveDecoderBase (lcevc->decoder, &picture); + if (res != LCEVC_Success && res != LCEVC_Again) + return AVERROR_EXTERNAL; + + if (res == LCEVC_Again) + break; + + res = LCEVC_FreePicture(lcevc->decoder, picture); + if (res != LCEVC_Success) + return AVERROR_EXTERNAL; + } + + return 0; +} + +static void event_callback(LCEVC_DecoderHandle dec, LCEVC_Event event, + LCEVC_PictureHandle pic, const LCEVC_DecodeInformation *info, + const uint8_t *data, uint32_t size, void *logctx) +{ + switch (event) { + case LCEVC_Log: + av_log(logctx, AV_LOG_INFO, "%s\n", data); + break; + default: + break; + } +} + +static void lcevc_free(FFRefStructOpaque unused, void *obj) +{ + FFLCEVCContext *lcevc = obj; + if (lcevc->initialized) + LCEVC_DestroyDecoder(lcevc->decoder); + memset(lcevc, 0, sizeof(*lcevc)); +} +#endif + +static int lcevc_init(FFLCEVCContext *lcevc, void *logctx) +{ +#if CONFIG_LIBLCEVC_DEC + LCEVC_AccelContextHandle dummy = { 0 }; +#endif + + if (lcevc->initialized) + return 0; + +#if CONFIG_LIBLCEVC_DEC + if (LCEVC_CreateDecoder(&lcevc->decoder, dummy) != LCEVC_Success) { + av_log(logctx, AV_LOG_ERROR, "Failed to create LCEVC decoder\n"); + return AVERROR_EXTERNAL; + } + + LCEVC_ConfigureDecoderInt(lcevc->decoder, "log_level", 4); + LCEVC_ConfigureDecoderInt(lcevc->decoder, "events", LCEVC_Log); + LCEVC_SetDecoderEventCallback(lcevc->decoder, event_callback, logctx); + + if (LCEVC_InitializeDecoder(lcevc->decoder) != LCEVC_Success) { + av_log(logctx, AV_LOG_ERROR, "Failed to initialize LCEVC decoder\n"); + LCEVC_DestroyDecoder(lcevc->decoder); + return AVERROR_EXTERNAL; + } + +#endif + lcevc->initialized = 1; + + return 0; +} + +int ff_lcevc_process(void *logctx, AVFrame *frame) +{ + FrameDecodeData *fdd = (FrameDecodeData*)frame->private_ref->data; + FFLCEVCContext *lcevc = fdd->post_process_opaque; + int ret; + + if (!lcevc->initialized) { + ret = lcevc_init(lcevc, logctx); + if (ret < 0) + return ret; + } + +#if CONFIG_LIBLCEVC_DEC + ret = lcevc_send_frame(logctx, lcevc, frame); + if (ret) + return ret < 0 ? ret : 0; + + lcevc_receive_frame(logctx, lcevc, frame); + if (ret < 0) + return ret; + + av_frame_remove_side_data(frame, AV_FRAME_DATA_LCEVC); +#endif + + return 0; +} + +int ff_lcevc_alloc(FFLCEVCContext **plcevc) +{ + FFLCEVCContext *lcevc = NULL; +#if CONFIG_LIBLCEVC_DEC + lcevc = ff_refstruct_alloc_ext(sizeof(*lcevc), 0, NULL, lcevc_free); + if (!lcevc) + return AVERROR(ENOMEM); +#endif + *plcevc = lcevc; + return 0; +} + +void ff_lcevc_unref(void *opaque) +{ + ff_refstruct_unref(&opaque); +} diff --git a/libavcodec/lcevcdec.h b/libavcodec/lcevcdec.h new file mode 100644 index 0000000000..7334d3a645 --- /dev/null +++ b/libavcodec/lcevcdec.h @@ -0,0 +1,42 @@ +/* + * 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_LCEVCDEC_H +#define AVCODEC_LCEVCDEC_H + +#include "config_components.h" + +#include +#if CONFIG_LIBLCEVC_DEC +#include +#else +typedef uintptr_t LCEVC_DecoderHandle; +#endif +#include "refstruct.h" + +typedef struct FFLCEVCContext { + LCEVC_DecoderHandle decoder; + int initialized; +} FFLCEVCContext; + +struct AVFrame; + +int ff_lcevc_alloc(FFLCEVCContext **plcevc); +int ff_lcevc_process(void *logctx, struct AVFrame *frame); +void ff_lcevc_unref(void *opaque); +#endif /* AVCODEC_LCEVCDEC_H */ diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index 019e33b7b2..87d796fd90 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -406,6 +406,7 @@ FF_ENABLE_DEPRECATION_WARNINGS dst->hwaccel_flags = src->hwaccel_flags; ff_refstruct_replace(&dst->internal->pool, src->internal->pool); + ff_decode_internal_sync(dst, src); } if (for_user) { @@ -782,6 +783,7 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count) ff_refstruct_unref(&ctx->internal->pool); av_packet_free(&ctx->internal->in_pkt); av_packet_free(&ctx->internal->last_pkt_props); + ff_decode_internal_uninit(ctx->internal); av_freep(&ctx->internal); av_buffer_unref(&ctx->hw_frames_ctx); av_frame_side_data_free(&ctx->decoded_side_data, @@ -845,6 +847,7 @@ static av_cold int init_thread(PerThreadContext *p, int *threads_to_free, copy->internal = ff_decode_internal_alloc(); if (!copy->internal) return AVERROR(ENOMEM); + ff_decode_internal_sync(copy, avctx); copy->internal->thread_ctx = p; copy->internal->progress_frame_pool = avctx->internal->progress_frame_pool; From patchwork Thu Sep 12 17:07:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 51553 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:14c:b0:48e:c0f8:d0de with SMTP id h12csp1229709vqi; Thu, 12 Sep 2024 16:04:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVzT3naIAuCKThdZmxQNYhkMbqejV8tSWLC4XiTV7la2f8wM2VPpgGp0aV4rZ57NofAMCE6ZD/WVXy3VKInZ1YI@gmail.com X-Google-Smtp-Source: AGHT+IFh7SE6DME1aPquzeuRndF69X/L7ChzOvnwFntfgjwmuezUJVPu2AqG+dL2CK/UUWOk3rZY X-Received: by 2002:a05:6512:224f:b0:52f:c13f:23d2 with SMTP id 2adb3069b0e04-53678fbf051mr2951372e87.25.1726182251416; Thu, 12 Sep 2024 16:04:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726182251; cv=none; d=google.com; s=arc-20240605; b=k8s5/lEz8Vn81FGlD+buiKzLYfHA83I7zQE9XaaALVhamzCdPMbnl3wYeckzh6Ypuh cfslVueUjQ+1lnFy99+2NEgNGNOHNrwe2d8F67u6xaJPTYorxewwmcMSVq0AM6/d9HLN sxD3WMxtL7sg/YFiCm5nY6LBr1Zz6VEMXNMwq66AkA2aIPEigDd5w9Bv3+bbHcP/qfCE GuV7L74YQ4DJOSi+PEU3jTNDZYez/NtNVzjdUTqwxYM8jAr2PgzEwG98YDzoMPbXtjcl mUmLsl7pn9AYTxoaUBhTEL5qsFvS15BOCOsrWcqKxcmCtVa321b721e/CiBhrQ149yDw JTvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=0m3QMFtefE2QEDm1mNfJN1Kc8tIlSNQDm5lEWZALkm8=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=hsdqErIcKTlHc1ELUXHAjyDUzcjKVwrRyVTEQ2VKPtc+GBoumfsnVJMFmeMApTjMaf BOXQJbaXSS3npbwJMYSfRc9a/KZJa5GmBQw0D5tDEQh4xJJjaiB4YPcBbq4BXjdlybU7 Cfijqmw0gnSbED8cTD5gFmlfUTWlkK3PnOW2wkslqehsxKJtx9jKge7K+FPwZSZSqFTB yponzJZoXadaMKYnR3AKedurSoRG3LJnfxhYRJ4e0eJcCL6IpJvNNLXUn6m17u+C+0ZX urDGYtR6QnJ9QNbFvwD3Wk1MzfFUVLUeVjRGWY569sTWua+N9FXOLXsmK5vuhZXhgHGO x3uw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=AFnH6dvO; 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=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 2adb3069b0e04-5365f86ecd8si4249778e87.152.2024.09.12.16.04.10; Thu, 12 Sep 2024 16:04:11 -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=@gmail.com header.s=20230601 header.b=AFnH6dvO; 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=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 444B668D90F; Thu, 12 Sep 2024 20:08:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1B39468D90F for ; Thu, 12 Sep 2024 20:08:17 +0300 (EEST) Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-20573eb852aso15853795ad.1 for ; Thu, 12 Sep 2024 10:08:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726160894; x=1726765694; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Ye2R+UR32u9bpw4QvVcBcZeM2MbezvhiJk8pWWleon8=; b=AFnH6dvO91vhIPukUlnyxuABaWUlZ0i8LAd7VLkPmi+8qbLR15QSyUJKn91MsdQQAH 4c3ds0bom20IFfRfmNB0SERAoHcjAEfWWS7ycZDNU2SL2mUGLbhY1aDOPO/MRYI50oqR ymHNqSbgBLqm7uoVfMRQHcb/iFv5D2meVs1pDbqJBfMMFEuCQYw7+SHzUf85Rs4zA1yW AOnDCKw/x4rWBhu6qioh7kTaSijdMomngb3Ehl1zLG2tx9CN7MUCf3QDnTBnQ5FpYtRj ke/0sA8ulkJSlRZ6Mvg9xi2iq0IfEaiPE0P+mRrYCvn0bIKORtCFv5+T31al3I2EXrp0 OFMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726160894; x=1726765694; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ye2R+UR32u9bpw4QvVcBcZeM2MbezvhiJk8pWWleon8=; b=SlWcJ26OjtvQTd7zYHIlkn24qdydLQfbEsUNIdh4AW8jNu2G2bpaQSn8qPqVOMXdro wMHIi1N06E47whOWKFNJrOb4fSo3eGVnJrwN/nLfRHrRrC3Cjz9sgN7eggkwU61AKDCY S+oxdZjnPY22baVEuu2XPmhJlswzK6uAjuRFWqWYY0AvAOcxH53IObGZSt12Ih3DSvwe BrWyKaPzdzc3otBp0LqYBnp7hEslKHlgVdjDYIDkzlrN0DaFtUSWhWCKiGVtF+rmX6c9 aAwMn63TkbE17YEK5EWTyWi6QRA2Tpc78SmX50gcrPwi2mndhPO4m2yiPH+PbZoS+ePA OrlQ== X-Gm-Message-State: AOJu0YyrJx6/8kezDau3M9mj9GFDtz/EW6FFdDWt8CNVad89ZJtW9SfW kbj2OfMrMzneQ+/5w25iST3UdtDfr8NA6KUhUcEfTTDwCNjJbwahGILv+Q== X-Received: by 2002:a17:902:db05:b0:205:5c06:39e6 with SMTP id d9443c01a7336-2074c3b43b4mr136041035ad.0.1726160893650; Thu, 12 Sep 2024 10:08:13 -0700 (PDT) Received: from localhost.localdomain ([181.92.233.116]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2076afe9198sm16379125ad.198.2024.09.12.10.08.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 10:08:13 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Thu, 12 Sep 2024 14:07:53 -0300 Message-ID: <20240912170753.1961-1-jamrial@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912005925.10151-1-jamrial@gmail.com> References: <20240912005925.10151-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/11] avfilter: add an LCEVC decoding filter via LCEVCdec X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: TrN3vCQ9vl6F Signed-off-by: James Almer --- configure | 1 + libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/version.h | 4 +- libavfilter/vf_lcevc.c | 434 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 439 insertions(+), 2 deletions(-) create mode 100644 libavfilter/vf_lcevc.c diff --git a/configure b/configure index e528714735..e88f4490b4 100755 --- a/configure +++ b/configure @@ -3891,6 +3891,7 @@ identity_filter_select="scene_sad" interlace_filter_deps="gpl" kerndeint_filter_deps="gpl" ladspa_filter_deps="ladspa libdl" +lcevc_filter_deps="liblcevc_dec" lensfun_filter_deps="liblensfun version3" libplacebo_filter_deps="libplacebo vulkan" lv2_filter_deps="lv2" diff --git a/libavfilter/Makefile b/libavfilter/Makefile index ac6a8d5783..91487afb21 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -360,6 +360,7 @@ OBJS-$(CONFIG_INTERLEAVE_FILTER) += f_interleave.o OBJS-$(CONFIG_KERNDEINT_FILTER) += vf_kerndeint.o OBJS-$(CONFIG_KIRSCH_FILTER) += vf_convolution.o OBJS-$(CONFIG_LAGFUN_FILTER) += vf_lagfun.o +OBJS-$(CONFIG_LCEVC_FILTER) += vf_lcevc.o OBJS-$(CONFIG_LATENCY_FILTER) += f_latency.o OBJS-$(CONFIG_LENSCORRECTION_FILTER) += vf_lenscorrection.o OBJS-$(CONFIG_LENSFUN_FILTER) += vf_lensfun.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 8e7d912c9f..9819f0f95b 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -337,6 +337,7 @@ extern const AVFilter ff_vf_kerndeint; extern const AVFilter ff_vf_kirsch; extern const AVFilter ff_vf_lagfun; extern const AVFilter ff_vf_latency; +extern const AVFilter ff_vf_lcevc; extern const AVFilter ff_vf_lenscorrection; extern const AVFilter ff_vf_lensfun; extern const AVFilter ff_vf_libplacebo; diff --git a/libavfilter/version.h b/libavfilter/version.h index d8cd8a2cfb..7e0eb9af97 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -31,8 +31,8 @@ #include "version_major.h" -#define LIBAVFILTER_VERSION_MINOR 2 -#define LIBAVFILTER_VERSION_MICRO 102 +#define LIBAVFILTER_VERSION_MINOR 3 +#define LIBAVFILTER_VERSION_MICRO 100 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ diff --git a/libavfilter/vf_lcevc.c b/libavfilter/vf_lcevc.c new file mode 100644 index 0000000000..843692cf40 --- /dev/null +++ b/libavfilter/vf_lcevc.c @@ -0,0 +1,434 @@ +/* + * This file is part of FFmpeg. + * + * Copyright (c) 2024 James Almer + * + * 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 "libavutil/internal.h" +#include "libavutil/opt.h" +#include "filters.h" +#include "video.h" + +typedef struct LCEVCContext { + LCEVC_DecoderHandle decoder; + LCEVC_PictureHandle base; + int w, h; +} LCEVCContext; + +static LCEVC_ColorFormat map_format(int format) +{ + switch (format) { + case AV_PIX_FMT_YUV420P: + return LCEVC_I420_8; + case AV_PIX_FMT_YUV420P10: + return LCEVC_I420_10_LE; + case AV_PIX_FMT_NV12: + return LCEVC_NV12_8; + case AV_PIX_FMT_NV21: + return LCEVC_NV21_8; + case AV_PIX_FMT_GRAY8: + return LCEVC_GRAY_8; + case AV_PIX_FMT_GRAY10LE: + return LCEVC_GRAY_10_LE; + } + + return LCEVC_ColorFormat_Unknown; +} + +static inline LCEVC_ColorRange map_range(int range) +{ + switch (range) { + case AVCOL_RANGE_MPEG: + return LCEVC_ColorRange_Limited; + case AVCOL_RANGE_JPEG: + return LCEVC_ColorRange_Full; + } + + return LCEVC_ColorRange_Unknown; +} + +static inline enum AVColorRange map_av_range(int range) +{ + switch (range) { + case LCEVC_ColorRange_Limited: + return AVCOL_RANGE_MPEG; + case LCEVC_ColorRange_Full: + return AVCOL_RANGE_JPEG; + } + + return AVCOL_RANGE_UNSPECIFIED; +} + +static int alloc_base_frame(AVFilterLink *inlink, const AVFrame *in, + LCEVC_PictureHandle *picture) +{ + AVFilterContext *ctx = inlink->dst; + LCEVCContext *lcevc = ctx->priv; + LCEVC_PictureDesc desc; + LCEVC_PicturePlaneDesc planes[AV_VIDEO_MAX_PLANES] = { 0 }; + LCEVC_ColorFormat fmt = map_format(in->format); + int width = in->width - in->crop_left - in->crop_right; + int height = in->height - in->crop_top - in->crop_bottom; + LCEVC_ReturnCode res; + + res = LCEVC_DefaultPictureDesc(&desc, fmt, width, height); + if (res != LCEVC_Success) { + av_log(ctx, AV_LOG_ERROR, "LCEVC_DefaultPictureDesc failed\n"); + return AVERROR_EXTERNAL; + } + + for (int i = 0; i < AV_VIDEO_MAX_PLANES; i++) { + planes[i].firstSample = in->data[i]; + planes[i].rowByteStride = in->linesize[i]; + } + + desc.cropTop = in->crop_top; + desc.cropBottom = in->crop_bottom; + desc.cropLeft = in->crop_left; + desc.cropRight = in->crop_right; + desc.sampleAspectRatioNum = in->sample_aspect_ratio.num; + desc.sampleAspectRatioDen = in->sample_aspect_ratio.den; + desc.colorRange = map_range(in->color_range); + desc.colorPrimaries = (LCEVC_ColorPrimaries)in->color_primaries; + desc.matrixCoefficients = (LCEVC_MatrixCoefficients)in->colorspace; + desc.transferCharacteristics = (LCEVC_TransferCharacteristics)in->color_trc; + av_log(ctx, AV_LOG_DEBUG, "in PTS %"PRId64", %dx%d, " + "%"SIZE_SPECIFIER"/%"SIZE_SPECIFIER"/%"SIZE_SPECIFIER"/%"SIZE_SPECIFIER", " + "SAR %d:%d\n", + in->pts, in->width, in->height, + in->crop_top, in->crop_bottom, in->crop_left, in->crop_right, + in->sample_aspect_ratio.num, in->sample_aspect_ratio.den); + + res = LCEVC_AllocPictureExternal(lcevc->decoder, &desc, NULL, planes, picture); + if (res != LCEVC_Success) { + av_log(ctx, AV_LOG_ERROR, "LCEVC_AllocPictureExternal to allocate a buffer for a base frame\n"); + return AVERROR_EXTERNAL; + } + + return 0; +} + +static int send_frame(AVFilterLink *inlink, AVFrame *in) +{ + AVFilterContext *ctx = inlink->dst; + LCEVCContext *lcevc = ctx->priv; + const AVFrameSideData *sd = av_frame_get_side_data(in, AV_FRAME_DATA_LCEVC); + LCEVC_ReturnCode res; + int ret; + + ret = alloc_base_frame(inlink, in, &lcevc->base); + if (ret < 0) + return ret; + + if (sd) { + res = LCEVC_SendDecoderEnhancementData(lcevc->decoder, in->pts, 0, sd->data, sd->size); + if (res == LCEVC_Again) + return AVERROR(EAGAIN); + else if (res != LCEVC_Success) { + av_log(ctx, AV_LOG_ERROR, "LCEVC_SendDecoderEnhancementData failed\n"); + return AVERROR_EXTERNAL; + } + } + + res = LCEVC_SendDecoderBase(lcevc->decoder, in->pts, 0, lcevc->base, -1, in); + memset(&lcevc->base, 0, sizeof(lcevc->base)); + if (res != LCEVC_Success) { + av_log(ctx, AV_LOG_ERROR, "LCEVC_SendDecoderBase failed\n"); + return AVERROR_EXTERNAL; + } + + return 0; +} + +static int alloc_enhanced_frame(AVFilterLink *inlink, const AVFrame *out, + LCEVC_PictureHandle *picture) +{ + AVFilterContext *ctx = inlink->dst; + LCEVCContext *lcevc = ctx->priv; + LCEVC_PictureDesc desc; + LCEVC_PicturePlaneDesc planes[AV_VIDEO_MAX_PLANES] = { 0 }; + LCEVC_ColorFormat fmt = map_format(out->format); + LCEVC_ReturnCode res; + + res = LCEVC_DefaultPictureDesc(&desc, fmt, out->width, out->height); + if (res != LCEVC_Success) + return AVERROR_EXTERNAL; + + for (int i = 0; i < AV_VIDEO_MAX_PLANES; i++) { + planes[i].firstSample = out->data[i]; + planes[i].rowByteStride = out->linesize[i]; + } + + res = LCEVC_AllocPictureExternal(lcevc->decoder, &desc, NULL, planes, picture); + if (res != LCEVC_Success) { + av_log(ctx, AV_LOG_ERROR, "LCEVC_AllocPictureExternal to allocate a buffer for an enhanced frame\n"); + return AVERROR_EXTERNAL; + } + + return 0; +} + +static int generate_output(AVFilterLink *inlink, AVFrame *out) +{ + AVFilterContext *ctx = inlink->dst; + AVFilterLink *outlink = ctx->outputs[0]; + LCEVCContext *lcevc = ctx->priv; + LCEVC_PictureDesc desc; + LCEVC_DecodeInformation info; + LCEVC_PictureHandle picture; + LCEVC_ReturnCode res; + + res = LCEVC_ReceiveDecoderPicture(lcevc->decoder, &picture, &info); + if (res == LCEVC_Again) { + int64_t pts; + int status; + if (ff_inlink_acknowledge_status(inlink, &status, &pts)) { + av_frame_free(&out); + ff_outlink_set_status(outlink, status, pts); + return 0; + } + // this shouldn't be reachable, but instead of asserting, just error out + return AVERROR_BUG; + } else if (res != LCEVC_Success) { + av_log(ctx, AV_LOG_ERROR, "LCEVC_ReceiveDecoderPicture failed\n"); + return AVERROR_EXTERNAL; + } + + av_frame_copy_props(out, (AVFrame *)info.baseUserData); + av_frame_remove_side_data(out, AV_FRAME_DATA_LCEVC); + + av_frame_free((AVFrame **)&info.baseUserData); + + res = LCEVC_GetPictureDesc(lcevc->decoder, picture, &desc); + LCEVC_FreePicture(lcevc->decoder, picture); + if (res != LCEVC_Success) { + av_log(ctx, AV_LOG_ERROR, "LCEVC_GetPictureDesc failed\n"); + return AVERROR_EXTERNAL; + } + + out->crop_top = desc.cropTop; + out->crop_bottom = desc.cropBottom; + out->crop_left = desc.cropLeft; + out->crop_right = desc.cropRight; + out->sample_aspect_ratio.num = outlink->sample_aspect_ratio.num = desc.sampleAspectRatioNum; + out->sample_aspect_ratio.den = outlink->sample_aspect_ratio.den = desc.sampleAspectRatioDen; + out->color_range = map_range(desc.colorRange); + out->color_primaries = (enum AVColorPrimaries)desc.colorPrimaries; + out->colorspace = (enum AVColorSpace)desc.matrixCoefficients; + out->color_trc = (enum AVColorTransferCharacteristic)desc.transferCharacteristics; + out->width = outlink->w = desc.width + out->crop_left + out->crop_right; + out->height = outlink->h = desc.height + out->crop_top + out->crop_bottom; + + av_log(ctx, AV_LOG_VERBOSE, "out PTS %"PRId64", %dx%d, " + "%"SIZE_SPECIFIER"/%"SIZE_SPECIFIER"/%"SIZE_SPECIFIER"/%"SIZE_SPECIFIER", " + "SAR %d:%d, " + "hasEnhancement %d, enhanced %d\n", + out->pts, out->width, out->height, + out->crop_top, out->crop_bottom, out->crop_left, out->crop_right, + out->sample_aspect_ratio.num, out->sample_aspect_ratio.den, + info.hasEnhancement, info.enhanced); + + return ff_filter_frame(outlink, out); +} + +static int receive_frame(AVFilterLink *inlink, AVFrame *out) +{ + AVFilterContext *ctx = inlink->dst; + LCEVCContext *lcevc = ctx->priv; + LCEVC_PictureHandle picture; + LCEVC_ReturnCode res; + int ret; + + ret = alloc_enhanced_frame(inlink, out, &picture); + if (ret < 0) + return ret; + + res = LCEVC_SendDecoderPicture(lcevc->decoder, picture); + if (res != LCEVC_Success) { + av_log(ctx, AV_LOG_ERROR, "LCEVC_SendDecoderPicture failed\n"); + return AVERROR_EXTERNAL; + } + + return generate_output(inlink, out); +} + +static int config_props(AVFilterLink *outlink) +{ + AVFilterContext *ctx = outlink->src; + AVFilterLink *inlink = ctx->inputs[0]; + LCEVCContext *lcevc = ctx->priv; + + outlink->w = lcevc->w = inlink->w * 2 / FFMAX(inlink->sample_aspect_ratio.den, 1); + outlink->h = lcevc->h = inlink->h * 2 / FFMAX(inlink->sample_aspect_ratio.den, 1); + outlink->sample_aspect_ratio = (AVRational) { 0, 1 }; + + return 0; +} + +static void flush_bases(AVFilterContext *ctx) +{ + LCEVCContext *lcevc = ctx->priv; + LCEVC_PictureHandle picture; + + while (LCEVC_ReceiveDecoderBase(lcevc->decoder, &picture) == LCEVC_Success) + LCEVC_FreePicture(lcevc->decoder, picture); +} + +static int activate(AVFilterContext *ctx) +{ + LCEVCContext *lcevc = ctx->priv; + AVFilterLink *inlink = ctx->inputs[0]; + AVFilterLink *outlink = ctx->outputs[0]; + AVFrame *in, *out; + int status, ret; + + FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink); + + ret = ff_inlink_consume_frame(inlink, &in); + if (ret < 0) + return ret; + if (!ret) { + int64_t pts; + if (ff_inlink_acknowledge_status(inlink, &status, &pts)) { + if (!status) + ff_outlink_set_status(outlink, status, pts); + } + if (!status) + FF_FILTER_FORWARD_WANTED(outlink, inlink); + } + + if (in) { + if (in->width != inlink->w || + in->height != inlink->h || + in->sample_aspect_ratio.den != inlink->sample_aspect_ratio.den || + in->sample_aspect_ratio.num != inlink->sample_aspect_ratio.num) { + inlink->dst->inputs[0]->w = in->width; + inlink->dst->inputs[0]->h = in->height; + inlink->dst->inputs[0]->sample_aspect_ratio.den = in->sample_aspect_ratio.den; + inlink->dst->inputs[0]->sample_aspect_ratio.num = in->sample_aspect_ratio.num; + + config_props(outlink); + } + + ret = send_frame(inlink, in); + if (ret < 0) + return ret; + } + + out = ff_get_video_buffer(outlink, lcevc->w, lcevc->h); + if (!out) + return AVERROR(ENOMEM); + + ret = receive_frame(inlink, out); + if (ret < 0) { + av_frame_free(&out); + return ret; + } + + flush_bases(ctx); + + return ret; +} + +static void log_callback(LCEVC_DecoderHandle dec, LCEVC_Event event, + LCEVC_PictureHandle pic, const LCEVC_DecodeInformation *info, + const uint8_t *data, uint32_t size, void *logctx) +{ + if (event != LCEVC_Log) // shouldn't happen + return; + + if (strlen(data) != size) // sanitize input + return; + + av_log(logctx, AV_LOG_INFO, "LCEVC Log: %s\n", data); +} + +static av_cold int init(AVFilterContext *ctx) +{ + LCEVCContext *lcevc = ctx->priv; + LCEVC_AccelContextHandle dummy = { 0 }; + const int32_t event = LCEVC_Log; + LCEVC_ReturnCode res; + + res = LCEVC_CreateDecoder(&lcevc->decoder, dummy); + if (res != LCEVC_Success) { + av_log(ctx, AV_LOG_ERROR, "LCEVC_CreateDecoder failed\n"); + return AVERROR_EXTERNAL; + } + + res = LCEVC_ConfigureDecoderInt(lcevc->decoder, "log_level", 4); + if (res != LCEVC_Success) { + av_log(ctx, AV_LOG_ERROR, "LCEVC_ConfigureDecoderInt failed to set \"log_level\"\n"); + return AVERROR_EXTERNAL; + } + res = LCEVC_ConfigureDecoderIntArray(lcevc->decoder, "events", 1, &event); + if (res != LCEVC_Success) { + av_log(ctx, AV_LOG_ERROR, "LCEVC_ConfigureDecoderIntArray failed to set \"events\"\n"); + return AVERROR_EXTERNAL; + } + res = LCEVC_SetDecoderEventCallback(lcevc->decoder, log_callback, ctx); + if (res != LCEVC_Success) { + av_log(ctx, AV_LOG_ERROR, "LCEVC_SetDecoderEventCallback failed\n"); + return AVERROR_EXTERNAL; + } + + res = LCEVC_InitializeDecoder(lcevc->decoder); + if (res != LCEVC_Success) { + av_log(ctx, AV_LOG_ERROR, "LCEVC_InitializeDecoder failed\n"); + return AVERROR_EXTERNAL; + } + + return 0; +} + +static av_cold void uninit(AVFilterContext *ctx) +{ + LCEVCContext *lcevc = ctx->priv; + + LCEVC_DestroyDecoder(lcevc->decoder); +} + +static const AVFilterPad lcevc_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .config_props = config_props, + }, +}; + +static const enum AVPixelFormat pix_fmts[] = { + AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV420P10LE, + AV_PIX_FMT_NV12, AV_PIX_FMT_NV21, + AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY10LE, + AV_PIX_FMT_NONE +}; + +const AVFilter ff_vf_lcevc = { + .name = "lcevc", + .description = NULL_IF_CONFIG_SMALL("LCEVC"), + .activate = activate, + FILTER_INPUTS(ff_video_default_filterpad), + FILTER_OUTPUTS(lcevc_outputs), + FILTER_PIXFMTS_ARRAY(pix_fmts), + .priv_size = sizeof(LCEVCContext), + .init = init, + .uninit = uninit, +};