From patchwork Fri Jul 21 13:37:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "J. Dekker" X-Patchwork-Id: 42884 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:be1d:b0:130:ccc6:6c4b with SMTP id ge29csp228445pzb; Fri, 21 Jul 2023 06:38:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlFzcHpG06waK/0+NNz4bu/5mnFKPJvhJMHw366JPDC3NU76OWmtyMvljXtrTm0zYKiCDNE5 X-Received: by 2002:a17:906:12:b0:987:5761:2868 with SMTP id 18-20020a170906001200b0098757612868mr1747916eja.11.1689946694992; Fri, 21 Jul 2023 06:38:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689946694; cv=none; d=google.com; s=arc-20160816; b=CksuXbNfzCjBs2wKk1cS+4CRQxX77QZwftSSZdkop3Ahk6NRM9SKmOWPAEyMlyWSUr zJJ6i66/ifC3N+L/1XLUti7v1H+/eHaA9zOBZkc/+ykjv7gYTdSVHe9EtVVQo96EUrYr K4G/PCdH/9W6oP1uvFWmgTodRDYYDY/2ln6VXM5RogBseltJouQfdA5BaFk4rqtjN221 N+OyYuN7gJfGBXRx7PnECb4rfyfVD0e+/ihJJA4o8UTWCWQ5n4OyG+Al7lUx0day1uPE 7OlZJKtsX50ikjOhGRlyU/VXD1WmAGVssq1a7N77hGOd296qd94aSSd0hr11Vd9zClbk xP0w== 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:message-id:date:to:from:feedback-id :dkim-signature:dkim-signature:delivered-to; bh=oPUVJdGOCWEXYilK9zFZUG46uahyDu51AEHQLfvh9s0=; fh=RX379NAUHdZIU7CQlxbXTMt5HBBB5CUKf4o4OtPlQjY=; b=tJRAf+XA95teB8V4nt5wyRNERmd129xy4E+e1NUgsCeU5cimMBdKNAmrqP74XgcwnE Fy+Rrj7X/wzE8NReNE9SUxXWcfey7TBKA575qGMLD5vsR6Z6ObxmTkt0Azl34cLMsMvb JyPUCOuySMp+HqjANFFBDxPNUujfnf7Cvp6leIESDiFoaU9D2fuWDq4pJnZ0UW44yfNu TQ5HU/NUjdmF+6002D1jQy/co9ny3dTTpUzwW4QAe/kfYCrWxf/DcCBjrn7vI4DZy6HU VVSrF0zoDFgdrOlGERqmCVLjNR834/n2ktnu7RL2/Cct80qG1/XqOgN3Nm4ybUGwe7jf XdCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@itanimul.li header.s=fm1 header.b=AnxwZuH0; dkim=neutral (body hash did not verify) header.i=@messagingengine.com header.s=fm3 header.b="h02VIy6/"; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id pg1-20020a170907204100b009926703c4b9si2207770ejb.413.2023.07.21.06.38.14; Fri, 21 Jul 2023 06:38:14 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@itanimul.li header.s=fm1 header.b=AnxwZuH0; dkim=neutral (body hash did not verify) header.i=@messagingengine.com header.s=fm3 header.b="h02VIy6/"; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C9E8E68C3F0; Fri, 21 Jul 2023 16:37:59 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 32E0868C3F0 for ; Fri, 21 Jul 2023 16:37:52 +0300 (EEST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 941A95C011B for ; Fri, 21 Jul 2023 09:37:49 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Fri, 21 Jul 2023 09:37:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=itanimul.li; h= cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:message-id:mime-version:reply-to:sender:subject :subject:to:to; s=fm1; t=1689946669; x=1690033069; bh=CKmzQn0vaG V7nO1uGqenvX/xi8fKwi6x8lAtKntEYZA=; b=AnxwZuH0e29GLbgKdoEGzvs1f5 ROMofn8Mdm6My8uG3wV+9BCn+tWT58HQDsZXGGIPRXXllydxGZDjFwjccSi9BPlj zxf7bvzGMVGRojYJ6Wt+0x7s4FgeevoiiE6RhHKFt2EjxbdNITEW3sC2zpOja4vI XzcLcRKYiF3v65HZah3iohUP0H37Ytv/M+Ci86eRDouUqCUAai0Na6o93HNWncXk G2LqFZtjhqhq+qsDS+Usa7FBkvoYJ4W9DY0hFwwhFhrOzdk8W9d8A073FJFnsvck JTLRbLFV8VIwvfkhrn96DA7NntJZ2wc2RbDjO/BVO7dsy3I9W5YU32GTsxfA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :message-id:mime-version:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1689946669; x=1690033069; bh=CKmzQn0vaGV7nO1uGqenvX/xi8fK wi6x8lAtKntEYZA=; b=h02VIy6/uPbosfz2o+27JsO2JLqH++itqUlea6UfEGPX Tm6bzsLAQpZarGol6lorf1d/rJMZzuQv+TcdJ0SxJIikCP9nRq9YX4U1o5hCL5Pj jcX3g4sI7RkJ/oGVtDW4juTHvjVAfUaZQAci3CGcE6k73gOiWxmFZdzikYX5Ywp5 ua8KE9LxABjvFDBMFLffa5hWeE5nU9LVyYiiyIXPIQDyBNmBSmrTggG9XFj95ugk c2Mz77jbl57H0WdNBhvhTZ54Nur1Jncf41nMdjLaF9cm7pa1Op2GwrFS/vW1RmLi 51WL4c0OElM2CHcsv41+7xxNIR1iph8nZOu8sGkzzw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrhedvgdeivdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffoggfgsedtkeertdertd dtnecuhfhrohhmpedflfdrucffvghkkhgvrhdfuceojhguvghksehithgrnhhimhhulhdr lhhiqeenucggtffrrghtthgvrhhnpeeutefgtdeuvdejjeejvdetleffueehtdeftedugf elhfejueektedvvddtveeiieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhep mhgrihhlfhhrohhmpehjuggvkhesihhtrghnihhmuhhlrdhlih X-ME-Proxy: Feedback-ID: i84994747:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 21 Jul 2023 09:37:48 -0400 (EDT) From: "J. Dekker" To: ffmpeg-devel@ffmpeg.org Date: Fri, 21 Jul 2023 15:37:40 +0200 Message-ID: <20230721133746.33335-1-jdek@itanimul.li> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/7] lavu: add ecinfo sidedata 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: bhczbnGZ+pzd Add sidedata for passing basic Error Concealment information helpful to a renderer or end user attempting to filter or conceal video decoding errors and artifacts. Co-Authored-By: Thomas Guillem Signed-off-by: J. Dekker --- libavutil/Makefile | 2 ++ libavutil/ec.c | 42 +++++++++++++++++++++++++++++ libavutil/ec.h | 66 +++++++++++++++++++++++++++++++++++++++++++++ libavutil/frame.c | 1 + libavutil/frame.h | 6 +++++ libavutil/version.h | 2 +- 6 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 libavutil/ec.c create mode 100644 libavutil/ec.h diff --git a/libavutil/Makefile b/libavutil/Makefile index bd9c6f9e32..81b6b1fb8a 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -28,6 +28,7 @@ HEADERS = adler32.h \ display.h \ dovi_meta.h \ downmix_info.h \ + ec.h \ encryption_info.h \ error.h \ eval.h \ @@ -124,6 +125,7 @@ OBJS = adler32.o \ dovi_meta.o \ downmix_info.o \ encryption_info.o \ + ec.o \ error.o \ eval.o \ fifo.o \ diff --git a/libavutil/ec.c b/libavutil/ec.c new file mode 100644 index 0000000000..762accd0a6 --- /dev/null +++ b/libavutil/ec.c @@ -0,0 +1,42 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "ec.h" + +AVECInfo *av_eci_create_side_data(AVFrame *f) +{ + AVBufferRef *buf = NULL; + AVECInfo *eci = av_mallocz(sizeof(AVECInfo)); + + if (!eci) + return NULL; + + buf = av_buffer_create((uint8_t *)eci, sizeof(AVECInfo), NULL, NULL, 0); + if (!buf) { + av_freep(&eci); + return NULL; + } + + if (!av_frame_new_side_data_from_buf(f, AV_FRAME_DATA_EC_INFO, buf)) { + av_buffer_unref(&buf); + return NULL; + } + + return eci; +} diff --git a/libavutil/ec.h b/libavutil/ec.h new file mode 100644 index 0000000000..439fe876a2 --- /dev/null +++ b/libavutil/ec.h @@ -0,0 +1,66 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_EC_H +#define AVUTIL_EC_H + +#include +#include +#include + +#include "libavutil/mem.h" +#include "libavutil/frame.h" + +/** + * Error Concealment information helpful to a renderer or end user + * attempting to filter or conceal video decoding errors and artifacts. + */ +typedef struct AVECInfo { + /** + * Integer estimating how many pixels of the video frame had decoding + * errors. + */ + uint64_t error; + /** + * Integer estimating how many pixels of the video frame decoded + * without error. + */ + uint64_t ok; + /** + * Integer estimating how many pixels of the video frame's reference + * frames had decoding errors. + */ + uint64_t ref_error; + /** + * Integer estimating how many pixels of the video frame's reference + * frames decoded without error. + */ + uint64_t ref_ok; +} AVECInfo; + +static inline void av_eci_reset(AVECInfo *info) +{ + info->error = info->ok = info->ref_error = info->ref_ok = 0; +} + +/** + * Creates AVECInfo in a specified frame as side data. + */ +AVECInfo *av_eci_create_side_data(AVFrame *f); + +#endif /* AVUTIL_EC_H */ diff --git a/libavutil/frame.c b/libavutil/frame.c index b6cee2d886..30a838bf22 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -960,6 +960,7 @@ const char *av_frame_side_data_name(enum AVFrameSideDataType type) case AV_FRAME_DATA_DOVI_RPU_BUFFER: return "Dolby Vision RPU Data"; case AV_FRAME_DATA_DOVI_METADATA: return "Dolby Vision Metadata"; case AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT: return "Ambient viewing environment"; + case AV_FRAME_DATA_EC_INFO: return "Error Concealment Information"; } return NULL; } diff --git a/libavutil/frame.h b/libavutil/frame.h index a491315f25..08c6b96d29 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -214,6 +214,12 @@ enum AVFrameSideDataType { * Ambient viewing environment metadata, as defined by H.274. */ AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT, + /** + * Error Concealment Information helpful to a renderer attempting to filter + * or conceal video decoding errors and artifacts. See AVECInfo defined in + * libavutil/error.h. + */ + AV_FRAME_DATA_EC_INFO, }; enum AVActiveFormatDescription { diff --git a/libavutil/version.h b/libavutil/version.h index 24af520e08..9e798b0e3f 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 58 -#define LIBAVUTIL_VERSION_MINOR 14 +#define LIBAVUTIL_VERSION_MINOR 15 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \