aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil
diff options
context:
space:
mode:
authorZhao Zhili <zhilizhao@tencent.com>2025-07-06 16:05:38 +0800
committerZhao Zhili <zhilizhao@tencent.com>2025-07-18 14:44:39 +0800
commitfbda5ffb95382ed3b51a3577f9287c8eb548b0b7 (patch)
treecc1a58849100f2f194f74a4595dfcee66dc2e876 /libavutil
parent7b13d17b6d88190c49e887134bba6a43d716d50a (diff)
downloadffmpeg-fbda5ffb95382ed3b51a3577f9287c8eb548b0b7.tar.gz
avutil/hwcontext: Add ohcodec device and pixel format
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/Makefile2
-rw-r--r--libavutil/hwcontext.c4
-rw-r--r--libavutil/hwcontext.h2
-rw-r--r--libavutil/hwcontext_internal.h1
-rw-r--r--libavutil/hwcontext_oh.c47
-rw-r--r--libavutil/hwcontext_oh.h34
-rw-r--r--libavutil/pixdesc.c4
-rw-r--r--libavutil/pixfmt.h2
-rw-r--r--libavutil/version.h4
9 files changed, 98 insertions, 2 deletions
diff --git a/libavutil/Makefile b/libavutil/Makefile
index 94a56bb72f..ee77e51c08 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -51,6 +51,7 @@ HEADERS = adler32.h \
hwcontext_qsv.h \
hwcontext_mediacodec.h \
hwcontext_opencl.h \
+ hwcontext_oh.h \
hwcontext_vaapi.h \
hwcontext_videotoolbox.h \
hwcontext_vdpau.h \
@@ -210,6 +211,7 @@ OBJS-$(CONFIG_AMF) += hwcontext_amf.o
OBJS-$(CONFIG_LIBDRM) += hwcontext_drm.o
OBJS-$(CONFIG_MACOS_KPERF) += macos_kperf.o
OBJS-$(CONFIG_MEDIACODEC) += hwcontext_mediacodec.o
+OBJS-$(CONFIG_OHCODEC) += hwcontext_oh.o
OBJS-$(CONFIG_OPENCL) += hwcontext_opencl.o
OBJS-$(CONFIG_QSV) += hwcontext_qsv.o
OBJS-$(CONFIG_VAAPI) += hwcontext_vaapi.o
diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index 3111a44651..83bd7457e8 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -69,6 +69,9 @@ static const HWContextType * const hw_table[] = {
#if CONFIG_AMF
&ff_hwcontext_type_amf,
#endif
+#if CONFIG_OHCODEC
+ &ff_hwcontext_type_oh,
+#endif
NULL,
};
@@ -86,6 +89,7 @@ static const char *const hw_type_names[] = {
[AV_HWDEVICE_TYPE_MEDIACODEC] = "mediacodec",
[AV_HWDEVICE_TYPE_VULKAN] = "vulkan",
[AV_HWDEVICE_TYPE_AMF] = "amf",
+ [AV_HWDEVICE_TYPE_OHCODEC] = "ohcodec",
};
typedef struct FFHWDeviceContext {
diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h
index 96042ba197..94fd11da73 100644
--- a/libavutil/hwcontext.h
+++ b/libavutil/hwcontext.h
@@ -39,6 +39,8 @@ enum AVHWDeviceType {
AV_HWDEVICE_TYPE_VULKAN,
AV_HWDEVICE_TYPE_D3D12VA,
AV_HWDEVICE_TYPE_AMF,
+ /* OpenHarmony Codec device */
+ AV_HWDEVICE_TYPE_OHCODEC,
};
/**
diff --git a/libavutil/hwcontext_internal.h b/libavutil/hwcontext_internal.h
index db23579c9e..dcfdc2016a 100644
--- a/libavutil/hwcontext_internal.h
+++ b/libavutil/hwcontext_internal.h
@@ -164,5 +164,6 @@ extern const HWContextType ff_hwcontext_type_videotoolbox;
extern const HWContextType ff_hwcontext_type_mediacodec;
extern const HWContextType ff_hwcontext_type_vulkan;
extern const HWContextType ff_hwcontext_type_amf;
+extern const HWContextType ff_hwcontext_type_oh;
#endif /* AVUTIL_HWCONTEXT_INTERNAL_H */
diff --git a/libavutil/hwcontext_oh.c b/libavutil/hwcontext_oh.c
new file mode 100644
index 0000000000..6d1f27cfc5
--- /dev/null
+++ b/libavutil/hwcontext_oh.c
@@ -0,0 +1,47 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * Copyright (c) 2025 Zhao Zhili <quinkblack@foxmail.com>
+ *
+ * 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 <multimedia/player_framework/native_avcodec_base.h>
+
+#include "hwcontext.h"
+#include "hwcontext_internal.h"
+#include "hwcontext_oh.h"
+
+static int oh_device_create(AVHWDeviceContext *ctx, const char *device,
+ AVDictionary *opts, int flags)
+{
+ if (device && device[0]) {
+ av_log(ctx, AV_LOG_ERROR, "Device selection unsupported.\n");
+ return AVERROR_UNKNOWN;
+ }
+
+ return 0;
+}
+
+const HWContextType ff_hwcontext_type_oh = {
+ .type = AV_HWDEVICE_TYPE_OHCODEC,
+ .name = "ohcodec",
+ .device_hwctx_size = sizeof(AVOHCodecDeviceContext),
+ .device_create = oh_device_create,
+ .pix_fmts = (const enum AVPixelFormat[]) {
+ AV_PIX_FMT_OHCODEC,
+ AV_PIX_FMT_NONE
+ },
+};
diff --git a/libavutil/hwcontext_oh.h b/libavutil/hwcontext_oh.h
new file mode 100644
index 0000000000..2794f85b7d
--- /dev/null
+++ b/libavutil/hwcontext_oh.h
@@ -0,0 +1,34 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * Copyright (c) 2025 Zhao Zhili <quinkblack@foxmail.com>
+ *
+ * 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_HWCONTEXT_OH_H
+#define AVUTIL_HWCONTEXT_OH_H
+
+/**
+ * OpenHarmony codec device
+ */
+typedef struct AVOHCodecDeviceContext {
+ /**
+ * Pointer to OHNativeWindow
+ */
+ void *native_window;
+} AVOHCodecDeviceContext;
+
+#endif /* AVUTIL_HWCONTEXT_OH_H */
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 8eb04d1f12..f0be20d749 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -3263,6 +3263,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
},
.flags = AV_PIX_FMT_FLAG_BE,
},
+ [AV_PIX_FMT_OHCODEC] = {
+ .name = "ohcodec",
+ .flags = AV_PIX_FMT_FLAG_HWACCEL,
+ },
};
static const char * const color_range_names[] = {
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index 9024850207..823ea8edab 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -497,6 +497,8 @@ enum AVPixelFormat {
AV_PIX_FMT_GBRP12MSBBE, ///< planar GBR 4:4:4 36bpp, lowest bits zero, big-endian
AV_PIX_FMT_GBRP12MSBLE, ///< planar GBR 4:4:4 36bpp, lowest bits zero, little-endian
+ AV_PIX_FMT_OHCODEC, /// hardware decoding through openharmony
+
AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions
};
diff --git a/libavutil/version.h b/libavutil/version.h
index 2c0aa3e35e..29cd31e229 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,8 +79,8 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 60
-#define LIBAVUTIL_VERSION_MINOR 4
-#define LIBAVUTIL_VERSION_MICRO 101
+#define LIBAVUTIL_VERSION_MINOR 5
+#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \