From patchwork Sun Mar 17 20:00:38 2024 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: 47130 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:958e:b0:1a3:31a3:7958 with SMTP id iu14csp656115pzb; Sun, 17 Mar 2024 13:01:30 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWdqTO/7BIY38dk+F1un6l9eOA+M7dsVYEvLeoLMcaDoNaFIYX7nNQh8YYhNHBaRO7wRLtJ0FHjJS18+Aav8lGGfK3ZeC60Ug6a6A== X-Google-Smtp-Source: AGHT+IHauhkihfzK188Is+MyStCjG81yTAIh8CJ3LUXcFv1Yl47pAn4Wxi1xO6+W20HvJO2ObOMp X-Received: by 2002:a17:906:710e:b0:a46:2b87:9f38 with SMTP id x14-20020a170906710e00b00a462b879f38mr5874547ejj.29.1710705690047; Sun, 17 Mar 2024 13:01:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710705690; cv=none; d=google.com; s=arc-20160816; b=igPgwi2jItr7FyI/fFliFXw/RTKvrOgaseu7UtWorfmLLH57axswrOI7t1llfh3Ny3 RkHj5onIMvSrKu55hgsgKikWw9paJlEiwqN1zDal1eQKq0aDTpRS5N02Lv9UEFMOgXt1 Eid/oHdEhMqUO2G4JNWrqWpb4UATnPLw/1silt+tzXVtXgBCUFjpxJkI6QJyHNDrWpTr o8F9lv8O8JYyzFIc8J+x4ATD1EB15Re4F+NGkIBUH+8yor/UI6/19pJDQ+PqAco14f3G vBr1glgKNPh/QMK7AoXZKGKhEertKMd5R+W4gwVTHzhWMdQ+JMrOtltAm8EED9vVd8ex E2KQ== 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=XD6SVcMziRDuJWZ+IjEMa2fRlOxXqona5bajt4cKboM=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=NM9I5HQVz/1LkNuhz8bGjipKcCQMz4y05rXTV6et1fTs81KNONazzViyzSy1Y3w93/ uwnH2ZxatLXk/1ewffk9Nfxz+w13yHJfh5d4CUrRsad3/PRhM8tScSJ5Hc2DbEqYBUDd ppL6ThXL1pO1SRzZIHne44XZpgKR38KewlfBnVQCxlw14p7dbegGslX3UGXJsorz/vHK diBrAtM3ufe0R45j+wgJiGk4JNqeOxxgq3it9BlCEV4LU+Tj26A2rguDX5nfBIhEJ7zr lg5q/BaVPe5IkLxF2AygJSoLr+DoNLlwWmlbDkDscnR9R0450wOAxgCtx5sxAb7i7yzT TW3Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=fZkCNNMD; 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 c7-20020a17090654c700b00a4628a74556si3555863ejp.279.2024.03.17.13.01.29; Sun, 17 Mar 2024 13:01:30 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=fZkCNNMD; 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 EA4BD68D1B4; Sun, 17 Mar 2024 22:01:17 +0200 (EET) 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 4B8E768CE16 for ; Sun, 17 Mar 2024 22:01:10 +0200 (EET) Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-513c8b72b24so4040429e87.3 for ; Sun, 17 Mar 2024 13:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710705669; x=1711310469; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=fUiSfTg77PKxwGlt5i3KDYZDuzE5HlYxtvwdcZx5qco=; b=fZkCNNMDyorwkL9jFxYpy2gyEcN6Yra55BHntBeuwia9b25os42Q6Ry9jhoQrVGrzj lFZ1Y9nTBgENvmcWLyaALv/8Tx9/IoiGzKcfpDDjwscTUxsIdDBqd3/FRndGkcKonR7/ 4Nm4+syItL1u0rHvsC0zCHh8RVCZ52fk83lqq+bVvCdWt3TIOnueByErr3TkxjX6ubr1 iSSNzz/V8EkZ9QOMuFLVMKMnVIC8RTSUTOHGCUc6OddVK0JRH21vLwGidhfMPuosszYP QW9i5eXOlv17bFtn1r9bFomNYMXfTJj8hl4ygr2bSyBYV8lU+eyWtECdBlKAKZgG4Sf7 f6yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710705669; x=1711310469; 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=fUiSfTg77PKxwGlt5i3KDYZDuzE5HlYxtvwdcZx5qco=; b=nKuqa5hxkMLTeP+9pA/Co92hvacbKfegRcDL7j2xeyfIdTAudJWsC414kvOvljd7tb GQBjIpdLvLW4wdRkIdmkrafnFZ29qpO8AjayYzQh2uGxf859CPxjr6rrgRbxWGQ9JdjO rfUPRPGv1FOc1Mody46v/MGYFAOmmUGdgjLRV1CsDhhYfBPuxNy6yV+ahoMNUcX9yLoH jUdifiqGkDOzAfZGfEDuQPygBaO0t6iZWmNM0ESnqAjVKEY8e4VIfNB18aJ9b+K/TkgG Rp8PtuBdjZZmVgZyKBEqPqJJxQl6Gy/EXy7mxfZ7fq7zflAHrslWlphXkbsCR/GUVkU2 13Mw== X-Gm-Message-State: AOJu0YwCLgoLUL6NMJ+j1hMKWpy5/yKyVzjkblMycNYpAiFAcc1j4il+ qWF4GFLFyIfAYz/E657O5cizdTIBlcQf26v7XelH8bk060nUpJt4tgB7DntA X-Received: by 2002:a19:ca0b:0:b0:513:dda5:a37f with SMTP id a11-20020a19ca0b000000b00513dda5a37fmr3359948lfg.23.1710705669340; Sun, 17 Mar 2024 13:01:09 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id y3-20020a056512044300b00513c844603fsm1340462lfk.41.2024.03.17.13.01.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 13:01:09 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 17 Mar 2024 22:00:38 +0200 Message-ID: <20240317200100.152097-2-jeebjp@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240317200100.152097-1-jeebjp@gmail.com> References: <20240317200100.152097-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v9 01/14] 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: Sr5nY9lhnD3p This will make it possible to to reuse logic in further commits. --- libavutil/frame.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 079cf6595b..ab425b2235 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -63,14 +63,19 @@ 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 frame_side_data_wipe(AVFrame *frame) +{ + wipe_side_data(&frame->side_data, &frame->nb_side_data); } AVFrame *av_frame_alloc(void) @@ -288,7 +293,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); + frame_side_data_wipe(dst); return AVERROR(ENOMEM); } memcpy(sd_dst->data, sd_src->data, sd_src->size); @@ -297,7 +302,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); + frame_side_data_wipe(dst); return AVERROR(ENOMEM); } } @@ -437,7 +442,7 @@ int av_frame_replace(AVFrame *dst, const AVFrame *src) if (ret < 0) goto fail; - wipe_side_data(dst); + frame_side_data_wipe(dst); av_dict_free(&dst->metadata); ret = frame_copy_props(dst, src, 0); if (ret < 0) @@ -536,7 +541,7 @@ void av_frame_unref(AVFrame *frame) if (!frame) return; - wipe_side_data(frame); + frame_side_data_wipe(frame); for (int i = 0; i < FF_ARRAY_ELEMS(frame->buf); i++) av_buffer_unref(&frame->buf[i]); From patchwork Sun Mar 17 20:00:39 2024 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: 47131 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:958e:b0:1a3:31a3:7958 with SMTP id iu14csp656206pzb; Sun, 17 Mar 2024 13:01:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX6WHUu1+eLCB3Z4HL+4c8VmCbB2cfltmVqVl1e1oN+kLX34zuCIieC58Sd/1ZH+SIZThmHscGMtEYSHNP/Fzk4qENHNEAoNHDmtA== X-Google-Smtp-Source: AGHT+IE2xvIfQKvCZuxaCIbXbfqwTxm8/8QZ8+NhkO5XNS3ViSAxTCU1tyE8quq3lRi8ri7ghGHw X-Received: by 2002:a17:907:7e93:b0:a46:a9f7:eebd with SMTP id qb19-20020a1709077e9300b00a46a9f7eebdmr2806195ejc.47.1710705698902; Sun, 17 Mar 2024 13:01:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710705698; cv=none; d=google.com; s=arc-20160816; b=vQdVOzXdr0ZCJ5uAkplS2c0GfwhNYNEMWk+HB0Pq9hHuFtVwjh8xznvALducZCgSMw OT2nzoocYk/GGCvug+BKRXsYIKSz13Pd47oHUn8DpXxBoG7jMrtgLfX9TbDDxMKqQvuS yw55UyeIqK9W+pUAKvMrOlCBFTyu8Jdz42WTUYUCA3m0GR49jZBADoDSkunAifNFEqKa kgebdNjWOZZ7QWRmCQmuQsnQdkKGzMeiTKMGqVoqyOUdiLWTzsF89JPgFxH3rQUw//Hc O0T/nM3pJy6YIJxc9Drl1ZvinzqEJV0c0oWrYb1Yk8G4z+SDpenIQHm7kd8oYyBoHy5Z bcaQ== 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=r3aIOvTapEuYJONq++/U/4OQiNpD746rfT8hiC6bjHc=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=ozA2ETVriqHlqeu3sndgL0g2YyszYHnPRelADgJ66FZ9TZmFg2R3bgxvvK2sfFgSoe 4Oj9pYxHv/EDG0eH4ypZ00VdITN/Gl4+x6aTPttrU/UAewvceT7AaxMts9d5H6ZvhBTy UOahgDbQYSG6vvvgd0REpfY+r3GHOcUsAKJz6QwDQ4vCwX6VFGT91fAFWIE9FjDIfrUI AhIJ5MCulyaXLWVLUVnYkoQzXWx+ArrDPC9kFjj7f3vIjo4jtyvaEbkTVfFmJBlkyLGz ZHM4ujT/ThmtYWXejsYBzTqYLCfzEXOxeETUe7W5zxq+wScToXYiM8wfznuHfdHyHE2G NtuA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=GpnDTMgt; 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 l12-20020a1709066b8c00b00a46424a602bsi3617584ejr.349.2024.03.17.13.01.38; Sun, 17 Mar 2024 13:01:38 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=GpnDTMgt; 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 03DA968D1C0; Sun, 17 Mar 2024 22:01:19 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BA30768CE16 for ; Sun, 17 Mar 2024 22:01:10 +0200 (EET) Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-513a6416058so5057699e87.1 for ; Sun, 17 Mar 2024 13:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710705670; x=1711310470; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=b9GX8cyKwQlfyvrpxZfc6WYT04QgOhpDLrJMEXt+J6c=; b=GpnDTMgtM2S0vBLyKQCSHEfAXUi30KRCFjJ9Nro8fDtyPCoLr3Ie1Szkv3uF2Gn8zG spbc/qTuSIaEBrhg8RXg/Scdex2/Ab/XhToGcSWFOD/tz4u8+7Bks8PSCNfNRzS4WNP8 yZlBEOEruW4Gpjlj9u5wR2y4yRfA8EB193JfAtg2e3ILfgUnK39VPfItF397jOujDB0K /Y5NH9nbvnVrdrhp4Ua1JTHHFgaMKnWo5bsBNJsVil083PhWg8lMOv6Zfd6Q6EOkz6vR P6kC4r+O47KNbvtNhMwRDvDTI6EM3JeOvVUfb50mjQifviWLCEnVaWq/f+tgUX3+I78H +xLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710705670; x=1711310470; 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=b9GX8cyKwQlfyvrpxZfc6WYT04QgOhpDLrJMEXt+J6c=; b=gUH0hEEyNrn/3AtVqUT6UvLFlC4CguneMcD/lpYcy7/vHU15uUtsg9TahTQuA2E6Md 7XnpwIiwswA8DvnwmN9ShjNDQq58CxmiDdZzzemq26w7tKsWRd1g2+hPvvhuxDJuKQxM X8aJq4p90UEH56XHAeJx0lnsLCsinf8j08t6xpMkHWW5YbIjCwc2H8+E+hnnh8E9hx9h HDTZXb4iAKcTJRWK6LagX6VJgVQowP//ks+JNfte0JZMRKfpuK/yEAZwKd5hH/vus9Rd zNPKOnjNQodiskKjD3+NGLzG3gphyPDgr9iDBew8qUHVgdSEepq3gWDdiJvwgQBMRC1P MtRg== X-Gm-Message-State: AOJu0YzXiP/bP8pzhM0ee/TBLK3qCMBP9eH69uJhuTSjFwGBosMeawUR 8R2HhuQIte+m16cyJP0cMeTEhSTCuEunfdKRWKnUEXAyfALydV+6xRP5wGaY X-Received: by 2002:a05:6512:2098:b0:513:80b3:3eea with SMTP id t24-20020a056512209800b0051380b33eeamr6417042lfr.56.1710705669748; Sun, 17 Mar 2024 13:01:09 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id y3-20020a056512044300b00513c844603fsm1340462lfk.41.2024.03.17.13.01.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 13:01:09 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 17 Mar 2024 22:00:39 +0200 Message-ID: <20240317200100.152097-3-jeebjp@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240317200100.152097-1-jeebjp@gmail.com> References: <20240317200100.152097-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v9 02/14] avutil/frame: add helper for freeing arrays 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: gpahwYPO4iBc --- libavutil/frame.c | 5 +++++ libavutil/frame.h | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/libavutil/frame.c b/libavutil/frame.c index ab425b2235..baac0706db 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -78,6 +78,11 @@ static void frame_side_data_wipe(AVFrame *frame) wipe_side_data(&frame->side_data, &frame->nb_side_data); } +void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd) +{ + wipe_side_data(sd, nb_sd); +} + AVFrame *av_frame_alloc(void) { AVFrame *frame = av_malloc(sizeof(*frame)); diff --git a/libavutil/frame.h b/libavutil/frame.h index b94687941d..27281c168f 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -988,6 +988,17 @@ int av_frame_apply_cropping(AVFrame *frame, int flags); */ const char *av_frame_side_data_name(enum AVFrameSideDataType type); +/** + * Free all side data entries and their contents, then zeroes out the + * values which the pointers are pointing to. + * + * @param sd pointer to array of side data to free. Will be set to NULL + * upon return. + * @param nb_sd pointer to an integer containing the number of entries in + * the array. Will be set to 0 upon return. + */ +void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd); + /** * @} */ From patchwork Sun Mar 17 20:00:40 2024 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: 47132 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:958e:b0:1a3:31a3:7958 with SMTP id iu14csp656282pzb; Sun, 17 Mar 2024 13:01:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX/lvO+5S8s7krrDxnCcy3BatjNFlnvkzwcn85PKSQtRMR2X7xCtk5EYC2OAeJoUh/5vOWEz0GD5zLumW84lDR5KVR+C1toEmqQcw== X-Google-Smtp-Source: AGHT+IFoV10PK1Bc2dXIYqf2v6a2V+uTCMW8HVmi38F953BCMS8OAkxW8yt4sieu6xGkkzHDgr1b X-Received: by 2002:a05:6402:4588:b0:568:546e:2a6a with SMTP id ig8-20020a056402458800b00568546e2a6amr4167405edb.3.1710705706974; Sun, 17 Mar 2024 13:01:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710705706; cv=none; d=google.com; s=arc-20160816; b=jhhDCvsy65RWbL6KhhLkVTGQw9Ba4rK/N6BRkPe8okOIW9TyrR0UwR4TphWaRv6YQE BRmed42Lnz9jKh8UqvJtkJ8MhqFx7mkrDey9Pdxggv/tsMaibrQiSfreOzbciKIetC0i zmy/DEthEPFvSJnGyPa47xjubOk08QG01p8ovnWF4e/N6qFPEH4zVvE9SrGxNtyAAIJ5 P2Kyq97cIetZaKNw9VIcfGUfTQn/jhkFPQwiihAZZbMJVLXqT4z4Q7a62LnvKuvKmvVa 7ydrAfU5lvX8uFueP3g4Fd7qOWGnU6lvTBd95eQP1484rLQVLpc2qMhFmKlivMdEwo5o ryaA== 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=PHjp+elTY++XM58NemnkW5o/nFmtfgvgs9zOhfQWXFE=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=WleTyi9ZLsSwstbQbF02Grm8dcsy5JBDAYhO0KfswBBXEj5Z4cnhG4XpbIeub7jSTX YqMZlgj50FrtSuvbQPNPSZ6mzju903Tg/1vArvM1RdW49WGHo/SbvPKBEEwbGo1wvRKP jv3B6AxoTMuVpPNWnnyYh29RQmho420bBqDcT6L9GLAlP3YPP7C1gkLLlBz91D3lTWX2 TLbD+O9sorujhqPrD6qf0r5CIafjxdJvUQioF+f79E786LnmkVRXJJcu+QrZf18IQTla v09cv9QOLCnYDbkX0b3R2Jt7SxgxQ5/uALuZNJJt+41Xc5vsqBlGqUIiw3tScbENhzGX uzaw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=MIN96Ubu; 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 i7-20020a05640242c700b00568d14170b6si919757edc.311.2024.03.17.13.01.46; Sun, 17 Mar 2024 13:01: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=20230601 header.b=MIN96Ubu; 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 27D7768D1F6; Sun, 17 Mar 2024 22:01:20 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 05A3868D1AC for ; Sun, 17 Mar 2024 22:01:11 +0200 (EET) Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-513e14b2bd9so1373563e87.2 for ; Sun, 17 Mar 2024 13:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710705670; x=1711310470; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=AotvT5w3UgblKqo5Lgu2NSe5ikU6BGlHNWc1J4yWfrU=; b=MIN96Ubu3rJMm+7DvBSezBOBpr8/7FutYZGUA81QhHbYhsIyFL47TQa8YTvJUV4Q9W UcAl8SHWxNlYVbSxt2y9t5NVzIzoYJqCm5Fp6GhNcS/KW6/I+GxhbZasIbeIQw55AWZ4 uQLGCfrWBfdgTJstw0TPL9BKsao/cA11KwxcdjPJJuILwwX2/+b13Ed6E21FfiuVrSG6 9nn7ul21XbGPtxpTs8JCG1etPv3q7cjVpbowAqQmSelY+CIK6zMeYdx8gOdZE6KWdUZv 8fbzyBhBlkEJopFq+jNSCH6kXTJxijDenmbqaQZIvrAUj9IMAjAEIUjwVPZz/HXWIMt9 maTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710705670; x=1711310470; 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=AotvT5w3UgblKqo5Lgu2NSe5ikU6BGlHNWc1J4yWfrU=; b=h6fVyOdcZOK8kQi5g5tae5s3sPQxpqz2vPNyNGYPYmpzfG2g7ffRZdaUlI4ogHTV1J dzxLH9cNpPuOCUbP5wj/8J6bZ9rG4ZTxWy+VQ2km4YW3HHdv8Ip1Q2xwUgZ5E50WrvDH jR+XWGuf0g0MTaW7MYtItsTDWyg9lXNMrp6+LAtYpAlMpCEXYljRnLSvSS4PH/wm12Nx Ml6xDKgu0rVFdr6fSmVBA27/w1k2JR7UERaVSXj/iouJTTpqviDiZI/jX0tzbTrrOz0g 8FPN4gUMGRgSnsnHo+4+RjzTQkayGWFjuPXhX/VMXsN0ihCgC3kDqeX3ac/Q7R3NdWnu 9x+g== X-Gm-Message-State: AOJu0YyAUNXX6mnFUYeSbFD3/vTrCMIjOeMrvxrjhDoaXJAiBM4odQsz Nj3M6lnZg1St5+LS4gi2Zx9Ry1WN2JiQMovMTaWCYRb9Y7RrNc9LZdYNlaTr X-Received: by 2002:a19:4318:0:b0:513:e623:e6b8 with SMTP id q24-20020a194318000000b00513e623e6b8mr1479310lfa.5.1710705670135; Sun, 17 Mar 2024 13:01:10 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id y3-20020a056512044300b00513c844603fsm1340462lfk.41.2024.03.17.13.01.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 13:01:09 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 17 Mar 2024 22:00:40 +0200 Message-ID: <20240317200100.152097-4-jeebjp@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240317200100.152097-1-jeebjp@gmail.com> References: <20240317200100.152097-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v9 03/14] 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: NJNQ2oVEeysu --- libavutil/frame.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index baac0706db..9ebe830c5c 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -679,23 +679,23 @@ AVBufferRef *av_frame_get_plane_buffer(const AVFrame *frame, int plane) 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(AVFrameSideData ***sd, + int *nb_sd, + 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 (*nb_sd > INT_MAX / sizeof(*sd) - 1) return NULL; - tmp = av_realloc(frame->side_data, - (frame->nb_side_data + 1) * sizeof(*frame->side_data)); + tmp = av_realloc(*sd, (*nb_sd + 1) * sizeof(*sd)); if (!tmp) return NULL; - frame->side_data = tmp; + *sd = tmp; ret = av_mallocz(sizeof(*ret)); if (!ret) @@ -706,11 +706,20 @@ 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; + (*sd)[(*nb_sd)++] = ret; return ret; } +AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame, + enum AVFrameSideDataType type, + AVBufferRef *buf) +{ + return + add_side_data_to_set_from_buf(&frame->side_data, &frame->nb_side_data, + type, buf); +} + AVFrameSideData *av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, size_t size) From patchwork Sun Mar 17 20:00:41 2024 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: 47133 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:958e:b0:1a3:31a3:7958 with SMTP id iu14csp656365pzb; Sun, 17 Mar 2024 13:01:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVHwEdVJIy6GghZgOFyjsBRH1eFQZ+Cpd9cgx3cr2oZqY+UScu33PQBCxPrd73VrPBgUdXHACNYMfXOle0jjmEJf2+ShXD/GY7fsQ== X-Google-Smtp-Source: AGHT+IG+FrlSQM4QFpVVmkokpmmDlBVAgCny77NAZ0GLgM9YtKzDK82MwjxX1SCKFwbFWt8E1M4T X-Received: by 2002:a17:906:b855:b0:a46:c11d:dd0a with SMTP id ga21-20020a170906b85500b00a46c11ddd0amr331625ejb.31.1710705714994; Sun, 17 Mar 2024 13:01:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710705714; cv=none; d=google.com; s=arc-20160816; b=c3acO3B25hFXHZspzMQxUnb20LdrQOtIHX5K8liVVdJi5i1bqkSgmfhaaEHHSt0sKI 2hNe0tXfVzOW45KYwsznzexWKksQaPjT+RWMrzLSy/tfQmBcUuvZTzb3OJ3Hj6NPysCG 9CpVPmoNKhIFy2IM0RjEUoKZo7jZ0AbBwcneuk0h7LPy8466bxC/9sm3aeSHLEtRaMFc YCPopFZi/CXRdnAvBmPo9m28Pnn46p9Udquyk4ntG5V6YI3H72SfPQkxRtd3zpPru2od KmmaKCI4WUCRo+KBkSNMdWquYoMwaJwgLfQGXcBvBejn1YHY9OzINj/lmsNWUiVD5VF9 nezg== 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=GM+9CLf68Px3c2Yn/LsB70H4KwBnjVXXBOT/91k9CC8=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=vcigwrXo4jyFmhInRshv61PZ3EWE8Swsq3hZWuGtk0I5PKQgU6o1MjyxNMjMCFLr9P wuS0iFS7T1+8XgOe96mqn0r4ZyosMD9il2i9uD+XLlGLcGAT6bRmnnFkCt117n/Pxong 0IDVPEaMMQo9WMMgV9afUEq0mXPzKS/d6RN1arq2jZvg4J/SYFa7P2LweV8TvNLAKZeu 2FcoOnB6VGBEAWN7z7rfU+veDaScaaHb5zh7HndWgO7pHiaQO6CwGiJtymg2d8LcwA4s NRgFkIXgGLgRQry3+rXshjObdSsBOmc0IrBGz7fdRV7fnYElZjpEP0Tdmk46z7VR2IXq H7aQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b="T/YAl/iu"; 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 v23-20020a1709067d9700b00a3e409474f0si3621696ejo.640.2024.03.17.13.01.54; Sun, 17 Mar 2024 13:01:54 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b="T/YAl/iu"; 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 360C668D1E9; Sun, 17 Mar 2024 22:01:21 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 69DB568D1AC for ; Sun, 17 Mar 2024 22:01:11 +0200 (EET) Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-513d247e3c4so2944842e87.0 for ; Sun, 17 Mar 2024 13:01:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710705670; x=1711310470; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=SX/5t3OnNyyrTjUoUgECAvlHZbTTCZv0dEnzDbr+2vY=; b=T/YAl/iuTe8wnfrB7HjhwGgBEgd6Wjbx6n8TpzUzauE0TQpE7sZ4o4vFvnYXN6rIWf 7JZmDixjadBzh2cvkw/lRpqXQ///7pgvAzwAkKp54PBZ0RYKkjhV1VDBNtLUXj/LBIHJ nuetpb6NrP5y9OZCEwJzJyLLXqb0RBB19QwQh4Qt5X/zmKLosZqGf35OzZOSoCAHjX79 rSBvfyU51cn57nWpv8+ODM9Oci0OWFjHpHQpPSfmYeC4YmG2WrIX9u7eWsWyj7GiPAli Yfn28iLsFuMkTPOuSJEOXN4gbu6OY7MiyteYjCpCo+R7+cWotzYvxXf4D8ka+cMR5j0k hB2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710705670; x=1711310470; 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=SX/5t3OnNyyrTjUoUgECAvlHZbTTCZv0dEnzDbr+2vY=; b=WlLExgMK0ZigiBb/4ekoimpE7mt3Icn/eZu5RFsZKP1SvKUbUfVJkoMq0+5u7EyiLW /Mswb65JOT8cv8tCTJyeMBXsc9ZR5kJ8gjYky/ePqt9um/ipMnR14h6QC1bjV+pUwiQB rxN9DLb2CGpu6fcHXvXy1e1jUpqbtNbeooAupjyJvgEvHoIu22cnVWaeRoeMuJyS1u6j oo2+1M0lqaMIgpeEBdc9V0jVjF0P0gFR+0rRWu/lWH5WIRF/0PVttSb0elto4na9ATuZ 2iPeUTZ1uybSuz0GZO699c8v7DYTjGpezCJAq7p3BiLRbrNYEJDo9EUEgQS+P2HO4y0d 1Y+A== X-Gm-Message-State: AOJu0YyL1MudefKZi3ceNcKOWkbQ4BoTJ5QPre0ZjEsh5Q/UOyBr3lB3 Ar8v/dBe//zsrJ7jLIQHS/h0qLVrvAUtQSxA0uECsZMjk1JN1yTcvi08xdHB X-Received: by 2002:a19:5e4f:0:b0:513:d3ea:ec5f with SMTP id z15-20020a195e4f000000b00513d3eaec5fmr3285246lfi.34.1710705670550; Sun, 17 Mar 2024 13:01:10 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id y3-20020a056512044300b00513c844603fsm1340462lfk.41.2024.03.17.13.01.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 13:01:10 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 17 Mar 2024 22:00:41 +0200 Message-ID: <20240317200100.152097-5-jeebjp@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240317200100.152097-1-jeebjp@gmail.com> References: <20240317200100.152097-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v9 04/14] avutil/frame: split side data removal 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: UWfWaR4NCib0 This will make it possible to reuse logic in further commits. --- libavutil/frame.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 9ebe830c5c..dd27456031 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -83,6 +83,21 @@ void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd) wipe_side_data(sd, nb_sd); } +static void remove_side_data(AVFrameSideData ***sd, int *nb_side_data, + const enum AVFrameSideDataType type) +{ + for (int i = *nb_side_data - 1; i >= 0; i--) { + AVFrameSideData *entry = ((*sd)[i]); + if (entry->type != type) + continue; + + free_side_data(&entry); + + ((*sd)[i]) = ((*sd)[*nb_side_data - 1]); + (*nb_side_data)--; + } +} + AVFrame *av_frame_alloc(void) { AVFrame *frame = av_malloc(sizeof(*frame)); @@ -801,14 +816,7 @@ int av_frame_copy(AVFrame *dst, const AVFrame *src) void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type) { - for (int i = frame->nb_side_data - 1; i >= 0; i--) { - AVFrameSideData *sd = frame->side_data[i]; - if (sd->type == type) { - free_side_data(&frame->side_data[i]); - frame->side_data[i] = frame->side_data[frame->nb_side_data - 1]; - frame->nb_side_data--; - } - } + remove_side_data(&frame->side_data, &frame->nb_side_data, type); } const char *av_frame_side_data_name(enum AVFrameSideDataType type) From patchwork Sun Mar 17 20:00:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 47134 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:958e:b0:1a3:31a3:7958 with SMTP id iu14csp656443pzb; Sun, 17 Mar 2024 13:02:04 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU2OdCZs5sfy/lRV6E4/2vGee9M7IAxkNDiSqQMFe9pTfS8R0sGN6KZVLPngqE88tSJbxSqHXRtdasDhS58fFhb/SEePVDlCleSLA== X-Google-Smtp-Source: AGHT+IE8NX50MVhYhhVMb0ZaDeirAs//6i771SHqW5P4b6MVd+x6OqyuBr3m/JomMoLLdDYXckIm X-Received: by 2002:a05:6402:43c8:b0:568:93e1:76d3 with SMTP id p8-20020a05640243c800b0056893e176d3mr6327486edc.2.1710705724092; Sun, 17 Mar 2024 13:02:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710705724; cv=none; d=google.com; s=arc-20160816; b=u6ZrOFla5/kUz54/uWQu1DRRy4kH73lULv5QUsFZagMJrQWmcHRlgoBSwFLC+oEc9d iW1U1fSthvMme7kuwa2mL+Lh3JpJL+gWxCUauZWyAGm45ev+scaMRNTW37y5n8JWwd+W gVL6rIcxl+8RVP5tqXpQ80eH3A9Mu00Fpv1wDT/gcDxRTb0yv6rl6sYt41tHmT4V+5z7 0M7o+u80OZ35wLn9gTJuON3L8er6dgoGxX8HsB3wzIdH278egoaaVs3tNnoI03fwh85+ C5LqhWXrqiVwOsszx3wlht20r4Ia9brTaEpLJhLUZP1irMZBjGT+AR7P7FZ+twL37rNe iSHw== 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=ACEFlK87Gz05289PIUDTd6t9eL+0+C75sitf+MHRRaw=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=VsbBtlVfRSSpPqC2LGOxTmzz71UV/hBR6V8TUlsRJJ8mSAeeyqTKM7ynHGqwPfoZCP iXYP3Dt420BmJ9v3bnH8sNj1kdFBLisz6Pc+OF/RUgcfquRE3JXD+LFMS5AHxD15daET fnNue6/0GroYvemm2myrTq2JKd4mibbW2F7zwN0wrsbwPQOcTfGaqNLY72PwdZ1Maf9a tyVdmtLTPP47uHVo+FOjPgp435cLe8AftibUBXil1dqC+zIjOo3R60LMXTbQkzcrZGKb P97E82dz1TYywXyvXCgV2CeMOq9hoXxswNjr1iok79ZYv8uYsqg2EaATyRSwyLi94I5e +1uQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=g9gst2qE; 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 ev7-20020a056402540700b00568a4e7e391si3256120edb.564.2024.03.17.13.02.03; Sun, 17 Mar 2024 13:02:04 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=g9gst2qE; 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 58D9568D206; Sun, 17 Mar 2024 22:01:22 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D132868D1C7 for ; Sun, 17 Mar 2024 22:01:11 +0200 (EET) Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-513da1c1f26so3564872e87.3 for ; Sun, 17 Mar 2024 13:01:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710705671; x=1711310471; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=g8V42aoe+CsKOUIPKaf5prw7AXFNwxjNRcJMOEaMS/w=; b=g9gst2qEg90TMUx9hRyB3eAVA6sEJytgIf+ayDleRH0T15ggg7XZHJ7/tcM07X8nyS raYsWgMF9FcfXbaA/2MiRV6pOWbuuAgrM1Fx+Qj6knrVXhagpbfZfsICnUl5XmIZbAyu ahjJu8cH6S67Z9zU/SV28HfA+Fjadd0Dt8PDaAhBNR4bOyy0dcYa/2qJGV478QXrQgR5 nFMhYKO8bjJj6CJeKZD9tqDw1PUOC1rHDZux3/AjPWAITkUA69obtxBliIYieRo/WU/3 WSyZru6eOf/pXBYEgPxxT52pkOkaDgl3OLqnY25IP6anKco2df3sJP4fftlnjxfkaXE4 /LDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710705671; x=1711310471; 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=g8V42aoe+CsKOUIPKaf5prw7AXFNwxjNRcJMOEaMS/w=; b=dfgomoBD4YOIctsZcErHSyg7V9MMJtS8+wvKVMNYzdgqWnAK28KnNauhhW2fiRZ6Z8 eMcEu8UdAN+4D8Zv79ur+pVCBgjbvQ3gV3ZVSudZy+B5SO1BCCAYXnK5PRTHZny8irP7 ViVj4n101HdwQ83mTbyGQW8mvOpCjvXQGBRZ8VFGev8SILfAFDIB6WGf7kf+7LdLLAqr jhNYoV7AUucTKq7YMdp6O5CU4oPY9E+R+7NEEwX/lpJj1xfaIjJvSIAh6/hQrSc66+pD NLp7k1moWSrNFYYFEfk1MS0KQnXMpftJua5muEQKgVZJXNYYDpIdLszAelGS1Hx60Ho2 Ln3A== X-Gm-Message-State: AOJu0YxWAAUshgj52YhEy0kGEVuVi5XWDR6ZP9GC5obCLkKuYq6Wtu4V mX/UUiAJN8XpeWXZURxaRGyRqDVlDMfe1yT+gY/0rjniBNeiwW9xZQynkqi3 X-Received: by 2002:ac2:5bce:0:b0:513:5a3c:e8cc with SMTP id u14-20020ac25bce000000b005135a3ce8ccmr7015926lfn.19.1710705670997; Sun, 17 Mar 2024 13:01:10 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id y3-20020a056512044300b00513c844603fsm1340462lfk.41.2024.03.17.13.01.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 13:01:10 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 17 Mar 2024 22:00:42 +0200 Message-ID: <20240317200100.152097-6-jeebjp@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240317200100.152097-1-jeebjp@gmail.com> References: <20240317200100.152097-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v9 05/14] avutil/frame: add helper for adding side data to array 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: bHodRJ8vVj37 Additionally, add an API test to check that the no-duplicates addition works after duplicates have been inserted. --- libavutil/Makefile | 1 + libavutil/frame.c | 17 ++++++ libavutil/frame.h | 22 +++++++ libavutil/tests/side_data_set.c | 103 ++++++++++++++++++++++++++++++++ tests/fate/libavutil.mak | 4 ++ tests/ref/fate/side_data_set | 14 +++++ 6 files changed, 161 insertions(+) create mode 100644 libavutil/tests/side_data_set.c create mode 100644 tests/ref/fate/side_data_set diff --git a/libavutil/Makefile b/libavutil/Makefile index e7709b97d0..4415c913a1 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -271,6 +271,7 @@ TESTPROGS = adler32 \ ripemd \ sha \ sha512 \ + side_data_set \ softfloat \ tree \ twofish \ diff --git a/libavutil/frame.c b/libavutil/frame.c index dd27456031..4074391a92 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -747,6 +747,23 @@ AVFrameSideData *av_frame_new_side_data(AVFrame *frame, return ret; } +AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, + enum AVFrameSideDataType type, + size_t size, unsigned int flags) +{ + AVBufferRef *buf = av_buffer_alloc(size); + AVFrameSideData *ret = NULL; + + if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE) + remove_side_data(sd, nb_sd, type); + + ret = add_side_data_to_set_from_buf(sd, nb_sd, 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 27281c168f..5d68d1e7af 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -999,6 +999,28 @@ const char *av_frame_side_data_name(enum AVFrameSideDataType type); */ void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd); +#define AV_FRAME_SIDE_DATA_FLAG_UNIQUE (1 << 0) + +/** + * Add new side data entry to an array. + * + * @param sd pointer to array of side data to which to add another entry, + * or to NULL in order to start a new array. + * @param nb_sd pointer to an integer containing the number of entries in + * the array. + * @param type type of the added side data + * @param size size of the side data + * @param flags Some combination of AV_FRAME_SIDE_DATA_FLAG_* flags, or 0. + * + * @return newly added side data on success, NULL on error. In case of + * AV_FRAME_SIDE_DATA_FLAG_UNIQUE being set, entries of matching + * AVFrameSideDataType will be removed before the addition is + * attempted. + */ +AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, + enum AVFrameSideDataType type, + size_t size, unsigned int flags); + /** * @} */ diff --git a/libavutil/tests/side_data_set.c b/libavutil/tests/side_data_set.c new file mode 100644 index 0000000000..793a62c009 --- /dev/null +++ b/libavutil/tests/side_data_set.c @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2023 Jan Ekström + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include "libavutil/frame.c" +#include "libavutil/mastering_display_metadata.h" + +static void print_clls(const AVFrameSideData **sd, const int nb_sd) +{ + for (int i = 0; i < nb_sd; i++) { + const AVFrameSideData *entry = sd[i]; + + printf("sd %d, %s", + i, av_frame_side_data_name(entry->type)); + + if (entry->type != AV_FRAME_DATA_CONTENT_LIGHT_LEVEL) { + putchar('\n'); + continue; + } + + printf(": MaxCLL: %u\n", + ((AVContentLightMetadata *)entry->data)->MaxCLL); + } +} + +typedef struct FrameSideDataSet { + AVFrameSideData **sd; + int nb_sd; +} FrameSideDataSet; + +int main(void) +{ + FrameSideDataSet set = { 0 }; + + av_assert0( + av_frame_side_data_new(&set.sd, &set.nb_sd, + AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT, + 0, 0)); + + // test entries in the middle + for (int value = 1; value < 4; value++) { + AVFrameSideData *sd = av_frame_side_data_new( + &set.sd, &set.nb_sd, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL, + sizeof(AVContentLightMetadata), 0); + + av_assert0(sd); + + ((AVContentLightMetadata *)sd->data)->MaxCLL = value; + } + + av_assert0( + av_frame_side_data_new( + &set.sd, &set.nb_sd, AV_FRAME_DATA_SPHERICAL, 0, 0)); + + // test entries at the end + for (int value = 1; value < 4; value++) { + AVFrameSideData *sd = av_frame_side_data_new( + &set.sd, &set.nb_sd, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL, + sizeof(AVContentLightMetadata), 0); + + av_assert0(sd); + + ((AVContentLightMetadata *)sd->data)->MaxCLL = value + 3; + } + + puts("Initial addition results with duplicates:"); + print_clls((const AVFrameSideData **)set.sd, set.nb_sd); + + { + AVFrameSideData *sd = av_frame_side_data_new( + &set.sd, &set.nb_sd, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL, + sizeof(AVContentLightMetadata), + AV_FRAME_SIDE_DATA_FLAG_UNIQUE); + + av_assert0(sd); + + ((AVContentLightMetadata *)sd->data)->MaxCLL = 1337; + } + + puts("\nFinal state after a single 'no-duplicates' addition:"); + print_clls((const AVFrameSideData **)set.sd, set.nb_sd); + + av_frame_side_data_free(&set.sd, &set.nb_sd); + + return 0; +} diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak index 80153f4395..6864ea9c03 100644 --- a/tests/fate/libavutil.mak +++ b/tests/fate/libavutil.mak @@ -148,6 +148,10 @@ FATE_LIBAVUTIL += fate-sha512 fate-sha512: libavutil/tests/sha512$(EXESUF) fate-sha512: CMD = run libavutil/tests/sha512$(EXESUF) +FATE_LIBAVUTIL += fate-side_data_set +fate-side_data_set: libavutil/tests/side_data_set$(EXESUF) +fate-side_data_set: CMD = run libavutil/tests/side_data_set$(EXESUF) + FATE_LIBAVUTIL += fate-tree fate-tree: libavutil/tests/tree$(EXESUF) fate-tree: CMD = run libavutil/tests/tree$(EXESUF) diff --git a/tests/ref/fate/side_data_set b/tests/ref/fate/side_data_set new file mode 100644 index 0000000000..7d8c684d8f --- /dev/null +++ b/tests/ref/fate/side_data_set @@ -0,0 +1,14 @@ +Initial addition results with duplicates: +sd 0, Ambient viewing environment +sd 1, Content light level metadata: MaxCLL: 1 +sd 2, Content light level metadata: MaxCLL: 2 +sd 3, Content light level metadata: MaxCLL: 3 +sd 4, Spherical Mapping +sd 5, Content light level metadata: MaxCLL: 4 +sd 6, Content light level metadata: MaxCLL: 5 +sd 7, Content light level metadata: MaxCLL: 6 + +Final state after a single 'no-duplicates' addition: +sd 0, Ambient viewing environment +sd 1, Spherical Mapping +sd 2, Content light level metadata: MaxCLL: 1337 From patchwork Sun Mar 17 20:00:43 2024 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: 47135 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:958e:b0:1a3:31a3:7958 with SMTP id iu14csp656497pzb; Sun, 17 Mar 2024 13:02:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW9mDrNm4lAPuE/6W+WAnyBSmiDFucGNHBMDYpDNjGAu6pvMdaVuI2HoKyS/Tc5604MKX2SOePLF0ex87CA7tdvlPoTI5dKu+5tLg== X-Google-Smtp-Source: AGHT+IEFxIUJpBbomf1RAxMI+aLpFZS4raZm/6bYIsjS4ko6W7ea7Pl9ToZ7mKAs+ORrrO13T9aN X-Received: by 2002:a05:6402:5418:b0:568:75c5:8fb with SMTP id ev24-20020a056402541800b0056875c508fbmr7397511edb.3.1710705732872; Sun, 17 Mar 2024 13:02:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710705732; cv=none; d=google.com; s=arc-20160816; b=z/yWI9pHQu/LlvbBEAb8+amZZhi0cVDZ+W7qhbY/iTkmhufl25VhFmh7xP6pfl+B+m aS2nYfW+IjN3JJauQ60Cv/yqjarJKFwxiHtCh9Hfkloful+L+hIzjE+3pYTJbj6fW1Td ebQ9TwG2a8TJKaQoCZXWhwErlcqb9rlc8XcPlZqYFr5+3OWi7zGkev9wxH6QsecpmZEU bmk6jRt73tfzU0nq94picbn64T1YalX9QYjoLpKcc/FUzPYuS7/6G+dSCmoaL+dQGYXJ yFOpR1Ac/bnA+tLTjbMvjj3MuTkrarYJ8qcQqyKATAnHpdH9t+XT4jJ6pv4/7gS/Miv9 +xEg== 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=4wJ7zyoWYGLjylpM7KbGqd6qiCCWiiodrGwJLCfbNgQ=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=r5ZOJUlsQ+qmqVeXLIR87hSixxuUfPO/DOxXPzEXiBP8DVmgOSEH4tunRIAlYsjXRM oBl4yT/aPsBw2YNB3TN80fP0mBN4gDfBrAiwFBqJ784Rx3EqQKnS3mEsLE9UZH3vxU3z vOw5UYj1O14cFvOb65dlwH8SdWW9HjB3/MnikXNGxOnTireXJtjVtJ3TMdqlzMmJr4F7 NNgjp6HG+pwSEa9DLGSfLqnd0s4wqX3v3VbC8AvmfWAQg753nZeR/JiHXfZy+ieoyVzB j1OVpFynyCjxctTK5cmPQjWTtBjVOdEOFHLg0EgCMtKij6nO8Bk5Es4qZEsRIWow30ru 2t7w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=YxO2gl5n; 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 r18-20020a05640251d200b0056855d684besi3908153edd.236.2024.03.17.13.02.12; Sun, 17 Mar 2024 13:02:12 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=YxO2gl5n; 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 3DDF468D1D2; Sun, 17 Mar 2024 22:01:23 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 352FE68D1CB for ; Sun, 17 Mar 2024 22:01:12 +0200 (EET) Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-51325c38d10so4229698e87.1 for ; Sun, 17 Mar 2024 13:01:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710705671; x=1711310471; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=IZWpwXhe8RWUtcBxWwVAbDpDCUE14ngk2xDfOmszF08=; b=YxO2gl5ndlNm7S67b5wZ5SxgcI6bmGB2H6QtavsEPCnlO8/YBEjx5nuMWREgmJKL8s OxYpyKK5zcg8FfKN/CTgTHPpgfEUblGOjK2k0xZalx83K/ECmhtJhOb0xkY+bi5MTxM8 3V++fM2aQoOfl+rL3fgk0M/imoH796J0I4AmucV+DVoTbp3+umOO5v4Fa63haJR2dBNA z/MYucTHkX3+j2uqFSyuJMaeERODUrXnp7bBS2Mz2yyEJ4ZdG/AseWSvyv52VXZ+ZVps G6AH5WNB4ZsIFm+a3nBqrzjDVIpnbEX4zPT8ryd0u20d6EcJ7x1D6iEU1rPvn81rOINn Yp2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710705671; x=1711310471; 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=IZWpwXhe8RWUtcBxWwVAbDpDCUE14ngk2xDfOmszF08=; b=Er+8WSc2hf5I80Irs9cB2aBzr7WXaIPCXeqZ6w/GeNi4e/5YFxkTuiKkLAApFXPRO7 9O34ZRbD0WHuz+3dQiGbRmoVjxNOYFxnroAuOScGLpMHNfy4MjQ8msHvYzRsyLwSHirN CBqm/EhywUyWQQ/wR5COjaGLbMvHDvawtzkfMEraYrr4EhYgPT8sJlmVNJVG1H6Rp1at luQfR7DcY8DIrKWMqYg+Sxpo/j1VOlOldK/dPyIBpqL/ISuVy4wkkShutuxi0V3k8wtU T89liIX0RXUuOfcj+Qb22iomiy3/ZTFVOFuvadYpNXIPIqz5h86Vq23ZrRJuw2vck28V kXQw== X-Gm-Message-State: AOJu0YwNL7Fyf65omLze6Kui9AtsF4bhAAKAGPZpqvgUUXWAnssbFsxf n6slXs2VZ6KoDoLpUy6u92SrrWQW3+3IgCI/xbIAq2QOOaczGwsvygMJLozZ X-Received: by 2002:ac2:4dbb:0:b0:513:19ce:cbde with SMTP id h27-20020ac24dbb000000b0051319cecbdemr3699402lfe.22.1710705671395; Sun, 17 Mar 2024 13:01:11 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id y3-20020a056512044300b00513c844603fsm1340462lfk.41.2024.03.17.13.01.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 13:01:11 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 17 Mar 2024 22:00:43 +0200 Message-ID: <20240317200100.152097-7-jeebjp@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240317200100.152097-1-jeebjp@gmail.com> References: <20240317200100.152097-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v9 06/14] avutil/frame: add helper for adding existing side data to array 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: y/f9gCJVkaSf --- libavutil/frame.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++ libavutil/frame.h | 20 +++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/libavutil/frame.c b/libavutil/frame.c index 4074391a92..46f976a3ed 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -98,6 +98,23 @@ static void remove_side_data(AVFrameSideData ***sd, int *nb_side_data, } } +static void remove_side_data_by_entry(AVFrameSideData ***sd, int *nb_sd, + const AVFrameSideData *target) +{ + for (int i = *nb_sd - 1; i >= 0; i--) { + AVFrameSideData *entry = ((*sd)[i]); + if (entry != target) + continue; + + free_side_data(&entry); + + ((*sd)[i]) = ((*sd)[*nb_sd - 1]); + (*nb_sd)--; + + return; + } +} + AVFrame *av_frame_alloc(void) { AVFrame *frame = av_malloc(sizeof(*frame)); @@ -764,6 +781,38 @@ AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, return ret; } +int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, + const AVFrameSideData *src, unsigned int flags) +{ + AVBufferRef *buf = NULL; + AVFrameSideData *sd_dst = NULL; + int ret = AVERROR_BUG; + + if (!sd || !src || !nb_sd || (*nb_sd && !*sd)) + return AVERROR(EINVAL); + + buf = av_buffer_ref(src->buf); + if (!buf) + return AVERROR(ENOMEM); + + if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE) + remove_side_data(sd, nb_sd, src->type); + + sd_dst = add_side_data_to_set_from_buf(sd, nb_sd, src->type, buf); + if (!sd_dst) { + av_buffer_unref(&buf); + return AVERROR(ENOMEM); + } + + ret = av_dict_copy(&sd_dst->metadata, src->metadata, 0); + if (ret < 0) { + remove_side_data_by_entry(sd, nb_sd, sd_dst); + return ret; + } + + return 0; +} + AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type) { diff --git a/libavutil/frame.h b/libavutil/frame.h index 5d68d1e7af..ce93421d60 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -1021,6 +1021,26 @@ AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, enum AVFrameSideDataType type, size_t size, unsigned int flags); +/** + * Add a new side data entry to an array based on existing side data, taking + * a reference towards the contained AVBufferRef. + * + * @param sd pointer to array of side data to which to add another entry, + * or to NULL in order to start a new array. + * @param nb_sd pointer to an integer containing the number of entries in + * the array. + * @param src side data to be cloned, with a new reference utilized + * for the buffer. + * @param flags Some combination of AV_FRAME_SIDE_DATA_FLAG_* flags, or 0. + * + * @return negative error code on failure, >=0 on success. In case of + * AV_FRAME_SIDE_DATA_FLAG_UNIQUE being set, entries of matching + * AVFrameSideDataType will be removed before the addition is + * attempted. + */ +int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, + const AVFrameSideData *src, unsigned int flags); + /** * @} */ From patchwork Sun Mar 17 20:00:44 2024 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: 47136 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:958e:b0:1a3:31a3:7958 with SMTP id iu14csp656555pzb; Sun, 17 Mar 2024 13:02:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXdiR8rgseHt2NGPrdYmsQRVc/LFo8Lw5Wg9T7RZkvilL4flLVtAmzqVcjBWmggvWlHF8lQ/Ih6Q3BvU79rhkBp47IXRYCKVD/eIQ== X-Google-Smtp-Source: AGHT+IEdUkIg60twSHWlzOmeS29Xz2WMd/qS4Eo4evDp6DeBPyss8ru92vuuDTQzp5pjemH+9N09 X-Received: by 2002:a05:6402:2401:b0:568:a05e:eafd with SMTP id t1-20020a056402240100b00568a05eeafdmr8444064eda.39.1710705741699; Sun, 17 Mar 2024 13:02:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710705741; cv=none; d=google.com; s=arc-20160816; b=Ys7d2WzjBGTV6+czQSy3h35l5nD0+JTedjzmrg9pqZu6ZFbZSXYHIDVqW6ESkVSt+w FiAA4Df/ojoS59Xs3j2/L2WTegpAlVp60S8j3poaN3hfsEVejLruisLV7F1jnbGeAnJJ ApHsSS1iiWeSt2Uib+4L8NPUARNtkAft8WdqbIX+WYWRJzg4NWvPqu/OrBs0xjKXZi3B zWQyJT67zAZ+0K3F7WOSh3EYK5MWfZkIhndZF+yfQvgduU+1F4uOvH4hSU0fYcs0vuki pKivnbKYAj3Nh6c/oYUwDyp4AUjOJYPLYgmYkjYU2gkjTHnQ9B5bq9c823AbCVQK0HWe DvMg== 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=TE2YhlWkumFdOyS/p2V5sOhgIViTCT/Jp3X4aDxEWQU=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=06ZlvVI3RIHo5+Jfv0/zYu9VMPTxdLCk6Aozkhl0BRH3iG0nJApy1Wae0PUK8YjwCV pYgVI+zV8m9gRm7wXUqm3e4zD6wvi5J/YBpzDQ/JDZKm0B/Ib5A8gLhI2EhuPzIDr61b c42r8nN9c1xj5+v7cR1RG0E6EuIGNHdhoXe1DPzaraLhaY+AHB1cDBxgo841kiiW5WBg sjgPeELP4D1+zjnRJz8ohMm+ekoMTQDMz9ekOVepuyPJ33CoOQ6nD6VSi+j1XjsdCTpL 4pLwlXAQlOlB4d3VglmAvJlL8gDCJ+rRFwfHC2HHIdVrJvPy7chB2ec80RQ0SLbFGsaP AZtw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=U6Z5Yraq; 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 z10-20020a05640235ca00b00568b65ab681si2356861edc.312.2024.03.17.13.02.21; Sun, 17 Mar 2024 13:02:21 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=U6Z5Yraq; 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 533B968D212; Sun, 17 Mar 2024 22:01:24 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A690168D1B4 for ; Sun, 17 Mar 2024 22:01:12 +0200 (EET) Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-512b3b04995so3326690e87.3 for ; Sun, 17 Mar 2024 13:01:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710705672; x=1711310472; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=qt6a8/F8bqj+RTz8gRZJFV2uZaNZU+zonBEJlN8Ye0c=; b=U6Z5YraqA2BHGSZe4a3yVN6p92egKbJLEZm6hL9pRLc9Hy19CyofBFHEXLQLNEkY9j 5yvvBhMdp5b8/UeWN7sHQshXwNN0T95Bv6jI8msFGi2huuTOBbFwNL1pORMGguaxrnEJ RCoPGdK4cu/aQnnTQJIsIa7iak6l27sF0xyHilaq9fritHTz5T0y1wQrMJcxuorkhbY2 yCm5h3v6aeG9gFdUeP7ki9noc2rYQ6QUU5B4Gwt3Zh7FHLtczZ1hMw/Hh2onqhs2/hlV WZWMkBiSpZyfl1D/pGeuMzHJqhsk+tmU/UEO8lV9I7lE/PPGyKGDfH/bn9OiIvhxQX2y 0gVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710705672; x=1711310472; 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=qt6a8/F8bqj+RTz8gRZJFV2uZaNZU+zonBEJlN8Ye0c=; b=Ww8GzcxnsOytSqkPv5OMbokeZyZVhbb2l1xScRY6+5l0fLSUZKCb9lqS37bi89+YXU JOcoawUKbGGHlCKfJpPAVYxZax21NZk5zFdra3gl5zYW2fc8dgrzl+iiI/5Um/biB0bo x1C7MBmCPdJaL6DyBkxj/OH0PLg7ogf7CD9SHZPhrT7XEigC4AejwLT3W6gq0ZV/VgKI h+O65+PNlaCJHxtdv7S+W+nUiIQLu3KCqyz/9YUfUpRuNmwCLqjuzC5WVS3A+ml4didG iuh5SPAySzxKbO2bEmXtppK09PSTaRvM18+gSkbtOrHvkwklo/JE3Y9qoSfpptw8MPXV miMw== X-Gm-Message-State: AOJu0Yy2ZIOv7N1YogMm3hU257weJCq6qZbuIP9+UsfgxAJJqYsblABa rNYe71YyV8acfKYRARCxwJdOcecLp527MpFa84oyGdiEEuUneJ/4MIl6ULr3 X-Received: by 2002:a05:6512:3b9b:b0:513:e918:42e9 with SMTP id g27-20020a0565123b9b00b00513e91842e9mr1326814lfv.62.1710705671809; Sun, 17 Mar 2024 13:01:11 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id y3-20020a056512044300b00513c844603fsm1340462lfk.41.2024.03.17.13.01.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 13:01:11 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 17 Mar 2024 22:00:44 +0200 Message-ID: <20240317200100.152097-8-jeebjp@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240317200100.152097-1-jeebjp@gmail.com> References: <20240317200100.152097-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v9 07/14] avutil/frame: add helper for adding side data w/ AVBufferRef to array 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: gNd12apsRI3d This was requested to be added in review. --- libavutil/frame.c | 43 ++++++++++++++++++++++++++++++------------- libavutil/frame.h | 21 +++++++++++++++++++++ 2 files changed, 51 insertions(+), 13 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 46f976a3ed..30db83a5e5 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -781,29 +781,46 @@ AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, return ret; } -int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, - const AVFrameSideData *src, unsigned int flags) +AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd, + enum AVFrameSideDataType type, + const AVBufferRef *buf, + unsigned int flags) { - AVBufferRef *buf = NULL; - AVFrameSideData *sd_dst = NULL; - int ret = AVERROR_BUG; + AVBufferRef *new_buf = NULL; + AVFrameSideData *sd_dst = NULL; - if (!sd || !src || !nb_sd || (*nb_sd && !*sd)) - return AVERROR(EINVAL); + if (!sd || !buf || !nb_sd || (*nb_sd && !*sd)) + return NULL; - buf = av_buffer_ref(src->buf); + new_buf = av_buffer_ref(buf); if (!buf) - return AVERROR(ENOMEM); + return NULL; if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE) - remove_side_data(sd, nb_sd, src->type); + remove_side_data(sd, nb_sd, type); - sd_dst = add_side_data_to_set_from_buf(sd, nb_sd, src->type, buf); + sd_dst = add_side_data_to_set_from_buf(sd, nb_sd, type, new_buf); if (!sd_dst) { - av_buffer_unref(&buf); - return AVERROR(ENOMEM); + av_buffer_unref(&new_buf); + return NULL; } + return sd_dst; +} + +int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, + const AVFrameSideData *src, unsigned int flags) +{ + AVFrameSideData *sd_dst = NULL; + int ret = AVERROR_BUG; + + if (!src) + return AVERROR(EINVAL); + + sd_dst = av_frame_side_data_add(sd, nb_sd, src->type, src->buf, flags); + if (!sd_dst) + return AVERROR(ENOMEM); + ret = av_dict_copy(&sd_dst->metadata, src->metadata, 0); if (ret < 0) { remove_side_data_by_entry(sd, nb_sd, sd_dst); diff --git a/libavutil/frame.h b/libavutil/frame.h index ce93421d60..a7e62ded15 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -1021,6 +1021,27 @@ AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, enum AVFrameSideDataType type, size_t size, unsigned int flags); +/** + * Add a new side data entry to an array from an existing AVBufferRef. + * + * @param sd pointer to array of side data to which to add another entry, + * or to NULL in order to start a new array. + * @param nb_sd pointer to an integer containing the number of entries in + * the array. + * @param type type of the added side data + * @param buf AVBufferRef for which a new reference will be made + * @param flags Some combination of AV_FRAME_SIDE_DATA_FLAG_* flags, or 0. + * + * @return newly added side data on success, NULL on error. In case of + * AV_FRAME_SIDE_DATA_FLAG_UNIQUE being set, entries of matching + * AVFrameSideDataType will be removed before the addition is + * attempted. + */ +AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd, + enum AVFrameSideDataType type, + const AVBufferRef *buf, + unsigned int flags); + /** * Add a new side data entry to an array based on existing side data, taking * a reference towards the contained AVBufferRef. From patchwork Sun Mar 17 20:00:45 2024 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: 47137 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:958e:b0:1a3:31a3:7958 with SMTP id iu14csp656603pzb; Sun, 17 Mar 2024 13:02:30 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUHA0uXzPscUD4y+yyN/TUElXcMjtnJLwJ3tRKnNOVIkggMTleYA6jVa6gCR1SBnOvrChfi64x0tfqeH5AEQZBlCW2Xd78pqUFmiA== X-Google-Smtp-Source: AGHT+IHl70sZDZjQ0IydehKW6HjmnysXV66U2QfCZ2XE0T6Bm8jOMJ2lqW7oZZQ3htghdDNoJu7O X-Received: by 2002:a05:6402:4284:b0:568:1100:2d95 with SMTP id g4-20020a056402428400b0056811002d95mr8730031edc.31.1710705749883; Sun, 17 Mar 2024 13:02:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710705749; cv=none; d=google.com; s=arc-20160816; b=LU42Z6WbmsiJH2p4evgxr57D5Vn89I0zhCsj4Q9wMg97zeCr4ts1CKWwnMmMJOuD+m bZRmJhQRkFRN6p63S0tOLQjhufxdfZ5zuDJEI5Yj3VCcdnND9VXRbgfes+j+QAfaey6m HCrz+RBZlzd32e8x5fPL3EG/XTEl+xIeCvaXoZCVYz9t0+wrnaJ0OiWeHgeZoWhgubEF 7pmcAnqBKpIh/UOQkvfD3Ri/QOIxF7rBn1yywpgmTikiXvm424kgvR+LqHDeCnCD9Y6U WjVLWjKf7G3MzxkfWvrKM17PWzG2YoJ5Cslb/AuSYsIRUazum0yFos/XZ+BjJeaDr8Ix ytIg== 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=pUTWJM83vSEYgpAPS00vzYNwTaKnMgdFvz2a34SpvH4=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=Di2VCTJiGzl4vknujgB6RysjMa9eZdziic0fvrH/4bg2DqDxWHqrVvd6SWI1wSNW7e bSRBbz+q9C5VcauRCfJZSRYLEnIGg/zVT0zHL6FsPrykp2HyAZsKGR3LEqDq4SBddBFD NrfTrIpM38rDxZRSKVha/86CuTWV2AHyhn75bhhQ/S8Mjonh3iOSP0EQzAlXJGmDABQ/ DUO8sS6wj1wAIF0/DuiTM5gHAvqcvIsCnPmIiFYkThe8KH0ERaVKfAUiVvrLLPiEft0E STFymagRJbgG1FiHLjbGh+GoSrShc5v+wijFE86MdZue4VqyChSyY6S3fOueon+VhLP3 R3rw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=I11lJqhP; 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 em3-20020a056402364300b00568b5637c0fsi2494681edb.618.2024.03.17.13.02.29; Sun, 17 Mar 2024 13:02:29 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=I11lJqhP; 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 60CAD68D21F; Sun, 17 Mar 2024 22:01:25 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 33E6668CE16 for ; Sun, 17 Mar 2024 22:01:13 +0200 (EET) Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-513c8b72b24so4040449e87.3 for ; Sun, 17 Mar 2024 13:01:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710705672; x=1711310472; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=d3MtCUCOihj3VKTQqRWzPEObCrL2n3nz5OOEwI2agUs=; b=I11lJqhP82i/VMa2DAXSUtXQyG+e8DejzHiHUa9K44FwBMIYtX79hFmhchDzh4Zenz i0C4uGPlTSjqi3O+FoEhG/AzQmiPa8mX0h3T0vtT96bG3juMwAicKTGe78lKUX2F39Dg M6PcOwz4RvAYVGkua9zRgZ6/asCr3OeiEtEx0Xyur3sr/N2JpsWLU9XzNZ46Ng7MpBXv kvHYg2SqkRDN2JwMvngcISGihoxNnyFaWMI5FuwqNEg2UvuRHr+4EAnKMCWDaZiKJRba E/aI+y9m1eI4esGhCLCSE0GhyZY8vuXJFIToqDrl4TFI044xJLIIokpN8cehax65V7fR 2dZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710705672; x=1711310472; 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=d3MtCUCOihj3VKTQqRWzPEObCrL2n3nz5OOEwI2agUs=; b=P1je0QIKTtIybeQurHsr2UaZjxK3EPhxxnjEdomN5EMc4Z0F3rN9tgapMfu11OCOzV ADIsVynUoJ01lxAl9AE7T17t7sPRgUPHKdUzkYuRh0hf4BDWeTopT7qI1U9NeoEgCPeW JUaLjOPaw7B/GKQK23lCiyrIIAWCn1K1DT7NXNI4dDlmhfDWxUX6GWAnPEz6LMKDbBcZ 6VjVpBW2BHxlsxFdh2YxILAQsI6ORFDD/ei6nOkYzmZHwvGunWJTY5pBe0RyuV9KfUK7 JfKwlY2GueC/KcnK7w1tbRdk6AqkRpkSoX+QpkpvCvQTWKVhBre0LAlmVP8WieVNhq7p VDiQ== X-Gm-Message-State: AOJu0YzWUJ9nIRIzWfX5eftC4uIqJeL4dxKXYQue+WHZwSCAF0KLSbBw 8g2wC4rSJ3G/0LZRrt6N3Mx/5nST4qe/3m2/8blc7uuExOWvqpG+sabnGc5U X-Received: by 2002:a05:6512:3ca6:b0:513:d3e3:f78c with SMTP id h38-20020a0565123ca600b00513d3e3f78cmr8927053lfv.40.1710705672310; Sun, 17 Mar 2024 13:01:12 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id y3-20020a056512044300b00513c844603fsm1340462lfk.41.2024.03.17.13.01.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 13:01:12 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 17 Mar 2024 22:00:45 +0200 Message-ID: <20240317200100.152097-9-jeebjp@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240317200100.152097-1-jeebjp@gmail.com> References: <20240317200100.152097-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v9 08/14] avutil/frame: add helper for getting side data from array 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: My8rjaVtSX2C --- libavutil/frame.c | 20 +++++++++++++++----- libavutil/frame.h | 14 ++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 30db83a5e5..47ecd964b8 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -830,16 +830,26 @@ int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, return 0; } -AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, - enum AVFrameSideDataType type) +const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData **sd, + const int nb_sd, + 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 < nb_sd; i++) { + if (sd[i]->type == type) + return sd[i]; } return NULL; } +AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, + enum AVFrameSideDataType type) +{ + return (AVFrameSideData *)av_frame_side_data_get( + (const AVFrameSideData **)frame->side_data, frame->nb_side_data, + type + ); +} + static int frame_copy_video(AVFrame *dst, const AVFrame *src) { int planes; diff --git a/libavutil/frame.h b/libavutil/frame.h index a7e62ded15..e59f033cce 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -1062,6 +1062,20 @@ AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd, int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, const AVFrameSideData *src, unsigned int flags); +/** + * Get a side data entry of a specific type from an array. + * + * @param sd array of side data. + * @param nb_sd integer containing the number of entries in the array. + * @param type type of side data to be queried + * + * @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. + */ +const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData **sd, + const int nb_sd, + enum AVFrameSideDataType type); + /** * @} */ From patchwork Sun Mar 17 20:00:46 2024 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: 47138 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:958e:b0:1a3:31a3:7958 with SMTP id iu14csp656668pzb; Sun, 17 Mar 2024 13:02:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVxtLY68j+q3aNdgfdKVdxs78eKl8W5uK9gT9rBQJKPa8C53vXl4VR2YZpHzMa/c+/zIYn3OB6LcbKjoZ+gcvxkUjsbkd+5z1py7Q== X-Google-Smtp-Source: AGHT+IH8uutIJlnw+NGZnba5ZeW0pO6WPL/uSfxph7TS9JlRrQuHlLnuHsIXieK2CE0m1os8N9qY X-Received: by 2002:a05:6402:5418:b0:568:75c5:8fb with SMTP id ev24-20020a056402541800b0056875c508fbmr7398123edb.3.1710705758149; Sun, 17 Mar 2024 13:02:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710705758; cv=none; d=google.com; s=arc-20160816; b=Zx6uW0Y4ayuBTzrxhFHlU8hk1Wb5ya7XrgscCCrAueTOxT2pi2XXoXXGngxjSPKrkg FNUciSZxA93F5AUR6OeYbMeVddMTeoIV610C08vJmZ23ozhNgwd3UO/R/J2wHRXK2YJz 98LHf6yKrh6la+69C1hx2+1VYXhdhFgEFET/UI+D8uY1dqmzqm3PMWMg0s/syS1oW82f qZngQBnlgivyh2A3ywE7xpHDywWwfNwH3b+oHVjjscK3weJU5RloJhefeBFyEkeHdqV4 XDiq/ZWShjw8bhugF3o7x8j1BixReinMBnjzh5VQquPMnExh6L810/WQ90uwawvGYdgk mSew== 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=+I1+B1xDDC1yxizuokZ+sfvYWyad9AUoDXT9PVWe3gU=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=o9b2eo71X4ruQUhI+kxa/7VBECdU+uDRk8//XhZJzb3BTBqDFghkr9Asw0f65Y3I47 DxEpmYe/v8vJuVTqk4njaOaYI8QPV0D47C3Ag6gL1XwNOy5Ark0nejlyAZaiX7Z/Db5p cqlsyY4OSNJF2EopGWdFqGeRtW10Bsmt5GgIFbmvWKWyZH2qWxT49Iq491iC+Cd1PJSz +lCwvrYKSzSYyMqhPItNftHE+D4HiJzGCNmdZ2uaTk0fdVqleO9+bl/Bo/VN0RqOxSkU 9zZ4fCwRRZMOxuwpI1ylrp5vH/93c5j6ca8XSieKMm84cf1U40nGYrJ7/PY5HjVvVPrx Yrew==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=MW58GQD4; 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 cs15-20020a0564020c4f00b00568c171cc3fsi1534451edb.19.2024.03.17.13.02.37; Sun, 17 Mar 2024 13:02:38 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=MW58GQD4; 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 6601568D224; Sun, 17 Mar 2024 22:01:26 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8ABCF68D1D6 for ; Sun, 17 Mar 2024 22:01:13 +0200 (EET) Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-513d717269fso3418718e87.0 for ; Sun, 17 Mar 2024 13:01:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710705673; x=1711310473; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=u1iDJE0pmgReYOrwe3+Mif8ECvv/EkpcLMErwxvKPi4=; b=MW58GQD40mDKhrY/k3CU7e7iEqS+Y1pCZZ3VUz8pQcLbMB1BgBTOH2YuN/75rOT3Ji D/QViIahZ2oWePG/87+3go87yfu0pm2G9daQSbIocZo/WZXQ4PMUGXBuQIP+eUDZaHai 6tvgo9B1FLv8jI+2QhX5WLtFBVAtWNfTsCEcTPFMpnUSwmjLJD9Y9pCSitQT4su9PHc9 INKIZuYvX1i8bsagXktjZCcXxqBjdU49Io7+QGFnP2EPlOTu21ONda2/61k77obWG20S qDp8WB10fJYygEL82JXJRTlIW0cYm1MdNfKgDSBSLjWvV2G4zFbMRzpekEHjn1s5QG5+ bg8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710705673; x=1711310473; 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=u1iDJE0pmgReYOrwe3+Mif8ECvv/EkpcLMErwxvKPi4=; b=RdLIUs02UEuZuHOtfJJ8rkHwCok1JcXFV/JmIoRugfeP+1j7NN0fNWMuNiCKSqEOOL 08q78VhUd3SCQpXH+sRCXjonOvuj+3NhN5gVhxVMQrWuc4/yRhmwLzZXLblc+BrC5lle WT3P0SlsWnXdHyHgKSANuTuc7qcA14y4uBa2e1/989F4YvCSJc4PhYkr877aaTJG0acj DpRA4n1ItFBPFMb5YK6sOlbmpd188u8f6jGdNmaDVub7J/z10+0FMhq8Wo4K/5+1NnQJ 5JvZq09gjqp44svouH0JD4Ov6EwzJA0c4RE37JJpsuPoB2zg8y/qXf0n7ciGlhSR9B8L CHhA== X-Gm-Message-State: AOJu0YySCpBjWm+Ytj/j+Xu7WHeNDBrm+o0gWD0aYmdgvB5pwZ3sJkIk K/WqRi4ZK4dFK/Pa2fUc+AeiQPmDp/Eyu2PjuZmwcE6jliPK1yJ5hIkUUEgx X-Received: by 2002:ac2:46c1:0:b0:513:97e3:43cf with SMTP id p1-20020ac246c1000000b0051397e343cfmr5663984lfo.32.1710705672722; Sun, 17 Mar 2024 13:01:12 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id y3-20020a056512044300b00513c844603fsm1340462lfk.41.2024.03.17.13.01.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 13:01:12 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 17 Mar 2024 22:00:46 +0200 Message-ID: <20240317200100.152097-10-jeebjp@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240317200100.152097-1-jeebjp@gmail.com> References: <20240317200100.152097-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v9 09/14] avcodec: add frame side data array 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: 65kNn723MldU This allows configuring an encoder by using AVFrameSideData. --- libavcodec/avcodec.h | 12 ++++++++++++ libavcodec/options.c | 2 ++ 2 files changed, 14 insertions(+) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 554501aa44..550df0e589 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2062,6 +2062,18 @@ typedef struct AVCodecContext { * Number of entries in side_data_prefer_packet. */ unsigned nb_side_data_prefer_packet; + + /** + * Array containing static side data, such as HDR10 CLL / MDCV structures. + * Side data entries should be allocated by usage of helpers defined in + * libavutil/frame.h. + * + * - encoding: may be set by user before calling avcodec_open2() for + * encoder configuration. + * - decoding: unused + */ + AVFrameSideData **encoder_side_data; + int nb_encoder_side_data; } AVCodecContext; /** diff --git a/libavcodec/options.c b/libavcodec/options.c index dcc67e497a..dd5c697da3 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -176,6 +176,8 @@ void avcodec_free_context(AVCodecContext **pavctx) av_freep(&avctx->inter_matrix); av_freep(&avctx->rc_override); av_channel_layout_uninit(&avctx->ch_layout); + av_frame_side_data_free( + &avctx->encoder_side_data, &avctx->nb_encoder_side_data); av_freep(pavctx); } From patchwork Sun Mar 17 20:00:47 2024 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: 47139 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:958e:b0:1a3:31a3:7958 with SMTP id iu14csp656752pzb; Sun, 17 Mar 2024 13:02:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUN/pFf7ddEBfwx/QUgrAsZfl41fqH721KYv9b0eZ02ur1647+vZgZ2QwJaSxS1gnL8jq89xupIe8E43vEX+f2fam9p0D8pduxeoA== X-Google-Smtp-Source: AGHT+IHVdf2QIARuryZQOu05knZkFJBdIqyZogcUbeP10qR83P5hGuTtJp6rM4nEqwfhuTD4u8LN X-Received: by 2002:a17:906:4089:b0:a46:7a84:8be2 with SMTP id u9-20020a170906408900b00a467a848be2mr5928471ejj.7.1710705767881; Sun, 17 Mar 2024 13:02:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710705767; cv=none; d=google.com; s=arc-20160816; b=XOIg/8DUiz2TxNIqnn8SCsJt5E/IECGJkRp/HzsdGc4NbXGsZ4//KP0rFCxVAngkLD sDoIciPj4t2b7WpwTGY+NwtXNXwwlIEO/9CzNRuao0Vg4INM7e8oM6eqYx/R/CN36RA3 2V7SRjkI7sff3avgOw42ZkRKlVUmF4SDk/J4pjLXGi8nTZWZEocoU15KfIbCxX/tKQg/ rKGEJSATyP5swYif4s0h3bOQYKtNCSp4b32PNjgb6SiVoF6jW3971ynxkG6v0P9u9N+e xTTTaHqLih/T0og7woOVvPsDBLk0+M34vWonxPcsoz5uwMq7DhRSqC3w5EcmHQAyBOry FMAA== 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=eA+qKBPpuJYElY1bDsIYphiAjPNS7Zm33okaURMy+3M=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=J83VbtrKGAB/0y4+U6deaMKfFCoS/CWgNkEtW8H5fSyBv8gFBYsG3slZg2pOeAmcgp QvALarLEpzAApTAVygaBWvsu5wgWmZG/zIeUuEAt5Afbbi5Kgdhzv4rG66u3ByPI5P5z NlIXZ5wiY6jcPqfJtv7gMWr4tNAMrb/X0zgeMafrNPiVTT9nLu5RU1SVynFbocO24oFb Ru+ZHuMeuLCjvAEdzg0TVm4SbQbVgT9ce162RKkWtjA/c0tjuexIn1OhDQUrxriYIghj hqrDA11dDU4B96ea8Tff4qSbk0gg2y2W7nbIzW4GbGc2aakqWZp7VlOqbEeF8Ey20lvR oLGg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=UWoqbstm; 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 hh21-20020a170906a95500b00a46a1d0d0f4si1803833ejb.89.2024.03.17.13.02.46; Sun, 17 Mar 2024 13:02:47 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=UWoqbstm; 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 9390F68D227; Sun, 17 Mar 2024 22:01:27 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1992168D1DB for ; Sun, 17 Mar 2024 22:01:14 +0200 (EET) Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-512e4f4e463so4039099e87.1 for ; Sun, 17 Mar 2024 13:01:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710705673; x=1711310473; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ZxiT/CzwLtq1GGe+tkJ8pyUKMWrKFCt1EKSb8u67Hhs=; b=UWoqbstmJmtUE7uWymsi8Y2HPvuX0nMq91x32q7U2ydTQ3q1KDiq/uPeP4dsB3jpTD ohl/O2x0wc3+JNiWj3y0xkyQzLqTDPv9cRPKN3f2WTAabBHgK9Y8S4z1BshvuvEB06FK fC/ChEz+l/PfqFZS1PrAfkz8s1zP+xEje5Teuho2FKiEJGSyrSdlu7aMDc5ug62U5Jy0 xR0f3vJe62KZeU3HFG/Ghvy2rgHryVYzXbHVLypz0h3BHW+QwbkKY2rvUdQHfvI8isHj 5SEnz+poJgZKn+O3KbN7q9BEuiKe5H3x+y1VdMjCdaqrYJRWfEqsPyrUarKP3AO1Ge+4 R/Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710705673; x=1711310473; 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=ZxiT/CzwLtq1GGe+tkJ8pyUKMWrKFCt1EKSb8u67Hhs=; b=v3HO0KBnXiHcd+yzX+skP4ZZh8x6gB+zfeZoPjCcG/Whj/e3gbNehV8IdmSSDxarP4 MXMu0CgG12nE/G0M1WMJ3bkJrLSr3LOsR2SGBTN87CC7HQznxgZWJ0fFnPAjuHoZ5ulL s7To53zEPYzBBDU6po7HGY++V7aDFrWMenSdwT4LSGQ2UREeBSIHOs/koKXKuchEkkwh vkXErbNFcAYUNECd6THwT1K3WYcVwqPrhK4HLq2KmdqemHZGA/QhHJMmkXGRCRLsDx8a jYZhwqR5hNDZ8PiWa16TR9gHGBMj69cTffQUOdFHbcP6nDHjey+1AM29RYOxO5wjFJsm l6dg== X-Gm-Message-State: AOJu0YzeXU5ntLcQI6p7/Pdp2Eeds6B9t283KUyFIqROEsnATvN86Iw0 bUO18aEIWkiL4S5Bl3qei5pB0IPjRPwbuEoglc3YBn80hIo+taraPILDC/OO X-Received: by 2002:a05:6512:68c:b0:513:db96:2be9 with SMTP id t12-20020a056512068c00b00513db962be9mr6726313lfe.64.1710705673125; Sun, 17 Mar 2024 13:01:13 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id y3-20020a056512044300b00513c844603fsm1340462lfk.41.2024.03.17.13.01.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 13:01:12 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 17 Mar 2024 22:00:47 +0200 Message-ID: <20240317200100.152097-11-jeebjp@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240317200100.152097-1-jeebjp@gmail.com> References: <20240317200100.152097-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v9 10/14] avcodec: add helper for configuring AVCodecContext's frame 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: hlDsXCYdAXuO This allows API clients that wish to configure multiple entries at a time to do so without writing the looping code themselves. --- libavcodec/avcodec.c | 31 +++++++++++++++++++++++++++++++ libavcodec/avcodec.h | 21 +++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index a9a87bb58c..3183952172 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -686,3 +686,34 @@ int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *fr return ff_decode_receive_frame(avctx, frame); return ff_encode_receive_frame(avctx, frame); } + +int avcodec_configure_side_data(AVCodecContext *avctx, + const AVFrameSideData **sd, const int nb_sd, + unsigned int flags) +{ + if (!avctx) + return AVERROR(EINVAL); + + if (!sd) { + av_frame_side_data_free( + &avctx->encoder_side_data, &avctx->nb_encoder_side_data); + return 0; + } + + if (nb_sd > 0 && nb_sd == avctx->nb_encoder_side_data && + sd == (const AVFrameSideData **)avctx->encoder_side_data) + return AVERROR(EINVAL); + + for (int i = 0; i < nb_sd; i++) { + int ret = av_frame_side_data_clone( + &avctx->encoder_side_data, &avctx->nb_encoder_side_data, sd[i], + flags); + if (ret < 0) { + av_frame_side_data_free( + &avctx->encoder_side_data, &avctx->nb_encoder_side_data); + return ret; + } + } + + return 0; +} diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 550df0e589..01085cc3c8 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3079,6 +3079,27 @@ void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size); */ int avcodec_is_open(AVCodecContext *s); +/** + * Add multiple side data entries to an AVCodecContext's array in one go, for + * example from an AVFrame. + * + * In case the function fails to add a side data entry, it will clear the + * whole side data set. + * + * @param avctx context to which the side data should be added + * @param sd array of side data to use as input. + * if null, clears out the side data for this context. + * @param nb_sd integer containing the number of entries in the array. + * @param flags Some combination of AV_FRAME_SIDE_DATA_SET_FLAG_* flags, or 0. + * + * @return negative error code on failure, >=0 on success. + * + * @see av_frame_side_data_new regarding the flags. + */ +int avcodec_configure_side_data(AVCodecContext *avctx, + const AVFrameSideData **sd, const int nb_sd, + unsigned int flags); + /** * @} */ From patchwork Sun Mar 17 20:00:48 2024 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: 47140 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:958e:b0:1a3:31a3:7958 with SMTP id iu14csp656797pzb; Sun, 17 Mar 2024 13:02:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUO41q9d5BUuUY83RlC4bqZTBxcx/eOtm6WSnRZdyIIVaSpOGsoN/LkwXrLOLoKEH93bUQj4B7OYFhxa7G983j2tdkBgY4i2uN6Sw== X-Google-Smtp-Source: AGHT+IEapIMZiL5rVo9m1b7NgYmezZ1hdHlDuJ28NLhe2uWty5HN+i00ds6Eq1bS4FW7ATg8YdFS X-Received: by 2002:a17:906:e99:b0:a46:4851:b8cb with SMTP id p25-20020a1709060e9900b00a464851b8cbmr6388506ejf.15.1710705775449; Sun, 17 Mar 2024 13:02:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710705775; cv=none; d=google.com; s=arc-20160816; b=L64YLVXMwTFVIK4fdGZDgz0G6FaGGNBnMBhQckHkWU/0kjAgUriFb/+eAJAT0w+wEe 2HChwe0JNWHZEMqdhj4vRFBVhx17u6zzl4GbcIVpKJ8rXhBQnHILxvQZZDIeI81nl46z G8KNYz8EmxINCBctf9r12nRa1hzr4RS8F+rVYGD2IXcT7DZfzGbsD97oAoM5ylfFTLyL GKI5nmo4CVGfPBjZFKt18oVxfYIGWuFUfw1DBVyMopsd73ANoDCeZwbWynRUxZ9YT0zD bjFmSUBcR7KjMs08OMIHpKyJWozCN1YPzZkClesq1Z+nVJhlRn9TgJFIHQFU0ugPLLrR bUoA== 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=g7Qkfwz2v92wPxbacC7asiWZpFunp1Mh6G8+rgLi3SI=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=We1gMA7zkquR1bOncR7nUktJaQKjZO5FyAqToiBDSSrxdLUA21TqSMUJDAv/MnxnXN dnBWrwIU33D/yR4vv+XXFboE153n0HeCQ098csJ93+aJJS3yhYLlxu/4s9mLtMB6F2/G /WRcJdVZ7Z2LaQ7p+1qDhQIbJ2L2jrPkEHiUCjb1sMCnypwNL2yRAdqm6/UDT+2vTFFi HfefNjYDyw6FX8mnWbTrtTHEDMJfTcQ2xs4JW5A7CVYZrIl7VAu4HX8KUfjBatYrzqyT mEhz+i/KTyEV6EkjOfntFmTH1ocfAqA4qFbXlAY8assBtUh5u9tt74Bl+T2KOC+0p4oq d2Rw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=ZLGFhg5I; 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 gg15-20020a170906e28f00b00a44d19c4051si3716957ejb.409.2024.03.17.13.02.55; Sun, 17 Mar 2024 13:02: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=20230601 header.b=ZLGFhg5I; 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 AED3068D1C4; Sun, 17 Mar 2024 22:01:28 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 60DDB68D1E6 for ; Sun, 17 Mar 2024 22:01:14 +0200 (EET) Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-513dc9d6938so2427546e87.2 for ; Sun, 17 Mar 2024 13:01:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710705673; x=1711310473; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=8B2WvqEqqxrUF9sBB7PKETgQ5sM02zIaUAWvQoWq3BU=; b=ZLGFhg5IqyhDUdtaKZHnSQQLWqvfSflqVo3omrxce94kDvU+7pghUIh5HE/wdZCspw SA6/AtIp6wK42lQpj8G3YOmA3qHwmMr2/L+R1LoFQmTaaMfLwFznKisltiY9HQnVvUYg HCydcbxCQm9d/kvLilOklOP+4wbWnC+McNj9nI8omB+GupfvdTOLt/9s7Vfu6VvM6so1 ML6Q64ah7YoD5qAAzOSjfTnl4j8J1uOFymjfvhmSQ9wuknUwFCYFJda6joAsvamyhfUQ SRx3/Oqs1i1lUN59pWwXGWEaKYeraR2iomdoLn598YRNgJ4JUUW9Scjn/blXRRgafdrF ZDRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710705673; x=1711310473; 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=8B2WvqEqqxrUF9sBB7PKETgQ5sM02zIaUAWvQoWq3BU=; b=MK72huENfgNgmVqzvkbSsVp2Pvj+iq6a8s0954Laq+rkXAN3lzmhGtmZNBMoiC9rcd 5hvbfdnVj1S5HOtN5TwtFlSLnUjzl3H8ryN1JVtbHYeDaxlzdzdGWaLqcxH50ItUCBBg pCfdK/8ddxmXnKSolgUC2Xe0RPfv4WZ34r0sdxo10JFikh4bRntsvzE6I5QA+k3Zhj3K JgYDJvC3SJF1SLAmU+1u31BJi9nqy/iEavJgj8K8kRwnoDrG16Vi6nXsiAxqFdB9q4tV YgHIJ+JOpY9KST6UpfDSTGqgnudNu+cf3mMw+8PrjKyUOb5SjluzT6iEpObFKa+q0ACm Ko0g== X-Gm-Message-State: AOJu0YwjqQgBCKkpTyBDBNUot7vz+5gteKPhAkmyysSBryal7jaM4LAi BdNx7khFTNZFVBUf8fh6oV/ia279OGmCuQwdhaGA8jrlhP9YLPtyZNQl6kP/ X-Received: by 2002:ac2:598c:0:b0:513:a732:4878 with SMTP id w12-20020ac2598c000000b00513a7324878mr6809868lfn.41.1710705673524; Sun, 17 Mar 2024 13:01:13 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id y3-20020a056512044300b00513c844603fsm1340462lfk.41.2024.03.17.13.01.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 13:01:13 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 17 Mar 2024 22:00:48 +0200 Message-ID: <20240317200100.152097-12-jeebjp@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240317200100.152097-1-jeebjp@gmail.com> References: <20240317200100.152097-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v9 11/14] 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: vndMYmSWZjzk 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_enc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index c9a12af139..c8d15fb999 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -246,6 +246,16 @@ int enc_open(void *opaque, const AVFrame *frame) enc_ctx->colorspace = frame->colorspace; enc_ctx->chroma_sample_location = frame->chroma_location; + ret = avcodec_configure_side_data( + enc_ctx, + (const AVFrameSideData **)frame->side_data, frame->nb_side_data, + AV_FRAME_SIDE_DATA_FLAG_UNIQUE); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "failed to configure video encoder: %s!\n", + av_err2str(ret)); + return ret; + } + if (enc_ctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME) || (frame->flags & AV_FRAME_FLAG_INTERLACED) #if FFMPEG_OPT_TOP From patchwork Sun Mar 17 20:00:49 2024 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: 47141 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:958e:b0:1a3:31a3:7958 with SMTP id iu14csp656890pzb; Sun, 17 Mar 2024 13:03:04 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUo+eDLsFrovDhfvhDfC2eJYyplrsHVBz/aOer2gQBQhWApbmWaTzMz0Uk6RDp1ZhgbppTy4TcSMtNdh12lTQCqNVUiViQIfZB76Q== X-Google-Smtp-Source: AGHT+IEOEoky1nNpcGMg59yVmLE8do2JC6g1MVzCoixKyJYgJ6i8LCKpHsOkDU+D7o6xDUQySl05 X-Received: by 2002:a50:d7d7:0:b0:568:a226:6685 with SMTP id m23-20020a50d7d7000000b00568a2266685mr8871134edj.8.1710705783944; Sun, 17 Mar 2024 13:03:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710705783; cv=none; d=google.com; s=arc-20160816; b=xLesu61ye9Gh5O142gCDfvFcUNGJFg53NJkUNWmzcpakPmO6WyyzXQdXppaKfvvRbk uMbHEoZSoA7e2H+sFZzNxW1cGMny44e+0VMGG1uQbo4j2uIHmR3E7CD/cNgyfhZaBlT4 1svAhPK2G9jMxZ6GHXjGZW1d451za6JtfmI76VY98tuK5PvuLv4ixKavbnN1mEXMjG5u 4b+oEnuDV57+CRdeH9wGf19KZkJhQQ4fK4ewmvHR6cvHHd/q10+Pr3t5ohnAktr0k5O2 cEPtjgnIDJ93X89VEyTT7/vJUZC25rLtsYPFcqiT8ayXAUIlhITghiSrSapNeV8y/GaI moeg== 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=RucBzEjN2F3+A36vFURYyuXjUs0/x3uWTO3+1njt0Zs=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=q3uuX+xMUxtwTR5MClh4dUrKh5K3LD4Ns4ydZDr6jDImJlrSU5i+xDDyYqT27WUsy5 Y9v/SHYofWav8/WO/cRfYQjkfkFAczuHm/DpMW44ekI0M2kc9To8FNIH1iGBO+QAAFLm fo1Uy6X11+v8NpJ3sBuaYUbipTVTni9q8ZUMICs6E+6R0oII5wclgI/eEXbetu3QOIPY FvHx/XRSa9kik/F581q/H1Gn3fJ+C9dqOvZTvXQpcYipeu/B2OzX8ExO+ZWd1/fMRJyk 4sSXrQ/PcYNNuXEP9gzJg/rmnK1vTFf/VU1f14iUB66Mt58PiBntuZ96W/p2b3Ay+Km0 ZBcQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=kO6nOuiz; 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 ij15-20020a056402158f00b00568305de8ebsi3742961edb.523.2024.03.17.13.03.03; Sun, 17 Mar 2024 13:03: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=20230601 header.b=kO6nOuiz; 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 BB2FC68D233; Sun, 17 Mar 2024 22:01:29 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BC03868D1EB for ; Sun, 17 Mar 2024 22:01:14 +0200 (EET) Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-513e6778112so501591e87.1 for ; Sun, 17 Mar 2024 13:01:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710705674; x=1711310474; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=quvHXO8aDwWeGD72escILk6z09t416aVosdKEDEK8ik=; b=kO6nOuiz0R3wKpaGVoew6QbA3eDeu8xYjYtnK7Gn9qKJbyAZkVwABmeR/gjiklBh7Y 8xX+1NxyV/pommg/x4A3LoOl1Yb59I4v7eyRAGaW3CEAhx+WbeUV0z0NeSrPMKLjXLQc hwq0XvqhlYwF6PGt1+Rer3x3uoTs88z59uJ6CEw/JU3WbfR34xhIUrLPOO/R9NMdIzn1 OMVZEFgtNp33qbVRvvvetILaivilRSu+BwGB0f5jVzOAYfFx4vwFyPQDCxkHHn5Wx8EE wW+lkJecFrdyXrAcrZr8xbodhAaME07sRb168TXcgsVlqvFKQUctL0ewBT/yBA9rK8Zo QTZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710705674; x=1711310474; 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=quvHXO8aDwWeGD72escILk6z09t416aVosdKEDEK8ik=; b=vQK8bX+vb1Ja5VSoZxx+XfbqOZ8BqaW0w1mPajn1QaNCt9COxC1xM+Cnm5+uHsQV3A N2KW45KdrgSb5p2fpKeuQAsl2vH50uhKPsq4NVldmYZKlT3fVe8hg0SV1p+krvyUhGLq pLmQPIQD2bn07JWELIqlGPickhpk1m9WNHxuYMN49mbUl6X95ZomfWHSEAnPaFSdeWf5 LMYczJih1u3iyTrSygHsA7ngAX+zLzdOso12SHtDwRM7RQBXA21I9Kmp3ROhgq/xmSMY VlzJgQCqm8TDMmtuapZEVjvEIrEqz0hzdbxjkkFCjOaJNTooml6Zp4ADwmBJWspBOeTI n8yw== X-Gm-Message-State: AOJu0YxkF+6Wf8mthgkgMNsLMocSVJXnnNyj2rRkT8I9Wl88JtdKc0pl ZH0PaauVwfOESQKiBzI44sba6lPJ3INdSoRkNdAUyH4IOf4dv6mLhe5Ypufl X-Received: by 2002:ac2:5bc8:0:b0:513:cc74:992b with SMTP id u8-20020ac25bc8000000b00513cc74992bmr4019435lfn.19.1710705673923; Sun, 17 Mar 2024 13:01:13 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id y3-20020a056512044300b00513c844603fsm1340462lfk.41.2024.03.17.13.01.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 13:01:13 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 17 Mar 2024 22:00:49 +0200 Message-ID: <20240317200100.152097-13-jeebjp@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240317200100.152097-1-jeebjp@gmail.com> References: <20240317200100.152097-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v9 12/14] 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: baYCYLm5T/EO 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. Additionally, add a FATE test which verifies that pass-through of the MDCV/CLL side data is working during encoding. --- libavcodec/libsvtav1.c | 69 ++++++++++++++++++++++++++++++++++ tests/fate/enc_external.mak | 5 +++ tests/ref/fate/libsvtav1-hdr10 | 14 +++++++ 3 files changed, 88 insertions(+) create mode 100644 tests/ref/fate/libsvtav1-hdr10 diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c index 7721e01677..73bfdba3cf 100644 --- a/libavcodec/libsvtav1.c +++ b/libavcodec/libsvtav1.c @@ -27,6 +27,8 @@ #include "libavutil/common.h" #include "libavutil/frame.h" #include "libavutil/imgutils.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/mastering_display_metadata.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "libavutil/avassert.h" @@ -136,6 +138,71 @@ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc) } +static void handle_mdcv(struct EbSvtAv1MasteringDisplayInfo *dst, + const AVMasteringDisplayMetadata *mdcv) +{ + if (mdcv->has_primaries) { + const struct EbSvtAv1ChromaPoints *const points[] = { + &dst->r, + &dst->g, + &dst->b, + }; + + for (int i = 0; i < 3; i++) { + const struct EbSvtAv1ChromaPoints *dst = points[i]; + const AVRational *src = mdcv->display_primaries[i]; + + AV_WB16(&dst->x, + av_rescale_q(1, src[0], (AVRational){ 1, (1 << 16) })); + AV_WB16(&dst->y, + av_rescale_q(1, src[1], (AVRational){ 1, (1 << 16) })); + } + + AV_WB16(&dst->white_point.x, + av_rescale_q(1, mdcv->white_point[0], + (AVRational){ 1, (1 << 16) })); + AV_WB16(&dst->white_point.y, + av_rescale_q(1, mdcv->white_point[1], + (AVRational){ 1, (1 << 16) })); + } + + if (mdcv->has_luminance) { + AV_WB32(&dst->max_luma, + av_rescale_q(1, mdcv->max_luminance, + (AVRational){ 1, (1 << 8) })); + AV_WB32(&dst->min_luma, + av_rescale_q(1, mdcv->min_luminance, + (AVRational){ 1, (1 << 14) })); + } +} + +static void handle_side_data(AVCodecContext *avctx, + EbSvtAv1EncConfiguration *param) +{ + const AVFrameSideData *cll_sd = + av_frame_side_data_get( + (const AVFrameSideData **)avctx->encoder_side_data, + avctx->nb_encoder_side_data, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); + const AVFrameSideData *mdcv_sd = + av_frame_side_data_get( + (const AVFrameSideData **)avctx->encoder_side_data, + avctx->nb_encoder_side_data, + AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); + + if (cll_sd) { + const AVContentLightMetadata *cll = + (AVContentLightMetadata *)cll_sd->data; + + AV_WB16(¶m->content_light_level.max_cll, cll->MaxCLL); + AV_WB16(¶m->content_light_level.max_fall, cll->MaxFALL); + } + + if (mdcv_sd) { + handle_mdcv(¶m->mastering_display, + (AVMasteringDisplayMetadata *)mdcv_sd->data); + } +} + static int config_enc_params(EbSvtAv1EncConfiguration *param, AVCodecContext *avctx) { @@ -254,6 +321,8 @@ FF_ENABLE_DEPRECATION_WARNINGS /* 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); diff --git a/tests/fate/enc_external.mak b/tests/fate/enc_external.mak index 7eabebcc51..d787941c16 100644 --- a/tests/fate/enc_external.mak +++ b/tests/fate/enc_external.mak @@ -2,5 +2,10 @@ FATE_ENC_EXTERNAL-$(call ENCDEC, LIBX264 H264, MOV, H264_DEMUXER) += fate-libx26 fate-libx264-simple: CMD = enc_external $(TARGET_SAMPLES)/h264-conformance/BA1_Sony_D.jsv \ mp4 "-c:v libx264" "-show_entries frame=width,height,pix_fmt,pts,pkt_dts -of flat" +# test for SVT-AV1 MDCV and CLL passthrough during encoding +FATE_ENC_EXTERNAL-$(call ENCDEC, LIBSVTAV1 HEVC, MOV, HEVC_DEMUXER LIBDAV1D_DECODER) += fate-libsvtav1-hdr10 +fate-libsvtav1-hdr10: CMD = enc_external $(TARGET_SAMPLES)/hevc/hdr10_plus_h265_sample.hevc \ + mp4 "-c:v libsvtav1" "-show_frames -show_entries frame=side_data_list -of flat" + FATE_SAMPLES_FFMPEG_FFPROBE += $(FATE_ENC_EXTERNAL-yes) fate-enc-external: $(FATE_ENC_EXTERNAL-yes) diff --git a/tests/ref/fate/libsvtav1-hdr10 b/tests/ref/fate/libsvtav1-hdr10 new file mode 100644 index 0000000000..6f0d34903b --- /dev/null +++ b/tests/ref/fate/libsvtav1-hdr10 @@ -0,0 +1,14 @@ +frames.frame.0.side_data_list.side_data.0.side_data_type="Mastering display metadata" +frames.frame.0.side_data_list.side_data.0.red_x="17367/65536" +frames.frame.0.side_data_list.side_data.0.red_y="45220/65536" +frames.frame.0.side_data_list.side_data.0.green_x="9830/65536" +frames.frame.0.side_data_list.side_data.0.green_y="3932/65536" +frames.frame.0.side_data_list.side_data.0.blue_x="44564/65536" +frames.frame.0.side_data_list.side_data.0.blue_y="20972/65536" +frames.frame.0.side_data_list.side_data.0.white_point_x="20493/65536" +frames.frame.0.side_data_list.side_data.0.white_point_y="21561/65536" +frames.frame.0.side_data_list.side_data.0.min_luminance="82/16384" +frames.frame.0.side_data_list.side_data.0.max_luminance="256000/256" +frames.frame.0.side_data_list.side_data.1.side_data_type="Content light level metadata" +frames.frame.0.side_data_list.side_data.1.max_content=1000 +frames.frame.0.side_data_list.side_data.1.max_average=200 From patchwork Sun Mar 17 20:00:50 2024 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: 47142 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:958e:b0:1a3:31a3:7958 with SMTP id iu14csp656963pzb; Sun, 17 Mar 2024 13:03:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVnQyIC04NzDvp5/4w7x9sFJzH9DkJvuIgZYv5dlQnkrGGEG3AjOBZMF4QYcgLhhTZma/RE63GWQnWktTBexg5fEzaC1v8Sd9Qu5g== X-Google-Smtp-Source: AGHT+IGpxyJjDH6Fq/K/PFFvmh/1KsY50NNtKNHsdyUWaW4TBTU8t0xJgh4L7erc0X7bezTjKgnE X-Received: by 2002:a05:6402:1d34:b0:568:29f8:1d79 with SMTP id dh20-20020a0564021d3400b0056829f81d79mr3356349edb.38.1710705792965; Sun, 17 Mar 2024 13:03:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710705792; cv=none; d=google.com; s=arc-20160816; b=kN2UIaI/uKgo9UaWG2kNrQBBzVjQv0CX+s3/EY/mwFdUAtNHEHrFDYzOxpyJ2kSlSk FcF/2I7oTqBgwm+jrCqRFr8+rauLfZePbgtoZMPmf1MLjYxejHEh2fGP80Fxsg3or0/p Xsl3AR/pC0SC720i74tOobYnI4ABSHO4ZQ7HnovbAWBZgn4A0aG28nKWovr2XVpUX509 NFocROR/Pobo+OUlABGTZ1wNuroRwBU9mk3myPEqdjM0W1RXuTmDprbPrNdwrVcW2Ldw 4BLHUbpHk45svFb03Ytlgh1CKcyB5uA2BnisB0497AUvi7xDPRvOpxPvtUKjshhqL7EW jDPg== 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=L7YZU3OvN+QFtDmQPV0NzfEIm+nBKCt9MqREYzP0Q4I=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=chZj62i7WdSQJyGfh7odHuROmIzs3taeyIGcwWwWKMIRNk6Q3KYw+e4LHeP/Lwe0aL p0g6xG9pJW575hHSXx6jZsrOdq5fPtzHxYi67JaOWrhHqlqsZbi/P6WxSzEoSOG4+7II Df1efi8lFasydcukYGZ/ut7cUCp/DJe5tJsj9o0sHi88Rqa5LQsNxnHlyKjPO0TJZ/Pr 7jJQD4MPHHIHV7er85clSiZRTBacdpvxuxZcpTwfXoW8esRerifLhFwcPAZ1nCyGr3BD SNaMIsKJpNOHRICITXNexkJ2arBli8XJLgmv6Klf6VENrv0rT4AsAtF+pFflfPaKjrmy rivQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=aovpvOGT; 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 i11-20020aa7c70b000000b0056864c54b3csi3842322edq.195.2024.03.17.13.03.12; Sun, 17 Mar 2024 13:03:12 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=aovpvOGT; 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 BCE5C68D23A; Sun, 17 Mar 2024 22:01:30 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2CF5D68D1F8 for ; Sun, 17 Mar 2024 22:01:15 +0200 (EET) Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-513ccc70a6dso6283062e87.1 for ; Sun, 17 Mar 2024 13:01:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710705674; x=1711310474; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=f/Gbxp8WMV/zy0OuzeRGkJO13SKaoQ/jWnZiOZQGSHo=; b=aovpvOGTeP2H54mocfvuu2+/CVE9DkyrhF1OgwVrgcDnrdPGFwzbAPA5AubAX3MDZN hDPIAGeJvvrg5qPf4DVeRFRB2ayWnk7SljTQUslBEa2NXcF8BTHY4R+zfCa+MZAiK27o Mvj7iAOTeSkR+c8iYi1SB06cKlDRKl9HiZ5F2FpRNFFszdpCLWyawClzZ81rzT8QEDtt 5Q6cbAZ0NqDGw+cNccUT/krJ+rGMUs1rXbo3oz7bPyWYatg5J8gbL9SpwV0KCFYnP3q9 /XkzHH7upEhanIbhOyQgJqL/wAynUn1mj21yf6UlzBlVbEI0a3MMk9NY9K7xQWuyxqGQ 4+Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710705674; x=1711310474; 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=f/Gbxp8WMV/zy0OuzeRGkJO13SKaoQ/jWnZiOZQGSHo=; b=PEtEkuyfnDQRlPnZlFOXs4skP+y0uX0/7Okyek9D29l1HW3r5/2cc/aJOhGtrZdC3A AIA5dXrOu/5i162SKdUDGtZBYUVtKDf6O5FpOc5EooO30OMP9+cYaVyGV+J1riNaSfmx 7EERk7zapp91dWe3l6aUbn1T66o+hJ1O4cU+PC0LT821FzRs6cbaJK0f1JkhtLo+aG5/ IRZ/fLoidoN/l63BB4R7mzoMFgXm7zZKJ1BoLcVrwtc0zAjoAeMwkfKBbHtvSyXIfjOq Ndh8z7/1dog0fzHL9Y4mEgRJGT4m+UQ9ZQWvYlYKopUaRHFJQmYIIT90y3J1R581Caeu vByQ== X-Gm-Message-State: AOJu0YyTK5GS/BPACkZ+5/uAio7POXQ9VeNKIYew3y+odoPAVDz26RHs 8j2btzqfRtP15sds3iXwJUQFQBjIZJBvMo2RvkrBoBfXc5qCXa8FzM7sCaUv X-Received: by 2002:ac2:5b05:0:b0:513:cdb4:4d46 with SMTP id v5-20020ac25b05000000b00513cdb44d46mr3824185lfn.31.1710705674358; Sun, 17 Mar 2024 13:01: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 y3-20020a056512044300b00513c844603fsm1340462lfk.41.2024.03.17.13.01.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 13:01:14 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 17 Mar 2024 22:00:50 +0200 Message-ID: <20240317200100.152097-14-jeebjp@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240317200100.152097-1-jeebjp@gmail.com> References: <20240317200100.152097-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v9 13/14] 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: 7hKFNIL55OLh 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. Finally, add a FATE test which verifies that pass-through of the MDCV/CLL side data is working during encoding. --- configure | 2 + libavcodec/libx264.c | 80 ++++++++++++++++++++++++++++++++++++ tests/fate/enc_external.mak | 5 +++ tests/ref/fate/libx264-hdr10 | 15 +++++++ 4 files changed, 102 insertions(+) create mode 100644 tests/ref/fate/libx264-hdr10 diff --git a/configure b/configure index 2b4c4ec9a2..44be4ef819 100755 --- a/configure +++ b/configure @@ -2531,6 +2531,7 @@ CONFIG_EXTRA=" jpegtables lgplv3 libx262 + libx264_hdr10 llauddsp llviddsp llvidencdsp @@ -6925,6 +6926,7 @@ enabled libx264 && require_pkg_config libx264 x264 "stdint.h x264.h" x require_cpp_condition libx264 x264.h "X264_BUILD >= 122" && { [ "$toolchain" != "msvc" ] || require_cpp_condition libx264 x264.h "X264_BUILD >= 158"; } && + check_cpp_condition libx264_hdr10 x264.h "X264_BUILD >= 163" && check_cpp_condition libx262 x264.h "X264_MPEG2" enabled libx265 && require_pkg_config libx265 x265 x265.h x265_api_get && require_cpp_condition libx265 x265.h "X265_BUILD >= 89" diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 0997c4e134..2a8d71cd0b 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" @@ -853,6 +854,83 @@ static int convert_pix_fmt(enum AVPixelFormat pix_fmt) return AVERROR(EINVAL);\ } +#if CONFIG_LIBX264_HDR10 +static void handle_mdcv(x264_param_t *params, + const AVMasteringDisplayMetadata *mdcv) +{ + if (!mdcv->has_primaries && !mdcv->has_luminance) + return; + + params->mastering_display.b_mastering_display = 1; + + if (mdcv->has_primaries) { + int *const 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 + }, + }; + + 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 }); + } + + if (mdcv->has_luminance) { + 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 // CONFIG_LIBX264_HDR10 + +static void handle_side_data(AVCodecContext *avctx, x264_param_t *params) +{ +#if CONFIG_LIBX264_HDR10 + const AVFrameSideData *cll_sd = + av_frame_side_data_get( + (const AVFrameSideData **)avctx->encoder_side_data, + avctx->nb_encoder_side_data, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); + const AVFrameSideData *mdcv_sd = + av_frame_side_data_get( + (const AVFrameSideData **)avctx->encoder_side_data, + avctx->nb_encoder_side_data, + 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 // CONFIG_LIBX264_HDR10 +} + static av_cold int X264_init(AVCodecContext *avctx) { X264Context *x4 = avctx->priv_data; @@ -1153,6 +1231,8 @@ FF_ENABLE_DEPRECATION_WARNINGS 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; diff --git a/tests/fate/enc_external.mak b/tests/fate/enc_external.mak index d787941c16..4095a4b51a 100644 --- a/tests/fate/enc_external.mak +++ b/tests/fate/enc_external.mak @@ -7,5 +7,10 @@ FATE_ENC_EXTERNAL-$(call ENCDEC, LIBSVTAV1 HEVC, MOV, HEVC_DEMUXER LIBDAV1D_DECO fate-libsvtav1-hdr10: CMD = enc_external $(TARGET_SAMPLES)/hevc/hdr10_plus_h265_sample.hevc \ mp4 "-c:v libsvtav1" "-show_frames -show_entries frame=side_data_list -of flat" +# test for x264 MDCV and CLL passthrough during encoding +FATE_ENC_EXTERNAL-$(call ENCDEC, LIBX264 HEVC, MOV, LIBX264_HDR10 HEVC_DEMUXER H264_DECODER) += fate-libx264-hdr10 +fate-libx264-hdr10: CMD = enc_external $(TARGET_SAMPLES)/hevc/hdr10_plus_h265_sample.hevc \ + mp4 "-c:v libx264" "-show_frames -show_entries frame=side_data_list -of flat" + FATE_SAMPLES_FFMPEG_FFPROBE += $(FATE_ENC_EXTERNAL-yes) fate-enc-external: $(FATE_ENC_EXTERNAL-yes) diff --git a/tests/ref/fate/libx264-hdr10 b/tests/ref/fate/libx264-hdr10 new file mode 100644 index 0000000000..99c11677f0 --- /dev/null +++ b/tests/ref/fate/libx264-hdr10 @@ -0,0 +1,15 @@ +frames.frame.0.side_data_list.side_data.0.side_data_type="H.26[45] User Data Unregistered SEI message" +frames.frame.0.side_data_list.side_data.1.side_data_type="Mastering display metadata" +frames.frame.0.side_data_list.side_data.1.red_x="13250/50000" +frames.frame.0.side_data_list.side_data.1.red_y="34500/50000" +frames.frame.0.side_data_list.side_data.1.green_x="7500/50000" +frames.frame.0.side_data_list.side_data.1.green_y="3000/50000" +frames.frame.0.side_data_list.side_data.1.blue_x="34000/50000" +frames.frame.0.side_data_list.side_data.1.blue_y="16000/50000" +frames.frame.0.side_data_list.side_data.1.white_point_x="15635/50000" +frames.frame.0.side_data_list.side_data.1.white_point_y="16450/50000" +frames.frame.0.side_data_list.side_data.1.min_luminance="50/10000" +frames.frame.0.side_data_list.side_data.1.max_luminance="10000000/10000" +frames.frame.0.side_data_list.side_data.2.side_data_type="Content light level metadata" +frames.frame.0.side_data_list.side_data.2.max_content=1000 +frames.frame.0.side_data_list.side_data.2.max_average=200 From patchwork Sun Mar 17 20:00:51 2024 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: 47143 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:958e:b0:1a3:31a3:7958 with SMTP id iu14csp657030pzb; Sun, 17 Mar 2024 13:03:22 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUFirdeO5Mz9qIyx/t1fIFb7BVFY8GigxDlO75sp4px6lV97Ispi1NKMHtV+ye3lOxXE36lw+EV5yRiGEPcsXi5o4vSYOVl4R75rg== X-Google-Smtp-Source: AGHT+IGjjAEEgJH4bFIzQsI+GahqiY+Gbi8KcHKZXXZVPfb7xx6OzPZwgsuffMLzu7tBY1YS3Oye X-Received: by 2002:a17:907:1007:b0:a46:8da3:fd17 with SMTP id ox7-20020a170907100700b00a468da3fd17mr4385452ejb.69.1710705802373; Sun, 17 Mar 2024 13:03:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710705802; cv=none; d=google.com; s=arc-20160816; b=CUUwBpkoIxUhm7mMiRROKSk+KyQvJ6P01D+B28Q3s7NmBhQ24vXmRPz3MfOaaoiUVm lB4W7mr2sxTblILOYuEg1rHgNVYOKzRu1jEN/XYu0z3I7KlVS/6O8a8bXeK91mmhjRcc QQDuxZK+N4N4gxCa5KphrI3Ep9oJW5tzpRN0Bg8ybOvq3hxexvYK7Lw1gEhktrWViY0C kpL9WEuYKTigAF2J4KSX5aUIwZTB16paxHrDitkV0+n8jOSJoBCpKGwhz06u87L1m76m yv+U4RAttltv7IvFylTezOqbw7lmNbggncQL6dvp5OZ6g2R7rhXQ1Y0rSV6Xm2tXjpfO kzeQ== 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=j8h7l+XX/+KHKkN1FGA0EdvKpWeGkJHagZlZCw1il4o=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=lxW9U6/rS9G4imxS4fs4cFNBJ0I6qd9nW3sx9OwNr6utsOVZLp18BFxXBiBoWsXpuy 8H3RPKjJan29EBvbcFDlptcX/vztNR4staVdP9TzJ2tP33Rn84+SL05EQM4HAglNHH5a 4Fv4zhEQo3q1+CNMcOvFoEJNfQeu7VWLNZMHMxbMXKhEqRNPy8biEHmzyagdxJbc7Kfv Zd58UoJQQW9S6CD2wuvMt4f6jgDb+Zy9itHmk9BoVq6lBOVxWvEveIw7VToOcuEK++oK +BcAC2e5iYYtCwNp9R+LfNNqR1+6yjW0I4FAA5zyqaEp8LAOik25eD7ag6UW+cNTuoU3 jZ1Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=nEEYbLKO; 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 g11-20020a170906348b00b00a440cbc0b95si3744979ejb.307.2024.03.17.13.03.21; Sun, 17 Mar 2024 13:03:22 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=nEEYbLKO; 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 BAB5B68D242; Sun, 17 Mar 2024 22:01:31 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 93F2968D1FC for ; Sun, 17 Mar 2024 22:01:15 +0200 (EET) Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-513dc9d6938so2427554e87.2 for ; Sun, 17 Mar 2024 13:01:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710705675; x=1711310475; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ifT8srkGCY/6JTqzH5gNjLat77CwfCY6fvkfVkvhDDI=; b=nEEYbLKOFUxJfBZ9+IXlUYgrqhM5bss6E7zIjlj1MvJ+4nsEdmbkIXAojCVY7O1ZbK AZftZ8JHZQjUnuNmGNztfuNjrdkNYlek87TAsD/uuLGkQe+gXzXNSuznoxRSUdSi2Cgn LVW9h422ZGPzpSR1iEG1L/R9IX8yxOtLyV0BdadAc/+UorwZnQAwUyE4sxU8Pp5yLCaA gITI72JZpShaVYVarcIjX5/z5bwf4Hx2GK3tlgCmfVOBbdAPWy/qKvEpbU1gF81mk5ni b8w+apc5LLajj7cJfuWVIiryNhLz2f75CCpOq6VHqNTxanc0wKQ5gh/Ihk4P1jUDwk60 oiQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710705675; x=1711310475; 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=ifT8srkGCY/6JTqzH5gNjLat77CwfCY6fvkfVkvhDDI=; b=edvxLDBbtdu2Qvrv7GMtcUQLXijGDBe9+YSRU5BSCJEeNGVqDkWgejtBurQW+8u9Yt VIVT1R9cHFSDKbgTAEQ/9pqUi2Esc5RqAzVF7jCOWMobpqy3iaxIMfNriOYpfOZceAbn 5Y0rRNvB+NjrrIQxB616LUKvE5aQAumwxGT2DwNwO4kUS52co1EOSpnHUiLNnaF4w/bG H/sla8KjeJx0NXxdeI13XWyHif98bThDi0VLxbxgqDfVWN+mN9C5JcEK4u5cWWwbu1D/ hAINyc83Yk5KH0UJ1ktoNHsX2Kk50zGKqOI015y3iMmKr0J1SYYeyiL9iK4LmMxL7a9j 7XMw== X-Gm-Message-State: AOJu0YzpWC885NMk9PSZIxmwgLwuFjpAgFsWhLX0XtltSVTrvePtDksf AB9X/Nb3RfAexxnB+evT3kYgcEK2rQ2ZKrDS9UsBLyZt/kvkmaL/XE7xStlY X-Received: by 2002:a05:6512:12d6:b0:513:d524:3790 with SMTP id p22-20020a05651212d600b00513d5243790mr7233111lfg.43.1710705674807; Sun, 17 Mar 2024 13:01: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 y3-20020a056512044300b00513c844603fsm1340462lfk.41.2024.03.17.13.01.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 13:01:14 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 17 Mar 2024 22:00:51 +0200 Message-ID: <20240317200100.152097-15-jeebjp@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240317200100.152097-1-jeebjp@gmail.com> References: <20240317200100.152097-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v9 14/14] 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: Nom6nk/HdBiv 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 | 89 ++++++++++++++++++++++++++++++++++++ tests/fate/enc_external.mak | 5 ++ tests/ref/fate/libx265-hdr10 | 16 +++++++ 3 files changed, 110 insertions(+) create mode 100644 tests/ref/fate/libx265-hdr10 diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index 92183b9ca2..0c884fe04d 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" @@ -176,6 +178,86 @@ static av_cold int libx265_param_parse_int(AVCodecContext *avctx, return 0; } +static int handle_mdcv(const AVClass **avcl, const x265_api *api, + x265_param *params, + const AVMasteringDisplayMetadata *mdcv) +{ + int ret = AVERROR_BUG; + 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)) { + av_log(avcl, AV_LOG_ERROR, + "MDCV string too long for its available space!\n"); + ret = AVERROR(ENOMEM); + goto end; + } + + if (api->param_parse(params, "master-display", buf.str) == + X265_PARAM_BAD_VALUE) { + av_log(avcl, AV_LOG_ERROR, + "Invalid value \"%s\" for param \"master-display\".\n", + buf.str); + 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 AVFrameSideData *cll_sd = + av_frame_side_data_get( + (const AVFrameSideData **)avctx->encoder_side_data, + avctx->nb_encoder_side_data, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); + const AVFrameSideData *mdcv_sd = + av_frame_side_data_get( + (const AVFrameSideData **)avctx->encoder_side_data, + avctx->nb_encoder_side_data, + 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->av_class, 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; @@ -336,6 +418,13 @@ FF_ENABLE_DEPRECATION_WARNINGS 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]; diff --git a/tests/fate/enc_external.mak b/tests/fate/enc_external.mak index 4095a4b51a..30021efbcd 100644 --- a/tests/fate/enc_external.mak +++ b/tests/fate/enc_external.mak @@ -12,5 +12,10 @@ FATE_ENC_EXTERNAL-$(call ENCDEC, LIBX264 HEVC, MOV, LIBX264_HDR10 HEVC_DEMUXER H fate-libx264-hdr10: CMD = enc_external $(TARGET_SAMPLES)/hevc/hdr10_plus_h265_sample.hevc \ mp4 "-c:v libx264" "-show_frames -show_entries frame=side_data_list -of flat" +# test for x265 MDCV and CLL passthrough during encoding +FATE_ENC_EXTERNAL-$(call ENCDEC, LIBX265 HEVC, MOV, HEVC_DEMUXER) += fate-libx265-hdr10 +fate-libx265-hdr10: CMD = enc_external $(TARGET_SAMPLES)/hevc/hdr10_plus_h265_sample.hevc \ + mp4 "-c:v libx265" "-show_frames -show_entries frame=side_data_list -of flat" + FATE_SAMPLES_FFMPEG_FFPROBE += $(FATE_ENC_EXTERNAL-yes) fate-enc-external: $(FATE_ENC_EXTERNAL-yes) diff --git a/tests/ref/fate/libx265-hdr10 b/tests/ref/fate/libx265-hdr10 new file mode 100644 index 0000000000..571c837cac --- /dev/null +++ b/tests/ref/fate/libx265-hdr10 @@ -0,0 +1,16 @@ +frames.frame.0.side_data_list.side_data.0.side_data_type="H.26[45] User Data Unregistered SEI message" +frames.frame.0.side_data_list.side_data.1.side_data_type="H.26[45] User Data Unregistered SEI message" +frames.frame.0.side_data_list.side_data.2.side_data_type="Mastering display metadata" +frames.frame.0.side_data_list.side_data.2.red_x="13250/50000" +frames.frame.0.side_data_list.side_data.2.red_y="34500/50000" +frames.frame.0.side_data_list.side_data.2.green_x="7500/50000" +frames.frame.0.side_data_list.side_data.2.green_y="3000/50000" +frames.frame.0.side_data_list.side_data.2.blue_x="34000/50000" +frames.frame.0.side_data_list.side_data.2.blue_y="16000/50000" +frames.frame.0.side_data_list.side_data.2.white_point_x="15635/50000" +frames.frame.0.side_data_list.side_data.2.white_point_y="16450/50000" +frames.frame.0.side_data_list.side_data.2.min_luminance="50/10000" +frames.frame.0.side_data_list.side_data.2.max_luminance="10000000/10000" +frames.frame.0.side_data_list.side_data.3.side_data_type="Content light level metadata" +frames.frame.0.side_data_list.side_data.3.max_content=1000 +frames.frame.0.side_data_list.side_data.3.max_average=200