From patchwork Fri Mar 31 16:21:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 40950 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp851335pzb; Fri, 31 Mar 2023 09:22:26 -0700 (PDT) X-Google-Smtp-Source: AKy350Y6DjhFPiAd5FZ1WmCkkPjCSAjUCwJYrt6jXaZ/FrdSu228sDxXlEgyShunBOYsUIWe2dRh X-Received: by 2002:aa7:c9d6:0:b0:4f9:db7b:b6b4 with SMTP id i22-20020aa7c9d6000000b004f9db7bb6b4mr22878370edt.40.1680279746512; Fri, 31 Mar 2023 09:22:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680279746; cv=none; d=google.com; s=arc-20160816; b=AoIY58US2w1IlTXKm4TgWfuyAN28Gtg50Xgaq99PNA4XzhCrhMuZMfRySHucCzuSq3 RGiYJV/Yu7VS33WliyDOyAFb7PVESbH8JBGwU64I2MGABpp2X+1mISrdxjNQoXYCNzfO hVNoIG9X4KM/jt2eqrohF1d7akfMOl+azWSpK9ePgRO+LmzzNu0wpjbR+o6xtMYtQiqp EE6pPbhyjvgIAeTHiZ7piYHfWxDmVpWWvmlS4zAzG3e79nhkvq87ZUBCmHyo9WYl0LZC XBm0+eHUSiuQ+uymVBXcedPTS1cGJnvj869qE6KvNWNHAc90QjHN/KCqMoHZDv1/JBPN K/GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=6FLG2IiGAFRZo3b8fM6sOx6IXescEkC0oXV91n9aGBE=; b=Fxu6lYn12ROszm/XY+oiThJefDCX6E6SQVTHwfwlbtvoDCCGY+XaDYWJLeckdSqAZ6 O4sswmxSoNYuSMMeIGpblxvJcydDwS2zwoRpKQX4XkMCzVk4DwkNOazZE7tyM9LRuRpF 7BmMkJPT5E7PxPRZ4+QYpA27SpLNZuiCEXSaUO80HHhEY7SS66SfNMZTlxa4tVPif1Dv 4/7z/GfKJSRZGShY9vm9GX3KxwC2DNxpPCY10gfdR1Dhkxo+BgIZ0qXbS9wzhTmbow/I CKqtff/0prJUSmlGnWLn5EivhZxV2+M5Ge6sDR7CdXZ3WDSoapvqOzRS+btbMir6kE0D WUcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="OMsGU/1b"; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n23-20020aa7c697000000b004ced100b0b7si2452218edq.316.2023.03.31.09.22.25; Fri, 31 Mar 2023 09:22:26 -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=20210112 header.b="OMsGU/1b"; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8D15D68C2C9; Fri, 31 Mar 2023 19:22:22 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0A84568C223 for ; Fri, 31 Mar 2023 19:22:16 +0300 (EEST) Received: by mail-lf1-f54.google.com with SMTP id g19so16497426lfr.9 for ; Fri, 31 Mar 2023 09:22:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680279735; 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=BN7enfIf0HCbAs2y7G/7eFy1943JJze0MzseIPYJsoc=; b=OMsGU/1bkZsEPcdBPcXi2jEgRTkR7RefzT0+wjK0WdapnLOPXywtEjv2bQZd91qFOo 6IXcgX8hC0WZz+ipN+cWeXTRWd5yUjGdpt0A5QaeacZCMi3INzD8mmaUh10H9a0mVAUJ YVAgIjxW0/fsKKdxxK2XP1KjjQ8TPnDuvwu3p//wcx5cyv4X2zE9gf7n/sDJj4chQKAB CMYm41skTzajc2butihy4ajgOnpIbzg+9Hn3IZ/ByX897HzQqxnUS7YP4JSNPhw/oYx5 6t49au/b8WEPD+Y/1eyfn/PqFeJsOBSNVvZ4RACHJG5sE/yrL6/pCnx632xx5xjfZ1Ml RpAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680279735; 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=BN7enfIf0HCbAs2y7G/7eFy1943JJze0MzseIPYJsoc=; b=Nd8NKGxcdwke5kwMc1DpqJgsmr32wxA/N7LTHBXYpbAFJn4+WI0UOHf0bQ5Gj6aqx3 zYvquAk9KNuyxBMk2rwJtZRtWQXWCVUr4TqXQ+7OJrZ6s2NPlmD34LzvTG+vC3xlntrc OpJ0mlI56nqNjF+DoLXOUQ+s5A40K7o/UbmzaH+1pmsJWNZgDAX5o2zt7P4klwzGiJZe qsZOByUqP1SfhG00u3G2MZ8cBcUZVs2e8EIhBU62dCNLzMJAWtU/gyPBFEDYxHWk0ls3 0e88SMtQj4BuAq0MBRVTtBeZ4YRqCZcA5lZGvQ6nWALCgC5dUL9rHrIuqDeU2k9e/FPM /L5w== X-Gm-Message-State: AAQBX9dTioV4Ami7YHibDirMy2s5yVmUYk1BIz5yPed4S6SDtBZPrGql tItGtzh34RDwWs35iT8xORNMiCsaAkA= X-Received: by 2002:ac2:59c6:0:b0:4e9:5f90:748 with SMTP id x6-20020ac259c6000000b004e95f900748mr8079708lfn.9.1680279734840; Fri, 31 Mar 2023 09:22:14 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id n20-20020a2e8794000000b0029573844d03sm411483lji.109.2023.03.31.09.22.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Mar 2023 09:22:14 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 31 Mar 2023 19:21:54 +0300 Message-Id: <20230331162205.428735-2-jeebjp@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230331162205.428735-1-jeebjp@gmail.com> References: <20230331162205.428735-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v1 01/12] avutil/frame: add AVFrameSideDataSet for passing sets of side 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: yFiSUicSWM8z --- libavutil/frame.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libavutil/frame.h b/libavutil/frame.h index 5b58c14ac3..45024c2a03 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -241,6 +241,14 @@ typedef struct AVFrameSideData { AVBufferRef *buf; } AVFrameSideData; +/** + * Structure to hold a set of AVFrameSideData + */ +typedef struct AVFrameSideDataSet { + AVFrameSideData **side_data; + int nb_side_data; +} AVFrameSideDataSet; + /** * Structure describing a single Region Of Interest. * From patchwork Fri Mar 31 16:21:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 40952 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp851647pzb; Fri, 31 Mar 2023 09:22:53 -0700 (PDT) X-Google-Smtp-Source: AKy350YiMGEN9MRCBKXOFa1Z7LjnQAqyUDj4937pze5NRMwieD0Y00OXD37Hkd2fz+VDdtqGe+SD X-Received: by 2002:aa7:c490:0:b0:4fa:315a:cb55 with SMTP id m16-20020aa7c490000000b004fa315acb55mr28820068edq.21.1680279773208; Fri, 31 Mar 2023 09:22:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680279773; cv=none; d=google.com; s=arc-20160816; b=GVBR7MkUzdHbOTxAKUJ2YgtcwFO1on6Vss/8ctsV1d0v7YUQU/uVq/IAQ7UieFGy7e dLsbyMKXebN15Sx35kl/HbqoxYCl3zh6ibORpg59cJE5WNH+7DUjMXblFQ/RPiQwahJ3 gWzhEPhCXL+Ae+mcLxQWVoM41eosd2FJ4BI6WpY10JHYcNwRRehnQtj6UIPPO1l2VbiS sDL0mSPlEf1SYsv21psJYNStSlCtMLee6tCZLcjorI2mdiUBl89vZ1PeiGY//lDSZvhX cZ4eKmANdGluHhxIBzjTe8Zrnf8MjSGkX+kiQ+QPy7SyFSX6C0b4ILcP+nEWtKM9KBRT Eh1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=LS47aM0TguAWhKDF1I/i5kWVI1wnYsjWG1QAG2WVlE0=; b=InwiWocYb7amLVHyfYDsloyNqwWNy3AM6IEfZBO8AqOZCOZqZbQ2XmMDsc51Z+w//f BAcSNAYsfI+xDW/6royuMKxl9kA9jIMrTCiCPtPJScMYBROCKytmDTkkm0fAEO7IGdXE /RXAJ5ZnKjPS4intRxfAkgO59IMtgw3TsD8NyXrYp1/Ci2mEltsFi0BCjUyM2EEyvRgV qG5pJaRbyCnv4LZRNugg18kijQlowQd3eYx0hfGI9XMp7h9ikc+ZWcPdq8OgrEr1fOcg uvORKVfPaqUcOiNory3Ci+DtaGeKF2osOJfi6A1uIz+JZNx7n0mqsyvytXB6iun7/KoQ hxFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=d9LPhDLx; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n8-20020a056402514800b004bd1a7dba86si446297edd.410.2023.03.31.09.22.52; Fri, 31 Mar 2023 09:22:53 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=d9LPhDLx; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1A49B68C303; Fri, 31 Mar 2023 19:22:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5253568C283 for ; Fri, 31 Mar 2023 19:22:16 +0300 (EEST) Received: by mail-lj1-f171.google.com with SMTP id a44so4975841ljr.10 for ; Fri, 31 Mar 2023 09:22:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680279735; 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=JWrL5L2Awwi8EyK5S5G0YfWizUrCXnEw0SdKnzbf4xA=; b=d9LPhDLx9undcNxWnT9p/lIwMSwdt8oOHAFb423IF8k+gCpP2zenroLV80/D7Qbp9b QwPt4APoYHsZvZqHIB9ZBvACkSided3FCSIf3sYfbyGauKQKIi44+WposAEgRMybC+yR nPXTQKYKuG/DSyXcM0ER7GIBOSHdGZfOdGj+guDZPN9JVZl5D7dyzW5R+lWuHUNwO//E 9fE4PFZParE0MWm/mF5OBp+TqqQ6SUmOALFsGH843dDjPXPqbMNBY16LXqEUFK7ycJf6 1PlKOeN0ETFaXuwRj5GnJG5MkKxI2iOTDxULbAmX1gC+EhMvzu0Rt2QjVpmMcBop7EXJ GN7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680279735; 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=JWrL5L2Awwi8EyK5S5G0YfWizUrCXnEw0SdKnzbf4xA=; b=SDmSyb+Su5un7Mh9tlJz4OG/SLoVP9Ui4Klf9obu/mt8osZdN6pFesKxK0Lqb7zrwR P4v+NlhAhR19cp4QWOV0gJQ7/GJxUgHFL9hnHGX8l6HNsH8xl68uyhZy7qd81Kv8Kbd9 flp3N3VnGjIz4Ey6pd8YK6ZtZYlonXd6fxPVvs4Fut3TwGQNVNIdxS/SMSakj7eLbPTq sDpMiHwoFvgNWJlCrLZzuAo5nPCroqlkiqLcSWu201bdGShUbbcEPg+0UPfKP9V5pRRq OnS1KacU/t1UKHn43T5ZdMKkPvOAbZlrOADgvGpjoYUk6+DLGlQvrbKSX8F8YC+Pmf12 sdFw== X-Gm-Message-State: AAQBX9cWE/8tgudybUMHL+iQko+ZV5YPizvrQANKQz3tgQs0r6YW4hG4 U8Kp8Z/pxk9KTt8IDuVfRjGkc4A+J8A= X-Received: by 2002:a2e:9d82:0:b0:2a6:1780:7700 with SMTP id c2-20020a2e9d82000000b002a617807700mr1972234ljj.1.1680279735190; Fri, 31 Mar 2023 09:22:15 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id n20-20020a2e8794000000b0029573844d03sm411483lji.109.2023.03.31.09.22.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Mar 2023 09:22:14 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 31 Mar 2023 19:21:55 +0300 Message-Id: <20230331162205.428735-3-jeebjp@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230331162205.428735-1-jeebjp@gmail.com> References: <20230331162205.428735-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v1 02/12] avutil/frame: split side data list wiping out to non-AVFrame function 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: bWYiRE3mDn/i --- libavutil/frame.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index c905e8d611..019613e4d2 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -76,14 +76,18 @@ static void free_side_data(AVFrameSideData **ptr_sd) av_freep(ptr_sd); } -static void wipe_side_data(AVFrame *frame) +static void wipe_side_data(AVFrameSideData ***sd, int *nb_side_data) { - for (int i = 0; i < frame->nb_side_data; i++) { - free_side_data(&frame->side_data[i]); + for (int i = 0; i < *nb_side_data; i++) { + free_side_data(&((*sd)[i])); } - frame->nb_side_data = 0; + *nb_side_data = 0; + + av_freep(sd); +} - av_freep(&frame->side_data); +static void wipe_side_data_from_frame(AVFrame *frame) { + wipe_side_data(&frame->side_data, &frame->nb_side_data); } AVFrame *av_frame_alloc(void) @@ -326,7 +330,7 @@ FF_ENABLE_DEPRECATION_WARNINGS sd_dst = av_frame_new_side_data(dst, sd_src->type, sd_src->size); if (!sd_dst) { - wipe_side_data(dst); + wipe_side_data_from_frame(dst); return AVERROR(ENOMEM); } memcpy(sd_dst->data, sd_src->data, sd_src->size); @@ -335,7 +339,7 @@ FF_ENABLE_DEPRECATION_WARNINGS sd_dst = av_frame_new_side_data_from_buf(dst, sd_src->type, ref); if (!sd_dst) { av_buffer_unref(&ref); - wipe_side_data(dst); + wipe_side_data_from_frame(dst); return AVERROR(ENOMEM); } } @@ -486,7 +490,7 @@ void av_frame_unref(AVFrame *frame) if (!frame) return; - wipe_side_data(frame); + wipe_side_data_from_frame(frame); for (int i = 0; i < FF_ARRAY_ELEMS(frame->buf); i++) av_buffer_unref(&frame->buf[i]); From patchwork Fri Mar 31 16:21:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 40951 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp851446pzb; Fri, 31 Mar 2023 09:22:36 -0700 (PDT) X-Google-Smtp-Source: AKy350Z7JJQP3AQDTbGiVr+FJV+Nw7YHBcy5eYTqaRBNC+vFoz66rvv/G0GXlKD3wHuh/OaDYXzK X-Received: by 2002:a17:906:d1cf:b0:8b1:7aaa:4c25 with SMTP id bs15-20020a170906d1cf00b008b17aaa4c25mr29559629ejb.29.1680279756302; Fri, 31 Mar 2023 09:22:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680279756; cv=none; d=google.com; s=arc-20160816; b=BB/fRfMvZb9/ZRVzp5eL0pRSEpX5Mom28QCbTvjTkl1gXAC/GFkFUxtopZImGh5slN 7bJx9CtPvpcf+CdiRWcVoDGhPXUix36nNPQJ0IKmyTdinbJmATID35oJDK+iHOsxyKVo 7lJL4p6coUBKxgxhdoMv2EyNI+sNXUatCa8Cz1lFJ0FJ0LZnzJNaSbO9tXo8qZu4WdRs 7cIimkikVpX29q7rdqKSR1joLs4mWCqS+ce9bB+n0wiYS5EXxPNXZyefOqcQ4cNqto+m 3ibeJkK1cTJVjLPqgHdqCjxzn/Mv7rrEH9wWxXcC6d4DUr0CK1Ts1n56a8cZmWgSScb1 +IoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=wX3rr1iWFEUwJ3NItpCW6XDtTFMvnlLs4l5exZ57ND0=; b=KPADKFKYvjmYX6G8Nnu+ydpsqu5ClnwUqinqZFbFtC3ezC+bFuUlSp1Yi1ONuDDe4v Hafnhv93VuR1SkHbAxLjgbUi5lWkWMbv1XH1P3Hpc39jaDd7C+rZJfFHutTTtZ1ndYky FOe10ymkSR2BkARC3tj5QKCl4wWB5ZLTUHb/MpxAUfsAxsq0CzBYlRsHALUblpZyMbMY 6I6TCxa1ZMRUFkH75unPF/Imb7t1ZJaIlfwxQDnSTRhcgc4odnuUSeDiemv1hE+VJVEn gFI8rBq4fxbeseqGbOJJPzdWz+FuUOCIBRkb6SopiIYOfe1k8FSSb3jTEA73j38xyXdR LXig== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=SysfUkLJ; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n11-20020a170906724b00b00930e86db8fdsi2374245ejk.938.2023.03.31.09.22.35; Fri, 31 Mar 2023 09:22:36 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=SysfUkLJ; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7AB1268C297; Fri, 31 Mar 2023 19:22:23 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 555E768C284 for ; Fri, 31 Mar 2023 19:22:16 +0300 (EEST) Received: by mail-lj1-f181.google.com with SMTP id a44so4975851ljr.10 for ; Fri, 31 Mar 2023 09:22:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680279735; 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=0vWrCyv5hu+6hIf6tp1WEqHZn8YLv75Q99828DGTiIs=; b=SysfUkLJtEBjhjkm2azTDneADDjUOnD6fxBeSdN1kXtka0BD3/Sk6l2e2NfcHIKGqA Rw4FVpS/WXmjsTlYR2NjPWclxvaL3b1SA2vNOsuOcGgfr1TEtvCobGtgJAF3Cd6hiyMd HtHvlcpDdnu/UdohG1k//hV9qbehivKjTOqU7Y5k/iE3GsS+fIGy+kcSMVZl7hf48OE4 HAeVSV6TkPfwScLV3nmzNe79D/kY4PaTQCQvTnDnDgo/9I2Bfc31NpK3PnPav6Sip8vH lCQzHxu0jogU00g1A7UBsouBBYZr/AQG8c+6OJg6hEUGdPPytuqSOU8f0gRmxuZUJJxt VSWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680279735; 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=0vWrCyv5hu+6hIf6tp1WEqHZn8YLv75Q99828DGTiIs=; b=BuS3DMuzEne236/ro0WCm9KsnkA2MYmHhY2lcKN+UhX25eMzCkTFDtfThuKVWeMoEP IeMj3lPXYvsoVRGhlrVd2XVKLs7Zv+flz7GvwSAmFWbHOKOmVN4zMpIzHZ4b8S5oN64r En+1lN518qfhnGWqiRm0WM/PGH8G4J6olspPqe17ASFLcWI05Ysqdz38TA7OF+zDG4Bc 3zODgv5hN6ivWcwUtk8RmZO2YIEq+kdSN9ZTZIrOcGVQFDSWiRekkmAnecCE6jfYF8W1 FhryPJhXj5gsBzqvlxyW5YiYosP+o4peaq/705jIUNLQMeGyeeyQu8fN3sYwRyCyTwsy 8EZw== X-Gm-Message-State: AAQBX9efFlORjbGvvFiguNDV9hZg1R0eCG+y1/BlHoTG07YYEbsE3GpW t37dV71Lm9BUmufhnJRYk9D91sBopso= X-Received: by 2002:a2e:b0c6:0:b0:2a2:ada:d70a with SMTP id g6-20020a2eb0c6000000b002a20adad70amr8641358ljl.7.1680279735612; Fri, 31 Mar 2023 09:22:15 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id n20-20020a2e8794000000b0029573844d03sm411483lji.109.2023.03.31.09.22.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Mar 2023 09:22:15 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 31 Mar 2023 19:21:56 +0300 Message-Id: <20230331162205.428735-4-jeebjp@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230331162205.428735-1-jeebjp@gmail.com> References: <20230331162205.428735-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v1 03/12] avutil/frame: add helper for clearing out side data sets 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: hGKIQbdgiMtk --- libavutil/frame.c | 5 +++++ libavutil/frame.h | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/libavutil/frame.c b/libavutil/frame.c index 019613e4d2..24038cc0fa 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -90,6 +90,11 @@ static void wipe_side_data_from_frame(AVFrame *frame) { wipe_side_data(&frame->side_data, &frame->nb_side_data); } +void av_side_data_set_wipe(AVFrameSideDataSet *set) +{ + wipe_side_data(&set->side_data, &set->nb_side_data); +} + AVFrame *av_frame_alloc(void) { AVFrame *frame = av_malloc(sizeof(*frame)); diff --git a/libavutil/frame.h b/libavutil/frame.h index 45024c2a03..734ac3fe75 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -991,6 +991,13 @@ int av_frame_apply_cropping(AVFrame *frame, int flags); */ const char *av_frame_side_data_name(enum AVFrameSideDataType type); +/** + * Clear all side data from a side data set + * + * @param set the set which should be cleared + */ +void av_side_data_set_wipe(AVFrameSideDataSet *set); + /** * @} */ From patchwork Fri Mar 31 16:21:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 40953 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp851719pzb; Fri, 31 Mar 2023 09:23:01 -0700 (PDT) X-Google-Smtp-Source: AKy350ZYyOvorZOd1RhfKbVBtuQbzYWq+c84bhOK/lz3Lf4zbaGbqgI4bqtdsBUMMHQLXhcggk9o X-Received: by 2002:a05:6402:2027:b0:4fd:1f7b:9fbd with SMTP id ay7-20020a056402202700b004fd1f7b9fbdmr9587066edb.6.1680279781592; Fri, 31 Mar 2023 09:23:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680279781; cv=none; d=google.com; s=arc-20160816; b=0LR1FnzAePr+I2jXBWyhc+e8orNeQJ0p5U2BnEj8GWrYtwn3Y79F/4nQfa8nSK9I03 lSi1cpHONqmsYJUlLjeOjiSE2H8G3qve/mhZAUF1yUTnfO8nVAq9azJkRGJV9626wCy2 adwT+GedtpcWFrOwjBnnx2gP7y/pWmJ873hu36gnSez2RoUZ7RntBd9scV7fUk7XGvGq HS9jwtIdcG3G0jsd1GYIBp8EZDATu2791NW9LQxDMi1MCPPfcxNIzuEGSAJKKX24BQ/Y Xkk5KhL/43zAoNnwOiTj+5iCXRPTCENYInujaWVA+LfqwCqEa7ltqzrb3zb3kpluspDv 30uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=+Cjch5dmkBnNtSbGU2z1a5ZdKOvv+AjeiEfSe9FIpEg=; b=k5PJ2h0tRm7ytdT5Y8XxspnzirhRc/1mAQrWiUHS7d+drW6Lf+shbLBi/KC2SBZRbw HmK5Bga/2juJeVRPBb1JX404casx1gQ+tRl9dT5OTV/MwJtXlrFqZP0NmbpPY3Y3JS7T 6qvCJagbVNbWPM65XaT9Y1pT+MmKFW9td3HBtFY3sZ6FXbESpkkTXlSHxjfHsD3rj25a V0G8oFADXAZO108YjajCFfGNRCMdMPfr5udXjB9tR1FJg8V/mRWNZfMJTj39OpIo2Sjt rLJWj1M0rxXp1KA6YykRMzcYTrBxPLyQCWTGavepsxjcBBtvM6B2y+30wbiuFVtPaTFB UDng== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=OK1CWTKB; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n13-20020a056402060d00b004acd2bb0015si2373358edv.346.2023.03.31.09.23.01; Fri, 31 Mar 2023 09:23:01 -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=20210112 header.b=OK1CWTKB; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0646268C30E; Fri, 31 Mar 2023 19:22:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D2A0B68C282 for ; Fri, 31 Mar 2023 19:22:16 +0300 (EEST) Received: by mail-lj1-f182.google.com with SMTP id x20so23602126ljq.9 for ; Fri, 31 Mar 2023 09:22:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680279736; 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=oGm3z9HAZvdROOvpvc/CCFyByzV9Mm1Tc8AJQSIbiRc=; b=OK1CWTKBG6EJyP22gOyTAggyfgAX8Dtfe1WzKORCAyi/jeboh0NeYwgv9pLr0YY1Bo aLpFtLZxmBFyvwmMPI8a1/AQMgnVJL/CxA9/Mx5uFkV7t/ZM2d8IuRRO3RaUHFTEdzNv Qzqg9UatVvPIdL8poiDFozCY+x0HwpoXHksyBWOmnpZP3nYymARG7y+4IPFavKlNh0c9 SWY1ZgmAaBOLjZ++JgEZ/8Dr2QxbQFviWi9gx/1Uq2bjQIhFf3NVPC3/+8H2cpwAbPWg Zl2qUBtERAVgRH5bre363koeR5N+5WviDirPctFzn/902cwlLCI3aDpvYtIOECDOJx8r 9mNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680279736; 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=oGm3z9HAZvdROOvpvc/CCFyByzV9Mm1Tc8AJQSIbiRc=; b=GgLMBy8V6oZUVHUlt9+6qJmMlMwILEtLX+A06T5nGMH+RiKi2QVPmDO65ps6yMooyK OikSMyrEHMeqAoeCG+/YNmH5QpNJhWhLsZRux9NYsTl/DE6d6Dz7yJx9baAQo2UXln5m zPDPSBQoUvF42x92Yua1zQ36RggSlzHuPjisVYYkzOoFYSEpSiQbUmitFalnd5Q+lMge G1eu3wm8W6StY2b394f20x5y0PWgQvW8xZAdd6Cku2tSqvDiisWAG4C6f7+s5eaXqJce DY9cMyU5LPnNykd3dMnioQQ72asPkv9Fh1M2mwMC7kIc5xv8zrAmvCFr5H256RPGKNex IC6w== X-Gm-Message-State: AAQBX9fJAoG303AtnFhRSR+OHj1rIrOTKC4GDQR/g4BgLS5T6Xn10Ihs wVMxOZCXJVYPrzUwGsWJzo/GxnnQTDs= X-Received: by 2002:a2e:b16e:0:b0:28b:6525:e6b1 with SMTP id a14-20020a2eb16e000000b0028b6525e6b1mr2866273ljm.24.1680279736008; Fri, 31 Mar 2023 09:22:16 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id n20-20020a2e8794000000b0029573844d03sm411483lji.109.2023.03.31.09.22.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Mar 2023 09:22:15 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 31 Mar 2023 19:21:57 +0300 Message-Id: <20230331162205.428735-5-jeebjp@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230331162205.428735-1-jeebjp@gmail.com> References: <20230331162205.428735-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v1 04/12] avutil/frame: split side_data_from_buf to base and AVFrame func 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: jX6d+trgCdWn --- libavutil/frame.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 24038cc0fa..ab1a4e7f6a 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -648,23 +648,23 @@ FF_ENABLE_DEPRECATION_WARNINGS return NULL; } -AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame, - enum AVFrameSideDataType type, - AVBufferRef *buf) +static AVFrameSideData *add_side_data_to_set_from_buf(AVFrameSideDataSet *set, + enum AVFrameSideDataType type, + AVBufferRef *buf) { AVFrameSideData *ret, **tmp; if (!buf) return NULL; - if (frame->nb_side_data > INT_MAX / sizeof(*frame->side_data) - 1) + if (set->nb_side_data > INT_MAX / sizeof(*set->side_data) - 1) return NULL; - tmp = av_realloc(frame->side_data, - (frame->nb_side_data + 1) * sizeof(*frame->side_data)); + tmp = av_realloc(set->side_data, + (set->nb_side_data + 1) * sizeof(*set->side_data)); if (!tmp) return NULL; - frame->side_data = tmp; + set->side_data = tmp; ret = av_mallocz(sizeof(*ret)); if (!ret) @@ -675,7 +675,23 @@ AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame, ret->size = buf->size; ret->type = type; - frame->side_data[frame->nb_side_data++] = ret; + set->side_data[set->nb_side_data++] = ret; + + return ret; +} + +AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame, + enum AVFrameSideDataType type, + AVBufferRef *buf) +{ + AVFrameSideDataSet set = { + .side_data = frame->side_data, + .nb_side_data = frame->nb_side_data, + }; + AVFrameSideData *ret = add_side_data_to_set_from_buf(&set, type, buf); + + frame->side_data = set.side_data; + frame->nb_side_data = set.nb_side_data; return ret; } From patchwork Fri Mar 31 16:21:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 40954 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp851820pzb; Fri, 31 Mar 2023 09:23:10 -0700 (PDT) X-Google-Smtp-Source: AKy350bcWWnPsim21qWopwX1vX8R5PlC1QrB53R+UNiJVlIrA6xnFjUrzZfa4rs8i9sfT2dTQPnY X-Received: by 2002:a17:906:b2d2:b0:93e:fa12:aa1a with SMTP id cf18-20020a170906b2d200b0093efa12aa1amr28104282ejb.1.1680279790677; Fri, 31 Mar 2023 09:23:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680279790; cv=none; d=google.com; s=arc-20160816; b=EfhWHDf1AoWaELz5n3ayQDmdzU5XXMC0UdCWf1IQfOLYk3zbjfSnPYzYdVJCzTtcX5 1CUDDzvudRHWvlAEBoFnxXDmZRNurKjH8za+pgjNT62i8oWb3viR3Zyu9dNPntsfjejD gJbn2ufNACww//sFodm1ZE3nZNSGDhMLst8PjS6nwhQ+5DrsZ4NXD1uHd6bU1+wr+nvT 4OMfGTCwWEkRECruVfUHKO+b9SRUEOQhWdZARb5x30IpnS6Iea8UJzc60Hz/FfCUx4is EAfYfbssXYSDzrfqRxln5BZwI0BQo0doc4On9ulo7LVVrBIx/jkm8oJfbdzBDlGznBJc dVwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=z6b0VUjnM8eAW6/Uehm1b7sO2rJK60TCQh47zcnchhs=; b=Q9E3JRW+STEWSmTqZaUVanOHge4uTqz6YHEXstVRj2M9D3JFsX3V0Rh7V7gk8LLswM Huec9LIl7WDLmhvsh9EB6RYhv9BCOvX8IwrsTCH3ufCp8jQikaE1Bf4bMuq6OZzmIZfX zadpmFNnSq7etbM3zgZt96NB73mYUjzb/27jgY1OJSzLgRSSR8aATRGCOCK4a0FQOD0S 0RYxqBevUNu+MFoxhfRVd9yCzR4kCnam72QLRW+X7PCmiwd7CHpYX3iyZdCWmt2wJZ0n gKpF2RWILwschcHXyoi/wL0Hs6I+a/omnR01kcBXPINDeQzFdFa2oU4DPmjRoC4Ix3/a pt0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=AwGxXKDj; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id v5-20020a1709060b4500b009212a3f8496si119551ejg.666.2023.03.31.09.23.10; Fri, 31 Mar 2023 09:23: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=20210112 header.b=AwGxXKDj; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 23C6368C32E; Fri, 31 Mar 2023 19:22:28 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2657E68C28B for ; Fri, 31 Mar 2023 19:22:17 +0300 (EEST) Received: by mail-lj1-f175.google.com with SMTP id a11so23613594lji.6 for ; Fri, 31 Mar 2023 09:22:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680279736; 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=8rEEYYVIS3CMaaYCT1jYvirXrRc+Efmzaab7J0siwFQ=; b=AwGxXKDj1azusr4ldEEFpj6jZvtRoei3fYuW1dZ15wbkriLRA+ti0TZDnJGkfvsdko JQFAP3o2+lvIZnbs0K2qcs+M/J7vp2i8/cX+QaEA9BjI5mbt64kuX7YkvaxD8dfU7GOg zCf7xDA2SPu+tj3ftOP/oi7w/mwNxD8cxgPE7qw5mHpCUlV0k3J3IuReKmxI9axmN+mP UZDp2xYPW95yxQ4c/DbFtEOrWu4dkdsX2cTgowqap7esYaBvyu9Z7vcSnzRTG26illCE 247Z1tNSwHyBQfIIbib1Rdcg+BPWQ6DNvgQOBie+5viK+DQmz7bmKB16L7zYhxJ+H2MS F48g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680279736; 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=8rEEYYVIS3CMaaYCT1jYvirXrRc+Efmzaab7J0siwFQ=; b=m0HYCOsFJBpelS/fICimM9b3nTZv8m5FbBAyrnpidyVkqewnD6210vKF1XWtwk3XUa xajY4fIDl6Gwx6nBqbfpmZdK5qfuLy09OHoB4tJ26tbqntxxes0dOx3OKzWKE3Ym6S/j dqwZ9tWBssUVDeOXSytEyyeOaeC1oTQ9L/7aSVXBz2jkLeD7MlUN8KUOz81z2bqfStJ4 IaT/dVzNpsA0NccKOCnd7KydHmD4xr+ci+DEJNd4KBqfVLmbVJvGt9uNthpL6GYPjT0Z kp4riTnmNKMAS/XSaxVpaaQVhFPNH7GqaUU19YdULKz9N2qD3QsEMpHvAUCLcPYQ9ajx fpZg== X-Gm-Message-State: AAQBX9eePzi4c5h6SG31vToItYymBhFg1B5vXbWoKBKT+YAr0d++dzI8 4ooi9RigysVVFIKttdXBGOEAShRXpjc= X-Received: by 2002:a2e:9cc9:0:b0:299:bb73:fcd4 with SMTP id g9-20020a2e9cc9000000b00299bb73fcd4mr8305163ljj.7.1680279736402; Fri, 31 Mar 2023 09:22:16 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id n20-20020a2e8794000000b0029573844d03sm411483lji.109.2023.03.31.09.22.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Mar 2023 09:22:16 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 31 Mar 2023 19:21:58 +0300 Message-Id: <20230331162205.428735-6-jeebjp@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230331162205.428735-1-jeebjp@gmail.com> References: <20230331162205.428735-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v1 05/12] avutil/frame: add helper for adding side data to set 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: hW4/d7HjQCVi --- libavutil/frame.c | 12 ++++++++++++ libavutil/frame.h | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/libavutil/frame.c b/libavutil/frame.c index ab1a4e7f6a..29e9b631f8 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -708,6 +708,18 @@ AVFrameSideData *av_frame_new_side_data(AVFrame *frame, return ret; } + +AVFrameSideData *av_new_side_data_to_set(AVFrameSideDataSet *set, + enum AVFrameSideDataType type, + size_t size) +{ + AVBufferRef *buf = av_buffer_alloc(size); + AVFrameSideData *ret = add_side_data_to_set_from_buf(set, type, buf); + if (!ret) + av_buffer_unref(&buf); + return ret; +} + AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type) { diff --git a/libavutil/frame.h b/libavutil/frame.h index 734ac3fe75..167a8f0ff6 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -998,6 +998,19 @@ const char *av_frame_side_data_name(enum AVFrameSideDataType type); */ void av_side_data_set_wipe(AVFrameSideDataSet *set); +/** + * Add a new side data entry to a set. + * + * @param set a set to which the side data should be added + * @param type type of the added side data + * @param size size of the side data + * + * @return newly added side data on success, NULL on error + */ +AVFrameSideData *av_new_side_data_to_set(AVFrameSideDataSet *set, + enum AVFrameSideDataType type, + size_t size); + /** * @} */ From patchwork Fri Mar 31 16:21:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 40955 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp851920pzb; Fri, 31 Mar 2023 09:23:19 -0700 (PDT) X-Google-Smtp-Source: AKy350Y4vS0cmo1gmDCbc2C2rp+Y8z0lysxqYF0HDsErbVZTCxq49QoX6jjkS8pJF/ur1ErYR2cK X-Received: by 2002:aa7:d885:0:b0:4fd:2155:74ef with SMTP id u5-20020aa7d885000000b004fd215574efmr27630587edq.19.1680279798952; Fri, 31 Mar 2023 09:23:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680279798; cv=none; d=google.com; s=arc-20160816; b=l/Csq1EXqnEk9rWiiOWK6+/am7LZkqezHANw1L0QJ+yjPtCnt2p9DLZGaKk9CvPszQ tequ5WqL1isiy2c+5KTADQIe7VpclF2VquDR0nDCDnjHyops0wck/vswii6y/tiDbqv7 Av7MyGOR7nJSRjcKyF0RFcm84pnRpMqlF6f0F9/PsFBvBskUdjCqX5TTlMar+jdYrkna ZWUfJmBGEozKRiJNjSvQDiCSYscVAdG5XsMRmuolzQ7mE1ZLedrsZhF1MJ9U8JwWQIi3 WvY7WIPFhLpI+6wVQJEiKdoluf0C2prKF2CpWXjtlasR5myfInraM8cQesCUHE7ZiGkM HW4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=nl0a9ujcefWUPm4wrYvtPk31fAYjPa93tT/cn33ruBM=; b=zI/EybmFY9OwsPa/YURP6y8A1HDRTjMeVC9JGztbjQSV9mESWRajpnkP7thMg3Njss pH7dmmsAX3HGHb9ew8Z7VdSJHVufa6aIiOZH3ctOfJB+PlK+AQwmyqOEwH34I08Inqwa eOK5UhRchEZszSPhPQisxcNIRhmE/9uTTooxoIR9q+seNDirtnd3U8K6DFxFTBTsiCeL 33n5MurWUgQNGIQM297yoiC41w+UleIpQx4Fl6xMkdVvq0gfpPGeAFfwBPYKSrcUdi24 4CFfPg91xzF0Nbns9RGAFrIBoVeq1SY8NrZgulQYhicZkPajLSxaY7yH5bP2bKUtZMDE uCRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=dknMA+J8; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a3-20020aa7cf03000000b004fb506ae6bfsi2380035edy.247.2023.03.31.09.23.18; Fri, 31 Mar 2023 09:23:18 -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=20210112 header.b=dknMA+J8; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1F7A268C32B; Fri, 31 Mar 2023 19:22:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6F76168C2A6 for ; Fri, 31 Mar 2023 19:22:17 +0300 (EEST) Received: by mail-lj1-f172.google.com with SMTP id x20so23602155ljq.9 for ; Fri, 31 Mar 2023 09:22:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680279736; 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=WmBGtDR4WahWX/AOvlMBMBpbmnm77KLt53cdeFx+uKE=; b=dknMA+J8wrxK1DjVkSqIw1yp8GXVpzSTDSh/+A4b6R05NEqoGQbvDWX1cHhLmBJhaT N/iLE6WK8dYQA+wg5yc/lHXgOgM0SqAE2ErStXrEooNxNPFN69p5hh/oUXl0Ti4t24fd 84AEivpR5CkDgvn+XW4jqCgfW1PVmdpO5xq4hgmKOoVW9rskGovsdIgKX8CH3J9RLIOa hpQThoqH7fjJ5BoEGBy4YUZJK4bnqvBaZbwSg29yV7iZiuoiyQTG4tXKpqEqRfMfnlCr r1/81CCRmaLduE8e9aB7yUmb8n6uHt2Ebx88wjbZDud/z4jevwglnvvI2VKpMvAk/IYm zg0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680279736; 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=WmBGtDR4WahWX/AOvlMBMBpbmnm77KLt53cdeFx+uKE=; b=sUdnlQwH4mZGsyYUrrQ/61GJ6Ka7hLiem0xX3z8XIU2sKTv+Xcm+a/YuGpNBrUnbAj /yDmlWx+8ojjz14BqkP23IOZFwSRFtM1wqBHB+ksHmBBlbqv/aCweB3p4MmhRYudKSDb B88273DZdmRCJoXmtwetE3orc9ILQZC/0VdesJ83PJAnxkoeOVmuederrUe+jppzv02X AT9ny5c1Vui4E+04zJEzV2Hq2nV+3VAbhomm+kOdIOipqsiSU2DyksVBKNm2V2QyYX4j IJLnprI/RSqznlCzjJQUYbjzUyl9QcsRx/YluOeP2G/tKTdQe/8ZyM2dfwBI/gilpKcB MvjA== X-Gm-Message-State: AAQBX9daa47jfbIvBWhNdHTgcz2KIWSNpK0tJg3syJNY7ICE/D40IUP3 3wxoWDMBAZ7LD/HcKyXRW/1lbfMH5jE= X-Received: by 2002:a2e:88ce:0:b0:2a5:fe8f:b450 with SMTP id a14-20020a2e88ce000000b002a5fe8fb450mr4665461ljk.47.1680279736754; Fri, 31 Mar 2023 09:22:16 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id n20-20020a2e8794000000b0029573844d03sm411483lji.109.2023.03.31.09.22.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Mar 2023 09:22:16 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 31 Mar 2023 19:21:59 +0300 Message-Id: <20230331162205.428735-7-jeebjp@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230331162205.428735-1-jeebjp@gmail.com> References: <20230331162205.428735-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v1 06/12] avutil/frame: add helper for getting side data from set 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: 2pPwQv//Ek1x --- libavutil/frame.c | 22 +++++++++++++++++----- libavutil/frame.h | 10 ++++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 29e9b631f8..3386cda627 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -720,16 +720,28 @@ AVFrameSideData *av_new_side_data_to_set(AVFrameSideDataSet *set, return ret; } -AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, - enum AVFrameSideDataType type) +AVFrameSideData *av_get_side_data_from_set(const AVFrameSideDataSet set, + enum AVFrameSideDataType type) { - for (int i = 0; i < frame->nb_side_data; i++) { - if (frame->side_data[i]->type == type) - return frame->side_data[i]; + for (int i = 0; i < set.nb_side_data; i++) { + if (set.side_data[i]->type == type) + return set.side_data[i]; } return NULL; } +AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, + enum AVFrameSideDataType type) +{ + return av_get_side_data_from_set( + (const AVFrameSideDataSet){ + .side_data = frame->side_data, + .nb_side_data = frame->nb_side_data + }, + type + ); +} + static int frame_copy_video(AVFrame *dst, const AVFrame *src) { const uint8_t *src_data[4]; diff --git a/libavutil/frame.h b/libavutil/frame.h index 167a8f0ff6..8aa50e3ad8 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -1011,6 +1011,16 @@ AVFrameSideData *av_new_side_data_to_set(AVFrameSideDataSet *set, enum AVFrameSideDataType type, size_t size); +/** + * @param set a set to which the side data should be added + * @param type type of the added side data + * + * @return a pointer to the side data of a given type on success, NULL if there + * is no side data with such type in this set. + */ +AVFrameSideData *av_get_side_data_from_set(const AVFrameSideDataSet set, + enum AVFrameSideDataType type); + /** * @} */ From patchwork Fri Mar 31 16:22:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 40956 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp852014pzb; Fri, 31 Mar 2023 09:23:28 -0700 (PDT) X-Google-Smtp-Source: AKy350axnxWHu6+xlPURVw8/ojl2nYwn+nyGf1xxTAW1/I5S7PihPBWrqZAEhmcc3j7HxESGFojV X-Received: by 2002:a17:906:9485:b0:933:c052:a277 with SMTP id t5-20020a170906948500b00933c052a277mr28119671ejx.12.1680279808205; Fri, 31 Mar 2023 09:23:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680279808; cv=none; d=google.com; s=arc-20160816; b=0elcTO0ET5vPa3sKBFaAJUD1dnB70HwsbY27fPnoeDSt/HCfSvKVkAB6u/lCyYn39h MMM+gJK6Ti08AjUhEMKE1ZcexcgTDOY/FL4nodNCsP3HIZPm5tdgm+XpPJS2/iPzcJSZ UCEgQnUPXmiOPuzwP8mq3Qp2hn2G3I80TfRix+pEEYSatWdhZfMdH7eXismpI1FvxO03 8MBO2YAg7xlDYbtT0IVJcY7CnK5MtyxrOLTwqAwG0iVDmIAn02pK750K8dqkil3eOceh FIJuJUxncrnc+FLxOl1DyDoVe0MJN3k0wlaTGMdq1OjRogTsuoOCe2Phj+2xhNXEyFgF GULg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=lg6F8WtWNLEm0GVCaRqRvtcjJWvhEis1KJsrUWUPpXs=; b=F7Nb61e9ikXifbdELDrTbVUbkYBKIbozWeF/5Ac9KKwm1CGKgtnY7Q6sHSLR/9AmEz ej8fDPuyzLI5NMsFaP1lBgB5d+D9GGF/xHSe1S3+Lg1Zv25PHr3gLVbmDZfxmE8p7GBP 9rOq31IiJ/CwSdpvFUu9bRFV/cCQ9/iun026U2aTdMbdolieIOpPX/KMvP3KaWM1f6LV 4EebZ0bGS2j8DKka7aHiM+76iiXGuOpQRaawv3ZG8p8QWGHkvH/lvJiijqNTlivJFmUM bui/z6Mpb8kINe6tID3xvU7rak8pOKen6uCcxaBbp2Sc1xY5gLg1s3ztA88p6Usp1Ne2 owUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="dqplRE/b"; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id bh10-20020a170906a0ca00b0093e5b108711si589848ejb.942.2023.03.31.09.23.27; Fri, 31 Mar 2023 09:23:28 -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=20210112 header.b="dqplRE/b"; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1C0B168C2DD; Fri, 31 Mar 2023 19:22:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AE0F768C2A6 for ; Fri, 31 Mar 2023 19:22:17 +0300 (EEST) Received: by mail-lj1-f181.google.com with SMTP id x20so23602170ljq.9 for ; Fri, 31 Mar 2023 09:22:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680279737; 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=Bsb3lmthOCc6e7au7gufgrFzapDq9oLtvGA3KaskcJo=; b=dqplRE/bpyPk6Gl7+dfcbI4nK28rsCGaXWxYuI+ps2H7gXSWJ/Ks7Up3KWzmlq4aeX e95MZfiAJnCi7XAs52JTCmv6cy4apRs2xDFrKInlAqrxyQoDWOFysW9VTQaIoJ6PzdlO 9I6rAS/SFRN8TZjFFbveOoe9jqc2n/x7E5hx9A3msGdQKPDBT9Bnfsn2oOopS89tdXNe QIzheqfklqVtzdHA9T384YY2t3F9eAUxee+bizMTzao1pkD4eW4eTgtZBuXKZV8mnL6t 4/s3iAms8cfbr/I6bMSxEZDCpZCWf/h+gso2nKJ9uTax83kLSKX3mNKOGeUJu/Ckf11J nIZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680279737; 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=Bsb3lmthOCc6e7au7gufgrFzapDq9oLtvGA3KaskcJo=; b=tvBS2cmHvKewyqX+OGuPIED1LWSH4v+EtDMh1U2Op4J9mcOTS2Ezmn/Da+6AI/OSoQ co8v50Cna9L6cajkPffs/LqakHVasqVCtPQpQLzD9P+yz+udgbgsgSL2i1Qa5AYCS5m5 fqxpQjimWHFkLxlBhAIxk7uClgKNzlKQGCeUD997hYBUpKMYXpGIaHH1eiX9MtvQz5Ag 9Nlah/UaRLq5wbEYupcjJ48cD9a/ouuvGL4wfxkEVmQk8kT8uCEq1pZFGzzI7L8rqp8t yG7IX1FWPPQfEoQ8O2rswlCt7iyj9JdlbapjeoFPZIGwh4Wot6ejXVPRzAbzcUqepfsg EiYg== X-Gm-Message-State: AAQBX9e9R+bGB9FpMjOyFN/vlpntFaSKSjWz3Vit+Jn2Q7ibzKW/sa+7 GOfkIpzvLY4QnuzbVg3+z4+YcC7xR0k= X-Received: by 2002:a2e:9194:0:b0:293:32e0:5c8a with SMTP id f20-20020a2e9194000000b0029332e05c8amr8527073ljg.15.1680279737147; Fri, 31 Mar 2023 09:22:17 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id n20-20020a2e8794000000b0029573844d03sm411483lji.109.2023.03.31.09.22.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Mar 2023 09:22:16 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 31 Mar 2023 19:22:00 +0300 Message-Id: <20230331162205.428735-8-jeebjp@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230331162205.428735-1-jeebjp@gmail.com> References: <20230331162205.428735-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v1 07/12] avutil/frame: add helper for extending a set of side 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: kLGgRAityQ88 --- libavutil/frame.c | 21 +++++++++++++++++++++ libavutil/frame.h | 11 +++++++++++ 2 files changed, 32 insertions(+) diff --git a/libavutil/frame.c b/libavutil/frame.c index 3386cda627..ec4e44a11f 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -720,6 +720,27 @@ AVFrameSideData *av_new_side_data_to_set(AVFrameSideDataSet *set, return ret; } +int av_extend_side_data_set(AVFrameSideDataSet *dst, + const AVFrameSideDataSet src) +{ + for (int i = 0; i < src.nb_side_data; i++) { + const AVFrameSideData *sd_src = src.side_data[i]; + AVFrameSideData *sd_dst = + av_new_side_data_to_set(dst, sd_src->type, + sd_src->size); + if (!sd_dst) { + av_side_data_set_wipe(dst); + return AVERROR(ENOMEM); + } + + memcpy(sd_dst->data, sd_src->data, sd_src->size); + + av_dict_copy(&sd_dst->metadata, sd_src->metadata, 0); + } + + return 0; +} + AVFrameSideData *av_get_side_data_from_set(const AVFrameSideDataSet set, enum AVFrameSideDataType type) { diff --git a/libavutil/frame.h b/libavutil/frame.h index 8aa50e3ad8..da8ac3237b 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -1011,6 +1011,17 @@ AVFrameSideData *av_new_side_data_to_set(AVFrameSideDataSet *set, enum AVFrameSideDataType type, size_t size); +/** + * Add multiple side data entries to a set in one go. + * + * @param dst a set to which the side data should be added + * @param src a set from which the side data should be copied from + * + * @return negative error code on failure, >=0 on success. + */ +int av_extend_side_data_set(AVFrameSideDataSet *dst, + const AVFrameSideDataSet src); + /** * @param set a set to which the side data should be added * @param type type of the added side data From patchwork Fri Mar 31 16:22:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 40957 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp852087pzb; Fri, 31 Mar 2023 09:23:37 -0700 (PDT) X-Google-Smtp-Source: AKy350ZpK/zuFphN5dFsiXF41I2bIiCB3hLQp3ERUN9kSkxDB3hc++3ecbGHqdWZZSDJCDvsKr9D X-Received: by 2002:a17:906:6953:b0:932:e43f:7367 with SMTP id c19-20020a170906695300b00932e43f7367mr25408012ejs.35.1680279817332; Fri, 31 Mar 2023 09:23:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680279817; cv=none; d=google.com; s=arc-20160816; b=tBTLz6afRkhcF9lHaBaXaPP5nknZJUxNKVv6SUHe06sgoe5Yic5CYQvFNgQK7hbFxq eX9bShkCAjn9IK30bR4I+I4cHlnNtHwhYuYora+r2vPUXaB2BKSCkY42MD9/Hstsf0TX Wub/Puat18vGS5xFu0/Zeg0Lffj+lYLCr+eRaIbDLeHMJH1m9lbkZIQy2o84t0rGahaE PSNuI3gJiaz7I/ZTssSA/gtrk9iC9xVUtaEfrmKWapTpoWOz/HDMgKv6zHUgBvBGl4iV LOTeq8CiC/W2EImfyksxqYXlpQMjsyX4mD1T2G7CKMfxDbt28XeST5b09IIhGIZKssti 5DAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=VGYpg74F0Bg1pbHysrdIQEUEjxEKT76BOdDDfC8eduY=; b=NYqrSJvFWGOpiHcrgO2mjHOeE9/8X/89kY4dTE3aEhZoub2AwHrxHPeGCNg+WoM6G1 EoBbsMT3+faUf1NFRWxDaBO+AeFiVgTrAVfWlZQlxxFMTZS9VBoHxbNFBZ0PU9h5LdMR PUYVFB96vwO53iXwPaWtucMPh85GUHPB4ExWZntO9xB84UVZuG4VVQIN3LkrNdk0isab JvOG+J4g1nGrciD0UNWKATl4jNzzv4d+ZbB8FePQKRXoLtWrLnCmpYyfNonKP3n9W4J/ 1zoXOZfALIczI18qKKTzGtby8KEMmw8TRPgBJkg2ofwc4zVfNErvYsh0xVz7c3HPJgnY iJWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=MCoGzTLH; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id s1-20020a170906168100b0093182033b89si2090908ejd.711.2023.03.31.09.23.36; Fri, 31 Mar 2023 09:23:37 -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=20210112 header.b=MCoGzTLH; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C515068C2F0; Fri, 31 Mar 2023 19:22:32 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0DE8A68C2DE for ; Fri, 31 Mar 2023 19:22:18 +0300 (EEST) Received: by mail-lj1-f172.google.com with SMTP id e9so8360097ljq.4 for ; Fri, 31 Mar 2023 09:22:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680279737; 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=THa7SvoWwJKGXnBPBzDBm193Q7NH1WQMe3d1EqK2UV0=; b=MCoGzTLHrVxikkuI/NWsKfVm6MYAnUVMkWyzVbFtW3OWVQ/nIKSv8jGLdq6s5ttBvN OQjRN3nz1m2bk+qEiC/BYEs1AJYNhfhKAycbd4PeQ8h8c7W40hmIMzNva1zYB6hMaFSV 3S0aqjo9fb1jYYOYp9hM4w4hz2WNM7TLmKYtv4s9ohsocsMdWgOUeMR0oI8UZaT+Wdd5 ykjzJSqe3Xe/rRiqJmlyrNx6P5Z70AkF9MAh3rR4/FqBxab2QYlQx1WzforiqqhDCaJT tzgutuTCqLvF1k5i0+DI+4Sw3GO4wyRFOrppNQ0RmOV7DSBHR9m/8/QBiWdO/3YEwQN0 mySw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680279737; 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=THa7SvoWwJKGXnBPBzDBm193Q7NH1WQMe3d1EqK2UV0=; b=lqAM8mBC6qHAeMkuxC8/zZWUU6AymIXrGyx2BFPdo+A3upgiartJVIahDVyZLUePM5 UGRHSHbKt0XtPJ6V0DCRgXkT+TDmUmMvboLFWZco4SSPzxQO3ltJ7ugodRZA9gC8ckJy FVU9GVHQTHKDusskUnnl2WvUF/epAJvVvZV6CQF4i/OCkeGGrY8TWssPzTIPzzFHFtzE aGBgvtfvoeF2hmpXWdQ0KdCAHGfWlMd0ReAc9PIfvXFZ0tRFT5PyFyNb6Ev+WpHfs+zO X8sBPWxjwyhnp+IkY58L21la6peAZWaWXAx49lb8lvuYSVu7lItE4IVKZIWVF3E8FzDP luxg== X-Gm-Message-State: AAQBX9c+68CbzitgCGTp+xyxbDgVReD/vFhodGn/48/M3cQnFYkY8a8b 7ZP8GwZbx3OcEQoLZqKGlAjDAgWLwDE= X-Received: by 2002:a2e:6a05:0:b0:2a5:f6c0:cb36 with SMTP id f5-20020a2e6a05000000b002a5f6c0cb36mr5221936ljc.7.1680279737488; Fri, 31 Mar 2023 09:22:17 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id n20-20020a2e8794000000b0029573844d03sm411483lji.109.2023.03.31.09.22.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Mar 2023 09:22:17 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 31 Mar 2023 19:22:01 +0300 Message-Id: <20230331162205.428735-9-jeebjp@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230331162205.428735-1-jeebjp@gmail.com> References: <20230331162205.428735-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v1 08/12] avcodec: add private side data set to AVCodecContext 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: VW9VWYINO8bJ This allows configuring an encoder by using AVFrameSideData. --- libavcodec/avcodec.h | 7 +++++++ libavcodec/options.c | 1 + 2 files changed, 8 insertions(+) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 18ca0e2494..0ba0c390c4 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2084,6 +2084,13 @@ typedef struct AVCodecContext { * an error. */ int64_t frame_num; + + /** + * Set containing static side data, such as HDR10 CLL / MDCV structures. + * - encoding: set by user + * - decoding: unused + */ + AVFrameSideDataSet side_data_set; } AVCodecContext; /** diff --git a/libavcodec/options.c b/libavcodec/options.c index a9b35ee1c3..b7ea6b6ab5 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -180,6 +180,7 @@ void avcodec_free_context(AVCodecContext **pavctx) av_freep(&avctx->inter_matrix); av_freep(&avctx->rc_override); av_channel_layout_uninit(&avctx->ch_layout); + av_side_data_set_wipe(&avctx->side_data_set); av_freep(pavctx); } From patchwork Fri Mar 31 16:22:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 40958 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp852183pzb; Fri, 31 Mar 2023 09:23:46 -0700 (PDT) X-Google-Smtp-Source: AKy350bAhJiXZddJQNXIofkMSQxwNjL+JSivIZagOb0Lv7F0lzY4Pbi4v2QLdZvgA0HCX2HlGtNV X-Received: by 2002:a17:906:2b8e:b0:946:c022:8979 with SMTP id m14-20020a1709062b8e00b00946c0228979mr15680045ejg.21.1680279826157; Fri, 31 Mar 2023 09:23:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680279826; cv=none; d=google.com; s=arc-20160816; b=ckYjgkYPH+ckQ81JFSRGL06RQ4dF5G13/4h1RKL3/lhR22hZmTJtAgATvYS2gGNDYU tJ8V5FnNRUYIycBMzee1Y2075bRG0ja+eq02QDme6GYjCk2zM4r2lk/IYCc9IipWaI7Z 93MbQS5gmEx7Dy0DfFVBZvKU4iD+xZ7hUz0v0Iu13os6MrXgbQUIYWLbFFmz4BeFHt1a o3znRolM57yu9B4TBin4pLnnWQxUP4XfP2ZNTgMI5OTdEcvlOda4/pY26+NfvuVBnngp RK2e96G2VMKLiV83GL049ecJmTtfAKvRffrdBBj5fZz0C5iN3a24jma4KJjH4AR0LwOB Ju2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=1AurSeyA5Jnphyld2+oZMRZ60/f5BqDeexDLSdMMpeE=; b=Df+JeCqBQinayfdatCGrrwDxLsKchfrmWweHjrsU/L6XJUfY+DV4yWY9TA4OiZzAjX QEL0GKSViIMhokKksHTaB8M3UzeunpmNZIYOEMPoWcE/8UfQ4WXBBmj5sYZQWDI1XuiZ uSnd+e2yY6yei5WFjfEP03oABvbWPtRK9ZN4rZP6bkjf4ZaPJxERKgW62TrXLQYysqML /XTWaCdXcaKSFxPVtVQGiFAMsTWlLVkEoPlSNFPhKD6N7djRA8gysK8KO180GhCe7crU NUDl3XuA6WxB34Xyfg7ZSGe9BgcW6GcpLl0q5FlxJOLKlHKT4fgX1BaKyDx9O4Y3EUuH +0Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=fj4itjaI; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id y14-20020aa7d50e000000b004fd23c354a4si2405652edq.536.2023.03.31.09.23.45; Fri, 31 Mar 2023 09:23:46 -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=20210112 header.b=fj4itjaI; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AF70F68C345; Fri, 31 Mar 2023 19:22:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7C9B368C2EE for ; Fri, 31 Mar 2023 19:22:18 +0300 (EEST) Received: by mail-lj1-f178.google.com with SMTP id a44so4975965ljr.10 for ; Fri, 31 Mar 2023 09:22:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680279737; 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=1NnZ+wvikwZDTSvlAF1ULTsLB12vvqbdwGQdXJ/I1ds=; b=fj4itjaImNZxqgJEIF3NER1v4DDOelnUQYF9uoZx4vjZWufU+mazhSdCO8IRlhFeyD a8q4zneq6VoiKrDcZamk/YuBrKae9uBDE71oWBqWBWsssblsbGVhicz5XEPWFyFHamjw e/7qgREbAqbORRbR9HxN0LAv5Y0DBFvGdgKN/v/a1+N7RWFokHlNSYBxP1F50pjHPfrF hkrdUpffd59jwTVgTJ6588A5n/swQrnxMxeHGYYG/UhXUf3m9PnQdRgzGFhIWihizQSF xuL1Ep3mVyYF8W4H8gnltWbyBEG5bZKK1W4kqt8npEKn8j0D0+Im06Mo7OCQxoL4eN/N 5Rgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680279737; 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=1NnZ+wvikwZDTSvlAF1ULTsLB12vvqbdwGQdXJ/I1ds=; b=jLq2xX7Mo+ci73p9/XE36Hu7wQDoqKcemGlmcLLKwJhm62Z9EAxPyWv1ed54nybCf5 kMp+7Q6IsA669wS4dURUDfsjmYZq5jQj6G+58sJUo9rvzTDTVSmgTYuf9riCMA9nZoUa xcG4TpclL5Ma1AoTb4dg1gE5LcOyp6dO/2CpqF3eyg58Fig+Nwx/uyUuovAweJsUCzPK Z8rAnzAYtrhzW2GXfMdTXvXV97eR3Wh/Nhmy0inpjXgro6Pgjc5FtDmhFiR0M5QX7Pap uWr3ruclZomOk6UYSHlD2NuR+MFg5UMcgX5GTl4toZLonFTRlLzgWXjK+A6cEfqEaa6R 6YYQ== X-Gm-Message-State: AAQBX9dd0+tU0XxD61uCEYCphlTJSjh+HpFqN5HTHPPcjQz5+DZlvf/t JyrLXFiwc27uxprQ22DZs8k8jdWVIwM= X-Received: by 2002:a2e:9c11:0:b0:2a1:8c04:b094 with SMTP id s17-20020a2e9c11000000b002a18c04b094mr7181813lji.3.1680279737834; Fri, 31 Mar 2023 09:22:17 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id n20-20020a2e8794000000b0029573844d03sm411483lji.109.2023.03.31.09.22.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Mar 2023 09:22:17 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 31 Mar 2023 19:22:02 +0300 Message-Id: <20230331162205.428735-10-jeebjp@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230331162205.428735-1-jeebjp@gmail.com> References: <20230331162205.428735-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v1 09/12] ffmpeg: pass first video AVFrame's side data to encoder X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: raxKctxdR6si This enables further configuration of output based on the results of input decoding and filtering in a similar manner as the color information. --- fftools/ffmpeg.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 438bee8fef..c26dd1ad0c 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3118,11 +3118,23 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame) av_pix_fmt_desc_get(enc_ctx->pix_fmt)->comp[0].depth); if (frame) { + int ret = AVERROR_BUG; + enc_ctx->color_range = frame->color_range; enc_ctx->color_primaries = frame->color_primaries; enc_ctx->color_trc = frame->color_trc; enc_ctx->colorspace = frame->colorspace; enc_ctx->chroma_sample_location = frame->chroma_location; + + if ((ret = av_extend_side_data_set(&enc_ctx->side_data_set, + (const AVFrameSideDataSet){ + .side_data = frame->side_data, + .nb_side_data = frame->nb_side_data + })) < 0) { + av_log(NULL, AV_LOG_ERROR, "failed to configure video encoder: %s!\n", + av_err2str(ret)); + return ret; + } } enc_ctx->framerate = ost->frame_rate; From patchwork Fri Mar 31 16:22:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 40959 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp852285pzb; Fri, 31 Mar 2023 09:23:55 -0700 (PDT) X-Google-Smtp-Source: AKy350aZNmJjPNy7rAlDawSoU7H/Ta88S8iFYTy6CKssfXTOosql9MRuCeEYX5KvyPurhgCOiTqt X-Received: by 2002:a17:906:3449:b0:930:9197:24d1 with SMTP id d9-20020a170906344900b00930919724d1mr10411317ejb.6.1680279835223; Fri, 31 Mar 2023 09:23:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680279835; cv=none; d=google.com; s=arc-20160816; b=IRa5w/6vYKtzeWcCX8NEUG9wCabBiHs56cmnSnHDgQMnI+aTxnT7mVvQ+3WOIx31VP dUgnIcwzF8RSKsXnfm1GXAuPY9krxI5AnPhgw1wCXGkS2ttIa+96VL86exbnr4Wioy5w lRY+h+Qf5WoJzRnYiH8CpODZNODu4UqxK3BdxNDQFVrc2DbZ1cNk+4cQ3QFuzGbaJ+q7 +7jcSQM66sSVAzXEBnH/J+H9HoAbNuHUrWwpEOGc/5YcG0uMlfi8Iwo6GS3ut40Igi4/ 7DySwajUbqBgbD5ydmL+n12/k2cnoSkSpVM59BsZp4d2rmKxtK0qIgze7POquJbCqO3F OClw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=2lx+WwHBa+Desj0QKvvX4OuWKNz6J0rulMKwE09hYIo=; b=Pb+cEN7PfijF0YKB3YZEGYuv4agrcb7mJQ6VBoCq8pTlfzI+IYafG+CtfWUrSXUbMB U6hewnN3ATlNrhsIdOKMzt4IPBjOeg0gytMdDnYaPeQm2zNAeIG2Ybtrk2O/FaBbS41E SZfq8s1vq1V23RmUYtzS/agrCLEY/mXq3qyhti6fiODOuedCR2Ea4WXJ69c6nS2Cn86z efAx489iqihfRkHsrk1UKjgHwOLLN8Z4KfZh5zYSfiSYZkkFhI88UaPZ9++VhMyfOiCb cnXkQGGSVLiyCRYde5zMQVXnRuacKJTRg/qSihPNZfGD7TXKbxxrXhecoUj3rHjIU1z9 pwRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=kuVxb+0W; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id qb10-20020a1709077e8a00b00947e2d50eb4si277981ejc.68.2023.03.31.09.23.54; Fri, 31 Mar 2023 09:23:55 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=kuVxb+0W; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A1C3268C337; Fri, 31 Mar 2023 19:22:34 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 164DC68C29A for ; Fri, 31 Mar 2023 19:22:19 +0300 (EEST) Received: by mail-lj1-f180.google.com with SMTP id a11so23613702lji.6 for ; Fri, 31 Mar 2023 09:22:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680279738; 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=frO6JDtis1QtgexSryxeFs7JVV2iWXOD3YZkF40KeAU=; b=kuVxb+0WZ7WLdCU8t1+tH8NagARePCdZhF0K/lcFSGgGDmoRRxwXEVS1uWOsvKzPMs A5z0WGVgs6sFRjaPLa1e/I7uWUpIJxp6RmHEuhEVnLY+cZ8LystyeOpxLTd17tzvPl0V LKRB909MH/fORdw+gQyW1QxqyC9cCXSz7Fh1IBDiQMXM+mKp/l2dADSa0GpQUDsxWVja KWiwAGymtYRO90qr2jwg8vKFeXrTgoGvb7jJGXOCnqc4QhR/aQyZcHC5j24FyL/dqF6N ieZlVp0sA89ocdadUAKHKahwnEFeNIeF9l9EghAPr/p8WY3U1/ikoEBZULS27y3926oy 0uQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680279738; 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=frO6JDtis1QtgexSryxeFs7JVV2iWXOD3YZkF40KeAU=; b=SAG1AeKAxeLR+HCmMMoCJeczKM9C2FM2+KV9xn8gu3xwA+EOAy9OX7q2ot1HmqGH+j 9xhUp+8vuK0GuZ7d107PMMR6MCLtack6F5I/nRvLYq5oRm0f9n8KTXQc8zdMDTcYdjQW gMQAZznRwzh1coOfS1SU87+ipHTqnyb3mRRM3gRVrvPeF5gCPtI8SawOOM4/fNZRAlYk txGcTXBRRXq0CvZGd54kaQgcEK4KLgbpgaGvNeLHVTuPHUJAbAzpXIUl52Zhxt7lrNdi a1EXIF5YmN7sts58OT1eKKsYfddkXNwXQH2K/n6PDrLNaqL/MD9t3sEPnutkZA55anZv +d1Q== X-Gm-Message-State: AAQBX9dwh4iEAlurjTtV0u340Tt4DkRX6O6r/j3PTfGYHBW/ZQGUYJDS KtIjTMYruCygTwdGYHWNj82XsCFYCJc= X-Received: by 2002:a05:651c:1308:b0:2a3:108:d2e0 with SMTP id u8-20020a05651c130800b002a30108d2e0mr2558131lja.25.1680279738233; Fri, 31 Mar 2023 09:22:18 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id n20-20020a2e8794000000b0029573844d03sm411483lji.109.2023.03.31.09.22.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Mar 2023 09:22:17 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 31 Mar 2023 19:22:03 +0300 Message-Id: <20230331162205.428735-11-jeebjp@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230331162205.428735-1-jeebjp@gmail.com> References: <20230331162205.428735-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v1 10/12] avcodec/libsvtav1: add support for writing out CLL and MDCV 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: HtIG/uijinGn These two were added in 28e23d7f348c78d49a726c7469f9d4e38edec341 and 3558c1f2e97455e0b89edef31b9a72ab7fa30550 for version 0.9.0 of SVT-AV1, which is also our minimum requirement right now. In other words, no additional version limiting conditions seem to be required. --- libavcodec/libsvtav1.c | 70 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c index 9174e2753c..1bbda0b705 100644 --- a/libavcodec/libsvtav1.c +++ b/libavcodec/libsvtav1.c @@ -24,9 +24,11 @@ #include #include +#include "libavutil/bswap.h" #include "libavutil/common.h" #include "libavutil/frame.h" #include "libavutil/imgutils.h" +#include "libavutil/mastering_display_metadata.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "libavutil/avassert.h" @@ -146,6 +148,72 @@ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc) } +static void handle_mdcv(struct EbSvtAv1MasteringDisplayInfo *dst, + const AVMasteringDisplayMetadata *mdcv) +{ + struct EbSvtAv1ChromaPoints *points[] = { + &dst->r, + &dst->g, + &dst->b, + }; + + if (!mdcv->has_primaries) + goto skip_primaries; + + for (int i = 0; i < 3; i++) { + struct EbSvtAv1ChromaPoints *dst = points[i]; + const AVRational *src = mdcv->display_primaries[i]; + + dst->x = + AV_BSWAP16C(av_rescale_q(1, src[0], + (AVRational){ 1, (1 << 16) })); + dst->y = + AV_BSWAP16C(av_rescale_q(1, src[1], + (AVRational){ 1, (1 << 16) })); + } + + dst->white_point.x = + AV_BSWAP16C(av_rescale_q(1, mdcv->white_point[0], + (AVRational){ 1, (1 << 16) })); + dst->white_point.y = + AV_BSWAP16C(av_rescale_q(1, mdcv->white_point[1], + (AVRational){ 1, (1 << 16) })); + +skip_primaries: + if (!mdcv->has_luminance) + return; + + dst->max_luma = + AV_BSWAP32C(av_rescale_q(1, mdcv->max_luminance, + (AVRational){ 1, (1 << 8) })); + dst->min_luma = + AV_BSWAP32C(av_rescale_q(1, mdcv->min_luminance, + (AVRational){ 1, (1 << 14) })); +} + +static void handle_side_data(AVCodecContext *avctx, + EbSvtAv1EncConfiguration *param) +{ + const AVFrameSideDataSet set = avctx->side_data_set; + const AVFrameSideData *cll_sd = + av_get_side_data_from_set(set, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); + const AVFrameSideData *mdcv_sd = + av_get_side_data_from_set(set, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); + + if (cll_sd) { + const AVContentLightMetadata *cll = + (AVContentLightMetadata *)cll_sd->data; + + param->content_light_level.max_cll = AV_BSWAP16C(cll->MaxCLL); + param->content_light_level.max_fall = AV_BSWAP16C(cll->MaxFALL); + } + + if (mdcv_sd) { + handle_mdcv(¶m->mastering_display, + (AVMasteringDisplayMetadata *)mdcv_sd->data); + } +} + static int config_enc_params(EbSvtAv1EncConfiguration *param, AVCodecContext *avctx) { @@ -256,6 +324,8 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param, /* 2 = IDR, closed GOP, 1 = CRA, open GOP */ param->intra_refresh_type = avctx->flags & AV_CODEC_FLAG_CLOSED_GOP ? 2 : 1; + handle_side_data(avctx, param); + #if SVT_AV1_CHECK_VERSION(0, 9, 1) while ((en = av_dict_get(svt_enc->svtav1_opts, "", en, AV_DICT_IGNORE_SUFFIX))) { EbErrorType ret = svt_av1_enc_parse_parameter(param, en->key, en->value); From patchwork Fri Mar 31 16:22:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 40960 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp852363pzb; Fri, 31 Mar 2023 09:24:03 -0700 (PDT) X-Google-Smtp-Source: AKy350b4eqnhqW48gT/NsA8Y7VYREm5LmcyVeLIHpMpovlOyPo+VXAh8CA6Ub6i0gNleTp3U+w3K X-Received: by 2002:a50:ec89:0:b0:4fa:4b1c:5ea3 with SMTP id e9-20020a50ec89000000b004fa4b1c5ea3mr27239245edr.23.1680279843439; Fri, 31 Mar 2023 09:24:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680279843; cv=none; d=google.com; s=arc-20160816; b=aM5jPG4TwAWJSTEHaeILeFEdctycvmJ7YP3KJnRvQMlGkzH8q9ziN6ZfS0L9zFx9Qm vUEsto8Uy0jDVT/kcP+3z8H0LvkyH6h450K/zEgp9E8g7npDV8R5kCAh5bAsJc/rDoK3 W3/6n5oonSHVbXZaL508mZ7wrJqwA4yN9B+kOHcfEBF6yLUQlyHIqyKwm/ukTKMa53su ttVt4aTbpfwySaW+bzDsqDytni/H47i5NWB4etWBgt2mbq+wewPbuNXHRrM+IriERxS/ KJecYryolZdx5k9EntQZKCt0PDq08Ho4k2CXAb+o3QG5J1V5m5wqBANMDtDb4yFKXKGc 0zcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=CTq+Au6ZEIkv5JsFiVhv65nGt1FrLkLm4aAZ/5qI8v4=; b=vgtrX8WF5O+iOrTbki9gyI75XAVHzIRtcAPsMYUZ7OxfJrYJ04Tn5+Wt4zUf0bNHP9 nXdlTeosAfpOWmCvUMOX++wXFQAb593Yb248++X+gNBE1OjE6hvvzDHsU+wLfTp44vU5 t8/T9K5Nkpc31PUPO9+Yl6uMSnKq/jUlxpen8SWnQ5MGwNwz+GgQt67k+AgtgXaonla1 1hE11wlnAFmvi60NJVyTO5itjz39IZWQ+WIRSiqTBZuW5fYIoP++INM6ncbSOKEmL2ip xGkmSsdpmljyusWk+o3lO2Yg3JLGF2AUqZSZaKIp1cN6rovjRLsOqNXG1kojbr9uEhxV NdBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=qS0zfC2b; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q7-20020aa7d447000000b004fcd1adbb05si1538089edr.210.2023.03.31.09.24.03; Fri, 31 Mar 2023 09:24:03 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=qS0zfC2b; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8CB5768C354; Fri, 31 Mar 2023 19:22:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 36AB368C29A for ; Fri, 31 Mar 2023 19:22:19 +0300 (EEST) Received: by mail-lj1-f180.google.com with SMTP id 20so23664178lju.0 for ; Fri, 31 Mar 2023 09:22:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680279738; 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=tL4emu2ZrZJaRofE5kS5tGm3dysqe64JI+gN8gTMsvg=; b=qS0zfC2b1v9ML6iQ/oseY+OseFzh+o64lGWe1ItEuhjGFYnboAqu7kUtc1v8PKfAvO LleJ129i6wO+w9fpp9sIej+HCh1cyAWaqzpE74XxkOH0dlTCqcXobiYooO7TJAIrGG4d 0VFC7W5kg91h+27NrqSFXbO9mAIV+mUsMQwPMAoTxmzDqvAltX4D43Ud+SjnQx7o+oGD uAruX+c0zIs34+8HEkcnHONyZTLTlXmtwU53OHwXuVhNiEp8UhOpOr8X3vHiKO8HJuxX 3zL87UlKqcBwqsRgK2IYUPRsDs8ZOaooYnu3LUj4Ppx0m+uo+xFqxZfG+5wzs8ShObcy 1ttQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680279738; 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=tL4emu2ZrZJaRofE5kS5tGm3dysqe64JI+gN8gTMsvg=; b=I38BIV9o7jKoR73HIAK4xkaxysR/bN6pmidapgsxZUXFRoI4p4WCx60dZ8BROi+B+N MohINSchA7QrHr+ia2LDHqvmq49G8w0LnbdEsRHh1yt+yWXtFauuUDDe019y+jr0rmZn aGRcbi+TccLz+sdPzqqwmDCrVAk9VUf0ujqh49tX/8XKKZ7B1VFTmd54FPa88d42bryB GtRA9UIJrgfW1Q9fwKnIQmKwQWWmwk1MxLgy5HQN5YD6STFHX//jJrTj5A2ObIXW03zj kqx0MlYUIWUnYhDDMt98jkaBtbnUaShYuygPQtq6O5CoI4FCgO39jf5rroDuOoVuAHvr 8o9w== X-Gm-Message-State: AAQBX9fvIAo0bxsZuRc80AmsVL0BWEVjzDPYUFQyRyNjxcBbIT6GbEmm rz/Erxxbrt6Bf+fZQcBUt0x7W1hBfRQ= X-Received: by 2002:a05:651c:95:b0:299:cf0a:bf8 with SMTP id 21-20020a05651c009500b00299cf0a0bf8mr8404127ljq.17.1680279738610; Fri, 31 Mar 2023 09:22:18 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id n20-20020a2e8794000000b0029573844d03sm411483lji.109.2023.03.31.09.22.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Mar 2023 09:22:18 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 31 Mar 2023 19:22:04 +0300 Message-Id: <20230331162205.428735-12-jeebjp@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230331162205.428735-1-jeebjp@gmail.com> References: <20230331162205.428735-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v1 11/12] avcodec/libx264: add support for writing out CLL and MDCV 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: 6i3MeB1HqDRw Both of these two structures were first available with X264_BUILD 163, so make relevant functionality conditional on the version being at least such. Keep handle_side_data available in all cases as this way X264_init does not require additional version based conditions within it. --- libavcodec/libx264.c | 79 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 92828fabc3..f841c66227 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -25,6 +25,7 @@ #include "libavutil/eval.h" #include "libavutil/internal.h" #include "libavutil/opt.h" +#include "libavutil/mastering_display_metadata.h" #include "libavutil/mem.h" #include "libavutil/pixdesc.h" #include "libavutil/stereo3d.h" @@ -737,6 +738,82 @@ static int convert_pix_fmt(enum AVPixelFormat pix_fmt) return AVERROR(EINVAL);\ } +#if X264_BUILD >= 163 +static void handle_mdcv(x264_param_t *params, + const AVMasteringDisplayMetadata *mdcv) +{ + int *points[][2] = { + { + ¶ms->mastering_display.i_red_x, + ¶ms->mastering_display.i_red_y + }, + { + ¶ms->mastering_display.i_green_x, + ¶ms->mastering_display.i_green_y + }, + { + ¶ms->mastering_display.i_blue_x, + ¶ms->mastering_display.i_blue_y + }, + }; + + if (!mdcv->has_primaries && !mdcv->has_luminance) + return; + + params->mastering_display.b_mastering_display = 1; + + if (!mdcv->has_primaries) + goto skip_primaries; + + for (int i = 0; i < 3; i++) { + const AVRational *src = mdcv->display_primaries[i]; + int *dst[2] = { points[i][0], points[i][1] }; + + *dst[0] = av_rescale_q(1, src[0], (AVRational){ 1, 50000 }); + *dst[1] = av_rescale_q(1, src[1], (AVRational){ 1, 50000 }); + } + + params->mastering_display.i_white_x = + av_rescale_q(1, mdcv->white_point[0], (AVRational){ 1, 50000 }); + params->mastering_display.i_white_y = + av_rescale_q(1, mdcv->white_point[1], (AVRational){ 1, 50000 }); + +skip_primaries: + if (!mdcv->has_luminance) + return; + + params->mastering_display.i_display_max = + av_rescale_q(1, mdcv->max_luminance, (AVRational){ 1, 10000 }); + params->mastering_display.i_display_min = + av_rescale_q(1, mdcv->min_luminance, (AVRational){ 1, 10000 }); +} +#endif // X264_BUILD >= 163 + +static void handle_side_data(AVCodecContext *avctx, x264_param_t *params) +{ +#if X264_BUILD >= 163 + const AVFrameSideDataSet set = avctx->side_data_set; + const AVFrameSideData *cll_sd = + av_get_side_data_from_set(set, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); + const AVFrameSideData *mdcv_sd = + av_get_side_data_from_set(set, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); + + if (cll_sd) { + const AVContentLightMetadata *cll = + (AVContentLightMetadata *)cll_sd->data; + + params->content_light_level.i_max_cll = cll->MaxCLL; + params->content_light_level.i_max_fall = cll->MaxFALL; + + params->content_light_level.b_cll = 1; + } + + if (mdcv_sd) { + handle_mdcv(params, (AVMasteringDisplayMetadata *)mdcv_sd->data); + } +#endif // X264_BUILD >= 163 +} + static av_cold int X264_init(AVCodecContext *avctx) { X264Context *x4 = avctx->priv_data; @@ -1031,6 +1108,8 @@ static av_cold int X264_init(AVCodecContext *avctx) if (avctx->chroma_sample_location != AVCHROMA_LOC_UNSPECIFIED) x4->params.vui.i_chroma_loc = avctx->chroma_sample_location - 1; + handle_side_data(avctx, &x4->params); + if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) x4->params.b_repeat_headers = 0; From patchwork Fri Mar 31 16:22:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 40961 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp852449pzb; Fri, 31 Mar 2023 09:24:12 -0700 (PDT) X-Google-Smtp-Source: AKy350akVzvqtgIXnnEPKzbBnnjLUwwdjRLOc9nfOiSChL6WhhgJo2hxTjYvd+F9OEIUuWYtne7i X-Received: by 2002:aa7:cb9a:0:b0:4f9:f45e:c8b3 with SMTP id r26-20020aa7cb9a000000b004f9f45ec8b3mr28434016edt.27.1680279852786; Fri, 31 Mar 2023 09:24:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680279852; cv=none; d=google.com; s=arc-20160816; b=SVEaydlHNxhTxnhwGzHfCAIdM/HrIb4Uxr+rpBj0gIvsQdWlJeihFy4xM5SslhfgBG RlGAIIHXZKWkgqWME5OHy/oKueMzU7aZ07rAOyuh9tlfzOXv3ULf5vjqrMATkK4RVEIm rE3blFmQaV6Oz6s9DSaJzqbR7Ziz8BD2VhzZOjLvarL5wrDcqIlrjhF3q9+7Dpcnyl8D 7XmCAkcK1k60lhnHDDOFZmhu0r00TJ+0dGA1r/UjWgl/DuiI4/bSe+x37+hbLMqacaaM UBsMfNjyie5KsHhM/8U7wQAFZFacDjoQ9XTW51IaRKba7xjGX0Nsf8v5zm8RmSknkeD7 VS2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=3715mchB74CoFmNF4o7+W3OQGj6vqtr312cMcRHKvLQ=; b=TALiuXsEIueFilnR90cSMolElbvFRQkGpHduLi/pIei+lxV4wJ/Ht+V/DFAbsRsSBK 4tqiPQ0rkw+5g3JJJHAFJ53cZraxq4OoX7lQvEIV5KY+ii5iwR9Dfpvhu82BT8r3CrJ8 +KRMGw/4ax91wZK+XwIV2rmF8dJi2fzmC4jqOhn4ERxz5UTpgwf961IKzBURW1HeoT7t EjWm7xiQSTble/Ha50vFLMy8h9h1xyI54fMp0b4RVnMO61gpsMxxcSHdWBvGngrB9cp+ PZenGe2u6xYmQhnahr1dqnLDPmIiMvxWneGmBbmAk9T9Jw338ipnJWK2HkDPnE0+GJAF gaSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=MZuNwukh; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id s15-20020a056402164f00b004fd2aaa62d0si114124edx.242.2023.03.31.09.24.12; Fri, 31 Mar 2023 09: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=20210112 header.b=MZuNwukh; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 86F8A68C369; Fri, 31 Mar 2023 19:22:36 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 95B5668C2F9 for ; Fri, 31 Mar 2023 19:22:19 +0300 (EEST) Received: by mail-lj1-f172.google.com with SMTP id o20so20695591ljp.3 for ; Fri, 31 Mar 2023 09:22:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680279739; 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=8pMTtc/dk40m7irEIMLDQHOM308NHXgmb5xwIXgCYGM=; b=MZuNwukheIeOea9abrzrmch7ML7BwHkESczrkrm1KYPCl5Z5oC/5ZfPRX9zXuLG2AI qI/ozzi8W+132i9bWHdKLnGzxpXohAVcEi5tBnOJOzM8576dQrQ9P4z5tnhB8PkwaM0w sYAl80i9Vr6k0IXqeoMvbzI95nWLZpybyYZw/D0xhehtVYwYFnBCWuPPZ38dfYh5rvJ8 pEeApyRvcZ4XNaVIv2jKO3R2mzL5qS6PqGZKdO3iFh/zAAmE65k1CV0MWHciAx+RgMNt OfkNqsj/iZDnaphsrSrOdOLxncmXrz8pwnJXlP9IyJ1SF4dXVa9a7r+aUJcG/rSmEJql sHIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680279739; 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=8pMTtc/dk40m7irEIMLDQHOM308NHXgmb5xwIXgCYGM=; b=wxUriVAlJwAeUZt4G7KRo/Lu391c3W1DtxzrYJLV1VXsVl1EuGZs6Pk5OJ/7wzIrV+ h71on1a4dAy06yef88EE2b4ByRp+4TSSCu6wjPFeUUp2FNSbnuvS5DLtEESFbugHZq9W Vdal+zRR6Bvhs/tdAsmnGNTWxRsIsTzM6mkmSQnBz2xOA0uYp8Sxz5W6pUm6f4TEMvAj RK+n3v0bo5cXpse2nn5CU3lfCN3FwrMuakJwYhnYLH+NgbYi91diRUb8s+XmfJr7TSS+ QQTvwu4LAun23JJ98U48/98h54BaqE15Gfb4Y7a1gVlqfw7IpbBZbMvLOeviTfAkJruU Fp3g== X-Gm-Message-State: AAQBX9cEe51rLgbXugCS72S1+PTYtwStaX4w1R7i3KN9uw9Bk36YojQn K0E4jGtUdCHmMYNAp/elOIjMdXg6ksA= X-Received: by 2002:a2e:961a:0:b0:298:700b:e4a8 with SMTP id v26-20020a2e961a000000b00298700be4a8mr8628817ljh.27.1680279739025; Fri, 31 Mar 2023 09:22:19 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id n20-20020a2e8794000000b0029573844d03sm411483lji.109.2023.03.31.09.22.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Mar 2023 09:22:18 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 31 Mar 2023 19:22:05 +0300 Message-Id: <20230331162205.428735-13-jeebjp@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230331162205.428735-1-jeebjp@gmail.com> References: <20230331162205.428735-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v1 12/12] avcodec/libx265: add support for writing out CLL and MDCV 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: Rzc/RX3UbcCm The newer of these two are the separate integers for content light level, introduced in 3952bf3e98c76c31594529a3fe34e056d3e3e2ea , with X265_BUILD 75. As we already require X265_BUILD of at least 89, no further conditions are required. --- libavcodec/libx265.c | 82 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index 420d0953af..4378c04996 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -28,9 +28,11 @@ #include #include "libavutil/avassert.h" +#include "libavutil/bprint.h" #include "libavutil/buffer.h" #include "libavutil/internal.h" #include "libavutil/common.h" +#include "libavutil/mastering_display_metadata.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "avcodec.h" @@ -179,6 +181,79 @@ static av_cold int libx265_param_parse_int(AVCodecContext *avctx, return 0; } +static int handle_mdcv(AVCodecContext *avctx, const x265_api *api, + x265_param *params, + const AVMasteringDisplayMetadata *mdcv) +{ + int ret = AVERROR_BUG; + static const char *option = "master-display"; + AVBPrint buf; + av_bprint_init(&buf, 0, AV_BPRINT_SIZE_AUTOMATIC); + + // G(%hu,%hu)B(%hu,%hu)R(%hu,%hu)WP(%hu,%hu)L(%u,%u) + av_bprintf( + &buf, + "G(%"PRId64",%"PRId64")B(%"PRId64",%"PRId64")R(%"PRId64",%"PRId64")" + "WP(%"PRId64",%"PRId64")L(%"PRId64",%"PRId64")", + av_rescale_q(1, mdcv->display_primaries[1][0], (AVRational){ 1, 50000 }), + av_rescale_q(1, mdcv->display_primaries[1][1], (AVRational){ 1, 50000 }), + av_rescale_q(1, mdcv->display_primaries[2][0], (AVRational){ 1, 50000 }), + av_rescale_q(1, mdcv->display_primaries[2][1], (AVRational){ 1, 50000 }), + av_rescale_q(1, mdcv->display_primaries[0][0], (AVRational){ 1, 50000 }), + av_rescale_q(1, mdcv->display_primaries[0][1], (AVRational){ 1, 50000 }), + av_rescale_q(1, mdcv->white_point[0], (AVRational){ 1, 50000 }), + av_rescale_q(1, mdcv->white_point[1], (AVRational){ 1, 50000 }), + av_rescale_q(1, mdcv->max_luminance, (AVRational){ 1, 10000 }), + av_rescale_q(1, mdcv->min_luminance, (AVRational){ 1, 10000 })); + + if (!av_bprint_is_complete(&buf)) { + ret = AVERROR(ENOMEM); + goto end; + } + + if (api->param_parse(params, option, buf.str) == + X265_PARAM_BAD_VALUE) { + av_log(avctx, AV_LOG_ERROR, + "Invalid value \"%s\" for param \"%s\".\n", + buf.str, option); + ret = AVERROR(EINVAL); + goto end; + } + + ret = 0; + +end: + av_bprint_finalize(&buf, NULL); + + return ret; +} + +static int handle_side_data(AVCodecContext *avctx, const x265_api *api, + x265_param *params) +{ + const AVFrameSideDataSet set = avctx->side_data_set; + const AVFrameSideData *cll_sd = + av_get_side_data_from_set(set, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); + const AVFrameSideData *mdcv_sd = + av_get_side_data_from_set(set, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); + + if (cll_sd) { + const AVContentLightMetadata *cll = + (AVContentLightMetadata *)cll_sd->data; + + params->maxCLL = cll->MaxCLL; + params->maxFALL = cll->MaxFALL; + } + + if (mdcv_sd) { + int ret = handle_mdcv(avctx, api, params, (AVMasteringDisplayMetadata *)mdcv_sd->data); + if (ret < 0) + return ret; + } + + return 0; +} + static av_cold int libx265_encode_init(AVCodecContext *avctx) { libx265Context *ctx = avctx->priv_data; @@ -333,6 +408,13 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx) return AVERROR_BUG; } + ret = handle_side_data(avctx, ctx->api, ctx->params); + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, "Failed handling side data! (%s)\n", + av_err2str(ret)); + return ret; + } + if (ctx->crf >= 0) { char crf[6];