[FFmpeg-devel] [PATCH 1/7] lavu: add ecinfo sidedata
J. Dekker
jdek at itanimul.li
Fri Jul 21 16:37:40 EEST 2023
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 <thomas at gllm.fr>
Signed-off-by: J. Dekker <jdek at itanimul.li>
---
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 <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#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, \
--
2.41.0
More information about the ffmpeg-devel
mailing list